123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991 |
- using PaintDotNet.Base.CommTool;
- using PaintDotNet.Base.Enum;
- using PaintDotNet.Base.Functionodel;
- using PaintDotNet.CustomControl;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace PaintDotNet.GeneralAnalysis
- {
- /// <summary>
- /// 颗粒统计-条件设置
- /// </summary>
- internal class DebrisSelectionValidConditionDialog : PdnBaseForm
- {
- private GroupBox groupBox1;
- private Button button4;
- private Button button3;
- private Button button2;
- private GroupBox groupBox2;
- private Button button5;
- private Button button6;
- private Button button7;
- private Button button8;
- private GroupBox groupBox3;
- private Button button1;
- private ListView listView1;
- private GroupBox groupBox4;
- private PictureBox pictureBox1;
- private RichTextBox richTextBox1;
- private ListView listView2;
- private DataGridView dataGridView1;
- /// <summary>
- /// 父级窗体
- /// </summary>
- private DebrisSelectionDialog debrisSelectionDialog;
- /// <summary>
- /// xml对象
- /// </summary>
- private DebrisSelectionModel debrisSelectionModel;
- public DebrisSelectionValidConditionDialog(DebrisSelectionDialog debrisSelectionDialog)
- {
- this.debrisSelectionDialog = debrisSelectionDialog;
- this.debrisSelectionModel = debrisSelectionDialog.debrisSelectionModel;
- InitializeComponent();
- InitializeLanguageText();
- InitOtherTools();
- InitSavedCondition();
- }
- private void InitializeLanguageText()
- {
- this.button8.Text = PdnResources.GetString("Menu.LabelAction.MoveDownAction.Text");
- this.groupBox3.Text = PdnResources.GetString("Menu.Generalanalysis.Particlestatistics.Conditionselection.text");
- this.groupBox4.Text = PdnResources.GetString("Menu.Generalanalysis.Particlestatistics.Descriptionofstatisticaldata.text");
- this.Text = PdnResources.GetString("Menu.Generalanalysis.Particlestatistics.Conditionsetting.text");
- this.groupBox1.Text = PdnResources.GetString("Menu.operation.text");
- this.button4.Text = PdnResources.GetString("Menu.File.Save.Text");
- this.button3.Text = PdnResources.GetString("Menu.Edit.Delete.Text");
- this.button2.Text = PdnResources.GetString("Menu.Rename.text");
- this.button1.Text = PdnResources.GetString("Menu.New.text");
- this.groupBox2.Text = PdnResources.GetString("Menu.Generalanalysis.Particlestatistics.Aconditionalrecordhasbeenadded.text");
- this.button5.Text = "< " + PdnResources.GetString("Menu.Addto.text");
- this.button6.Text = PdnResources.GetString("Menu.Moveout.text") + " >";
- this.button7.Text = PdnResources.GetString("Menu.LabelAction.MoveUpAction.Text");
- }
- private void InitializeComponent()
- {
- 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.groupBox2 = new System.Windows.Forms.GroupBox();
- this.dataGridView1 = new System.Windows.Forms.DataGridView();
- this.listView2 = new System.Windows.Forms.ListView();
- this.button5 = new System.Windows.Forms.Button();
- this.button6 = new System.Windows.Forms.Button();
- this.button7 = new System.Windows.Forms.Button();
- this.button8 = new System.Windows.Forms.Button();
- this.groupBox3 = new System.Windows.Forms.GroupBox();
- this.groupBox4 = new System.Windows.Forms.GroupBox();
- this.richTextBox1 = new System.Windows.Forms.RichTextBox();
- this.pictureBox1 = new System.Windows.Forms.PictureBox();
- this.listView1 = new System.Windows.Forms.ListView();
- this.groupBox1.SuspendLayout();
- this.groupBox2.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
- this.groupBox3.SuspendLayout();
- this.groupBox4.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
- this.SuspendLayout();
- //
- // 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.Location = new System.Drawing.Point(13, 13);
- this.groupBox1.Name = "groupBox1";
- this.groupBox1.Size = new System.Drawing.Size(705, 54);
- this.groupBox1.TabIndex = 0;
- this.groupBox1.TabStop = false;
- this.groupBox1.Text = "操作";
- //
- // button4
- //
- this.button4.Location = new System.Drawing.Point(618, 20);
- this.button4.Name = "button4";
- this.button4.Size = new System.Drawing.Size(75, 23);
- this.button4.TabIndex = 3;
- this.button4.Text = "保存";
- this.button4.UseVisualStyleBackColor = true;
- this.button4.Click += new System.EventHandler(this.button4_Click);
- //
- // button3
- //
- this.button3.Location = new System.Drawing.Point(538, 20);
- this.button3.Name = "button3";
- this.button3.Size = new System.Drawing.Size(75, 23);
- this.button3.TabIndex = 2;
- this.button3.Text = "删除";
- this.button3.UseVisualStyleBackColor = true;
- this.button3.Click += new System.EventHandler(this.button3_Click);
- //
- // button2
- //
- this.button2.Location = new System.Drawing.Point(457, 20);
- this.button2.Name = "button2";
- this.button2.Size = new System.Drawing.Size(75, 23);
- this.button2.TabIndex = 1;
- this.button2.Text = "重命名";
- this.button2.UseVisualStyleBackColor = true;
- this.button2.Click += new System.EventHandler(this.button2_Click);
- //
- // button1
- //
- this.button1.Location = new System.Drawing.Point(376, 20);
- this.button1.Name = "button1";
- this.button1.Size = new System.Drawing.Size(75, 23);
- this.button1.TabIndex = 0;
- this.button1.Text = "新建";
- this.button1.UseVisualStyleBackColor = true;
- this.button1.Click += new System.EventHandler(this.button1_Click);
- //
- // groupBox2
- //
- this.groupBox2.Controls.Add(this.dataGridView1);
- this.groupBox2.Controls.Add(this.listView2);
- this.groupBox2.Location = new System.Drawing.Point(13, 74);
- this.groupBox2.Name = "groupBox2";
- this.groupBox2.Size = new System.Drawing.Size(407, 411);
- this.groupBox2.TabIndex = 1;
- this.groupBox2.TabStop = false;
- this.groupBox2.Text = "已添加条件设置记录";
- //
- // dataGridView1
- //
- this.dataGridView1.AllowUserToAddRows = false;
- this.dataGridView1.AllowUserToDeleteRows = false;
- this.dataGridView1.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.dataGridView1.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
- this.dataGridView1.BackgroundColor = System.Drawing.Color.White;
- this.dataGridView1.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.None;
- this.dataGridView1.EditMode = System.Windows.Forms.DataGridViewEditMode.EditOnEnter;
- this.dataGridView1.Location = new System.Drawing.Point(135, 21);
- this.dataGridView1.MultiSelect = false;
- this.dataGridView1.Name = "dataGridView1";
- this.dataGridView1.RowHeadersVisible = false;
- this.dataGridView1.RowTemplate.Height = 23;
- this.dataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
- this.dataGridView1.Size = new System.Drawing.Size(266, 367);
- this.dataGridView1.TabIndex = 1;
- this.dataGridView1.CurrentCellDirtyStateChanged += new System.EventHandler(this.dataGridView1_CurrentCellDirtyStateChanged);
- //
- // listView2
- //
- this.listView2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
- | System.Windows.Forms.AnchorStyles.Left)));
- this.listView2.FullRowSelect = true;
- this.listView2.HideSelection = false;
- this.listView2.Location = new System.Drawing.Point(7, 21);
- this.listView2.MultiSelect = false;
- this.listView2.Name = "listView2";
- this.listView2.Size = new System.Drawing.Size(121, 367);
- this.listView2.TabIndex = 0;
- this.listView2.UseCompatibleStateImageBehavior = false;
- this.listView2.SelectedIndexChanged += new System.EventHandler(this.listView2_SelectedIndexChanged);
- //
- // button5
- //
- this.button5.Location = new System.Drawing.Point(426, 173);
- this.button5.Name = "button5";
- this.button5.Size = new System.Drawing.Size(75, 23);
- this.button5.TabIndex = 2;
- this.button5.Text = "添加";
- this.button5.UseVisualStyleBackColor = true;
- this.button5.Click += new System.EventHandler(this.button5_Click);
- //
- // button6
- //
- this.button6.Location = new System.Drawing.Point(426, 202);
- this.button6.Name = "button6";
- this.button6.Size = new System.Drawing.Size(75, 23);
- this.button6.TabIndex = 3;
- this.button6.Text = "移出";
- this.button6.UseVisualStyleBackColor = true;
- this.button6.Click += new System.EventHandler(this.button6_Click);
- //
- // button7
- //
- this.button7.Location = new System.Drawing.Point(426, 353);
- this.button7.Name = "button7";
- this.button7.Size = new System.Drawing.Size(75, 23);
- this.button7.TabIndex = 4;
- this.button7.Text = "向上移动";
- this.button7.UseVisualStyleBackColor = true;
- this.button7.Click += new System.EventHandler(this.button7_Click);
- //
- // button8
- //
- this.button8.Location = new System.Drawing.Point(426, 382);
- this.button8.Name = "button8";
- this.button8.Size = new System.Drawing.Size(75, 23);
- this.button8.TabIndex = 5;
- this.button8.Text = "向下移动";
- this.button8.UseVisualStyleBackColor = true;
- this.button8.Click += new System.EventHandler(this.button8_Click);
- //
- // groupBox3
- //
- this.groupBox3.Controls.Add(this.groupBox4);
- this.groupBox3.Controls.Add(this.listView1);
- this.groupBox3.Location = new System.Drawing.Point(507, 74);
- this.groupBox3.Name = "groupBox3";
- this.groupBox3.Size = new System.Drawing.Size(211, 411);
- this.groupBox3.TabIndex = 6;
- this.groupBox3.TabStop = false;
- this.groupBox3.Text = "条件选择";
- //
- // groupBox4
- //
- this.groupBox4.Controls.Add(this.richTextBox1);
- this.groupBox4.Controls.Add(this.pictureBox1);
- this.groupBox4.Location = new System.Drawing.Point(17, 279);
- this.groupBox4.Name = "groupBox4";
- this.groupBox4.Size = new System.Drawing.Size(182, 126);
- this.groupBox4.TabIndex = 1;
- this.groupBox4.TabStop = false;
- this.groupBox4.Visible = false;
- //
- // richTextBox1
- //
- this.richTextBox1.BackColor = System.Drawing.SystemColors.Control;
- this.richTextBox1.BorderStyle = System.Windows.Forms.BorderStyle.None;
- this.richTextBox1.Location = new System.Drawing.Point(95, 29);
- this.richTextBox1.Name = "richTextBox1";
- this.richTextBox1.ReadOnly = true;
- this.richTextBox1.Size = new System.Drawing.Size(75, 80);
- this.richTextBox1.TabIndex = 1;
- this.richTextBox1.Text = "";
- //
- // pictureBox1
- //
- this.pictureBox1.BackColor = System.Drawing.Color.White;
- this.pictureBox1.Location = new System.Drawing.Point(10, 29);
- this.pictureBox1.Name = "pictureBox1";
- this.pictureBox1.Size = new System.Drawing.Size(80, 80);
- this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
- this.pictureBox1.TabIndex = 0;
- this.pictureBox1.TabStop = false;
- //
- // listView1
- //
- this.listView1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.listView1.FullRowSelect = true;
- this.listView1.HideSelection = false;
- this.listView1.Location = new System.Drawing.Point(27, 20);
- this.listView1.MultiSelect = false;
- this.listView1.Name = "listView1";
- this.listView1.Size = new System.Drawing.Size(160, 385);
- this.listView1.TabIndex = 0;
- this.listView1.UseCompatibleStateImageBehavior = false;
- this.listView1.SelectedIndexChanged += new System.EventHandler(this.listView1_SelectedIndexChanged);
- this.listView1.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.listView1_MouseDoubleClick);
- //
- // DebrisSelectionValidConditionDialog
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
- this.ClientSize = new System.Drawing.Size(730, 497);
- this.Controls.Add(this.groupBox3);
- this.Controls.Add(this.button8);
- this.Controls.Add(this.button7);
- this.Controls.Add(this.button6);
- this.Controls.Add(this.button5);
- this.Controls.Add(this.groupBox2);
- this.Controls.Add(this.groupBox1);
- this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
- this.MaximizeBox = false;
- this.MinimizeBox = false;
- this.Name = "DebrisSelectionValidConditionDialog";
- this.Text = "条件设置";
- this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.DebrisSelectionValidConditionDialog_FormClosed);
- this.Controls.SetChildIndex(this.groupBox1, 0);
- this.Controls.SetChildIndex(this.groupBox2, 0);
- this.Controls.SetChildIndex(this.button5, 0);
- this.Controls.SetChildIndex(this.button6, 0);
- this.Controls.SetChildIndex(this.button7, 0);
- this.Controls.SetChildIndex(this.button8, 0);
- this.Controls.SetChildIndex(this.groupBox3, 0);
- this.groupBox1.ResumeLayout(false);
- this.groupBox2.ResumeLayout(false);
- ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
- this.groupBox3.ResumeLayout(false);
- this.groupBox4.ResumeLayout(false);
- ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
- this.ResumeLayout(false);
- }
- /// <summary>
- /// 加载其他工具
- /// </summary>
- private void InitOtherTools()
- {
- //
- //已添加listview
- //
- this.listView2.View = View.Details;
- ColumnHeader header0 = new ColumnHeader();
- header0.Text = PdnResources.GetString("Menu.Generalanalysis.Particlestatistics.Alistofconditionshasbeenadded.text");
- header0.Width = 114;
- this.listView2.Columns.Add(header0);
- this.listView2.SelectedItems.Clear();
- //
- //已添加datagridview
- //
- this.dataGridView1.ColumnHeadersHeight = 35;
- DataGridViewTextBoxColumn h1 = new DataGridViewTextBoxColumn();
- h1.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
- h1.Width = 80;
- DataGridViewComboBoxColumn h2 = new DataGridViewComboBoxColumn();
- h2.Width = 55;
- DataGridViewTextBoxColumn h3 = new DataGridViewTextBoxColumn();
- h3.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
- h3.Width = 55;
- DataGridViewComboBoxColumn h4 = new DataGridViewComboBoxColumn();
- h4.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
- h4.Width = 55;
- this.dataGridView1.Columns.Add(h1);
- this.dataGridView1.Columns.Add(h2);
- this.dataGridView1.Columns.Add(h3);
- this.dataGridView1.Columns.Add(h4);
- DataGridViewHelper helper = new DataGridViewHelper(this.dataGridView1);
- helper.Headers.Add(new DataGridViewHelper.TopHeader(0, 1, PdnResources.GetString("Menu.projectname.text")));
- helper.Headers.Add(new DataGridViewHelper.TopHeader(1, 1, PdnResources.GetString("Menu.judgementconditions.text")));
- helper.Headers.Add(new DataGridViewHelper.TopHeader(2, 1, PdnResources.GetString("Menu.Conditionvalue.text")));
- helper.Headers.Add(new DataGridViewHelper.TopHeader(3, 1, PdnResources.GetString("Menu.associatedcondition.text")));
- this.dataGridView1.Columns[0].SortMode = DataGridViewColumnSortMode.NotSortable;
- this.dataGridView1.Columns[0].ReadOnly = true;
- this.dataGridView1.Columns[0].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;//文字居中
- this.dataGridView1.Columns[1].SortMode = DataGridViewColumnSortMode.NotSortable;
- this.dataGridView1.Columns[1].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
- this.dataGridView1.Columns[2].SortMode = DataGridViewColumnSortMode.NotSortable;
- this.dataGridView1.Columns[2].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
- this.dataGridView1.Columns[3].SortMode = DataGridViewColumnSortMode.NotSortable;
- this.dataGridView1.Columns[3].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
- this.dataGridView1.AllowUserToResizeRows = false;
- this.dataGridView1.AllowUserToResizeColumns = false;
- //
- //条件选择listview
- //
- this.listView1.View = View.Details;
- ColumnHeader header1 = new ColumnHeader();
- header1.Text = PdnResources.GetString("Menu.Generalanalysis.Particlestatistics.Conditionlist.text");
- header1.Width = 138;
- this.listView1.Columns.Add(header1);
- foreach (KeyValuePair<Enum, Object> entry in InvariantData.debrisSelectionparameters)
- {
- ListViewItem listViewItem = new ListViewItem();
- listViewItem.Tag = entry.Key;
- listViewItem.SubItems[0].Text = entry.Value.ToString();
- this.listView1.Items.Add(listViewItem);
- }
-
- this.listView1.SelectedItems.Clear();
- }
- /// <summary>
- /// 加载已保存的条件
- /// </summary>
- private void InitSavedCondition()
- {
- if(this.debrisSelectionModel != null && this.debrisSelectionModel.debrisSelectionList.Count > 0)
- {
- for(int i = 0; i < this.debrisSelectionModel.debrisSelectionList.Count; i++)
- {
- ListViewItem listViewItem = new ListViewItem();
- listViewItem.Name = this.debrisSelectionModel.debrisSelectionList[i].itemName;
- listViewItem.SubItems[0].Text = this.debrisSelectionModel.debrisSelectionList[i].itemName;
- this.listView2.Items.Add(listViewItem);
- }
- this.listView2.SelectedItems.Clear();
- }
- }
- /// <summary>
- /// 条件选择的切换事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void listView1_SelectedIndexChanged(object sender, EventArgs e)
- {
- if (this.listView1.SelectedItems != null && this.listView1.SelectedItems.Count == 1)
- {
- switch ((DebrisSelectionParameters)Enum.Parse(typeof(DebrisSelectionParameters), this.listView1.SelectedItems[0].Tag.ToString()))
- {
- case DebrisSelectionParameters.area:
- this.richTextBox1.Text = PdnResources.GetString("Menu.areaofaregionthatit.Text")+"。";
- this.pictureBox1.Image = PdnResources.GetImageResource("Images.CalcArea.png").Reference;
- break;
- case DebrisSelectionParameters.areaRatio:
- this.richTextBox1.Text = PdnResources.GetString("Menu.heratiooftheareaofanentire.Text")+"。";
- this.pictureBox1.Image = null;
- break;
- case DebrisSelectionParameters.perimeter:
- this.richTextBox1.Text = PdnResources.GetString("Menu.Theperimeterregion.Text")+"。";
- this.pictureBox1.Image = null;
- break;
- case DebrisSelectionParameters.longAxis:
- this.richTextBox1.Text = PdnResources.GetString("Menu.ongsideofthesmallestenclosingrect.Text")+"。";
- this.pictureBox1.Image = null;
- break;
- case DebrisSelectionParameters.shortAxis:
- this.richTextBox1.Text = PdnResources.GetString("Menu.rtsideofthesmallestenclosingrectangleofregion.Text")+"。";
- this.pictureBox1.Image = null;
- break;
- case DebrisSelectionParameters.centerX:
- this.richTextBox1.Text = PdnResources.GetString("Menu.atessmallestenclosingrectangleo.Text")+"。";
- this.pictureBox1.Image = null;
- break;
- case DebrisSelectionParameters.centerY:
- this.richTextBox1.Text = PdnResources.GetString("Menu.ordinateYofthecenterpointofthe.Text")+"。";
- this.pictureBox1.Image = null;
- break;
- case DebrisSelectionParameters.inclinationAngle:
- this.richTextBox1.Text = PdnResources.GetString("Menu.reafitstheAngleofthelon.Text")+"。";
- this.pictureBox1.Image = PdnResources.GetImageResource("Images.EllipseAngle.png").Reference;
- break;
- case DebrisSelectionParameters.objectAppearance:
- this.richTextBox1.Text = PdnResources.GetString("Menu.aspectratiooftheenclosingr.Text")+"。";
- this.pictureBox1.Image = null;
- break;
- case DebrisSelectionParameters.height:
- this.richTextBox1.Text = PdnResources.GetString("Menu.heightofanareaadjacenttoarec.Text")+"。";
- this.pictureBox1.Image = null;
- break;
- case DebrisSelectionParameters.width:
- this.richTextBox1.Text = PdnResources.GetString("Menu.thofarectangleurroundingaregio.Text")+"。";
- this.pictureBox1.Image = null;
- break;
- case DebrisSelectionParameters.aspectRatio:
- this.richTextBox1.Text = PdnResources.GetString("Menu.oofwidthtoheightofaregionenclosin.Text")+"。";
- this.pictureBox1.Image = null;
- break;
- case DebrisSelectionParameters.redDensity:
- this.richTextBox1.Text = PdnResources.GetString("Menu.Themaximumgrayvalueofanarear.Text")+"。";
- this.pictureBox1.Image = null;
- break;
- case DebrisSelectionParameters.greenDensity:
- this.richTextBox1.Text = PdnResources.GetString("Menu.ximumgrayvalueofanareagreenhannel.Text")+"。";
- this.pictureBox1.Image = null;
- break;
- case DebrisSelectionParameters.blueDensity:
- this.richTextBox1.Text = PdnResources.GetString("Menu.grayvalueofanareabluechannel.Text")+"。";
- this.pictureBox1.Image = null;
- break;
- /*case DebrisSelectionParameters.maxDensity:
- break;
- case DebrisSelectionParameters.minDensity:
- break;
- case DebrisSelectionParameters.avgDensity:
- break;
- case DebrisSelectionParameters.sumDensity:
- break;*/
- case DebrisSelectionParameters.majorAxis:
- this.richTextBox1.Text = PdnResources.GetString("Menu.Halfofthelongsid.Text")+"。";
- this.pictureBox1.Image = null;
- break;
- case DebrisSelectionParameters.minorAxis:
- this.richTextBox1.Text = PdnResources.GetString("Menu.shortestsideofthesmallestenclosingrectangleofa.Text")+"。";
- this.pictureBox1.Image = null;
- break;
- case DebrisSelectionParameters.circumcircleDiameter:
- this.richTextBox1.Text = PdnResources.GetString("Menu.rofthesmallestcircumscribedcircle.Text")+"。";
- this.pictureBox1.Image = null;
- break;
- case DebrisSelectionParameters.nodularity:
- this.richTextBox1.Text = PdnResources.GetString("Menu.tioftheareaofaregiontotheare.Text")+"。";
- this.pictureBox1.Image = null;
- break;
- case DebrisSelectionParameters.equalCircleDiameter:
- this.richTextBox1.Text = PdnResources.GetString("Menu.diameterofanareawhose.Text")+"。";
- this.pictureBox1.Image = null;
- break;
- case DebrisSelectionParameters.maxCaliperDiameter:
- this.richTextBox1.Text = PdnResources.GetString("Menu.maximudeterminedbasedondistancemea.Text")+"。";
- this.pictureBox1.Image = PdnResources.GetImageResource("Images.FeretMaximum.png").Reference;
- break;
- case DebrisSelectionParameters.minCaliperDiameter:
- this.richTextBox1.Text = PdnResources.GetString("Menu.umcaliperdiameterisd.Text")+"。";
- this.pictureBox1.Image = PdnResources.GetImageResource("Images.FeretMaximum.png").Reference;
- break;
- case DebrisSelectionParameters.avgCaliperDiameter:
- this.richTextBox1.Text = PdnResources.GetString("Menu.rminedbasedodistancmeasuremenandtheminimumva.Text")+"。";
- this.pictureBox1.Image = PdnResources.GetImageResource("Images.FeretMaximum.png").Reference;
- break;
- case DebrisSelectionParameters.maxGray:
- this.richTextBox1.Text = PdnResources.GetString("Menu.Themaximumgrayvalueof.Text")+"。";
- this.pictureBox1.Image = null;
- break;
- case DebrisSelectionParameters.minGray:
- this.richTextBox1.Text = PdnResources.GetString("Menu.Theminimumgrayvalueofanarea.Text")+"。";
- this.pictureBox1.Image = null;
- break;
- case DebrisSelectionParameters.avgGray:
- this.richTextBox1.Text = PdnResources.GetString("Menu.Theaveragegrayvalueofanarea.Text")+"。";
- this.pictureBox1.Image = null;
- break;
- case DebrisSelectionParameters.fiberLength:
- this.richTextBox1.Text = PdnResources.GetString("Menu.Thelengthoafibrousregion.Text")+"。";
- this.pictureBox1.Image = PdnResources.GetImageResource("Images.FibrelengthFormula.png").Reference;
- break;
- case DebrisSelectionParameters.fillArea:
- this.richTextBox1.Text = PdnResources.GetString("Menu.Thelengthoafibrousregion.Text") + "。";
- this.pictureBox1.Image = PdnResources.GetImageResource("Images.FibrelengthFormula.png").Reference;
- break;
- case DebrisSelectionParameters.waistDepth:
- this.richTextBox1.Text = PdnResources.GetString("Menu.Thelengthoafibrousregion.Text") + "。";
- this.pictureBox1.Image = PdnResources.GetImageResource("Images.FibrelengthFormula.png").Reference;
- break;
- case DebrisSelectionParameters.waistDepthShort:
- this.richTextBox1.Text = PdnResources.GetString("Menu.Thelengthoafibrousregion.Text") + "。";
- this.pictureBox1.Image = PdnResources.GetImageResource("Images.FibrelengthFormula.png").Reference;
- break;
- }
- }
- }
-
- /// <summary>
- /// 新建按钮
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button1_Click(object sender, EventArgs e)
- {
- using (DebrisSelectionAddConditionDialog debrisSelectionAddConditionDialog = new DebrisSelectionAddConditionDialog(this, null, -1))
- {
- debrisSelectionAddConditionDialog.StartPosition = FormStartPosition.CenterScreen;
- debrisSelectionAddConditionDialog.ShowDialog();
- }
- }
- /// <summary>
- /// 重命名按钮
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button2_Click(object sender, EventArgs e)
- {
- if (this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count == 1)
- {
- using (DebrisSelectionAddConditionDialog debrisSelectionAddConditionDialog = new DebrisSelectionAddConditionDialog(this,
- this.listView2.SelectedItems[0].Text , this.listView2.SelectedItems[0].Index))
- {
- debrisSelectionAddConditionDialog.StartPosition = FormStartPosition.CenterScreen;
- debrisSelectionAddConditionDialog.ShowDialog();
- }
- }
- else
- MessageBox.Show(PdnResources.GetString("Menu.Pleaseseledfirst.text"));
- }
- /// <summary>
- /// 删除按钮
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button3_Click(object sender, EventArgs e)
- {
- if (this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count == 1)
- {
- DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Areyousurselecteditem.text")+"?", PdnResources.GetString("Menu.alert.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
- if (dr == DialogResult.OK)
- {
- this.debrisSelectionModel.debrisSelectionList.RemoveAt(this.listView2.SelectedItems[0].Index);
- this.listView2.Items.Remove(this.listView2.SelectedItems[0]);
- this.listView2.SelectedItems.Clear();
- this.dataGridView1.Rows.Clear();
- }
- }
- else
- MessageBox.Show(PdnResources.GetString("Menu.Pleaseseeletefirst.text"));
- }
- /// <summary>
- /// 保存按钮
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button4_Click(object sender, EventArgs e)
- {
- string debrisSelectionModelInfo = XmlSerializeHelper.XmlSerialize<DebrisSelectionModel>(this.debrisSelectionModel);
- if (FileOperationHelper.WriteStringToFile(debrisSelectionModelInfo, this.debrisSelectionDialog.filePath, FileMode.Create))
- this.Close();
- else
- MessageBox.Show(PdnResources.GetString("Menu.Savefailed.text"));
- }
- /// <summary>
- /// 刷新当前选中对象的条件model
- /// </summary>
- private void ResetDebrisSelectionModel()
- {
- if(this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count == 1)
- {
- int rowIndex = this.listView2.SelectedItems[0].Index;//选中记录的下标
- //新增
- if(rowIndex == this.debrisSelectionModel.debrisSelectionList.Count)
- {
- DebrisSelectionModel.DebrisSelection debrisSelection = new DebrisSelectionModel.DebrisSelection();
- debrisSelection.itemName = this.listView2.SelectedItems[0].Text;
- debrisSelection.conditionList = new List<DebrisSelectionModel.Condition>();
- for (int i = 0; i < this.dataGridView1.Rows.Count; i++)
- {
- try
- {
- DebrisSelectionModel.Condition condition = new DebrisSelectionModel.Condition();
- condition.conditionName = this.dataGridView1.Rows[i].Cells[0].Tag.ToString();
- condition.judgeCondition = Array.IndexOf(InvariantData.judgeCondition, this.dataGridView1.Rows[i].Cells[1].Value.ToString());
- condition.conditionNum = double.Parse(this.dataGridView1.Rows[i].Cells[2].Value.ToString());
- condition.joinCondition = Array.IndexOf(InvariantData.joinCondition, this.dataGridView1.Rows[i].Cells[3].Value.ToString());
- debrisSelection.conditionList.Add(condition);
- }
- catch (Exception ex)
- {
- continue;
- }
- }
- this.debrisSelectionModel.debrisSelectionList.Add(debrisSelection);
- }
- //编辑
- else if (rowIndex < this.debrisSelectionModel.debrisSelectionList.Count)
- {
- this.debrisSelectionModel.debrisSelectionList[rowIndex].itemName = this.listView2.SelectedItems[0].Text;
- this.debrisSelectionModel.debrisSelectionList[rowIndex].conditionList = new List<DebrisSelectionModel.Condition>();
- for (int i = 0; i < this.dataGridView1.Rows.Count; i++)
- {
- try
- {
- DebrisSelectionModel.Condition condition = new DebrisSelectionModel.Condition();
- condition.conditionName = this.dataGridView1.Rows[i].Cells[0].Tag.ToString();
- condition.judgeCondition = Array.IndexOf(InvariantData.judgeCondition, ((DataGridViewComboBoxCell)(this.dataGridView1.Rows[i].Cells[1])).Value.ToString());
- condition.conditionNum = double.Parse(this.dataGridView1.Rows[i].Cells[2].Value.ToString());
- condition.joinCondition = Array.IndexOf(InvariantData.joinCondition, this.dataGridView1.Rows[i].Cells[3].Value.ToString());
- this.debrisSelectionModel.debrisSelectionList[rowIndex].conditionList.Add(condition);
- }
- catch (Exception ex)
- {
- continue;
- }
- }
- }
- }
- }
- /// <summary>
- /// 添加按钮
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button5_Click(object sender, EventArgs e)
- {
- if(this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count == 1 && this.listView1.SelectedItems != null &&
- this.listView1.SelectedItems.Count == 1)
- {
- DataGridViewRow row = new DataGridViewRow();
- row.Height = 25;
- row.Cells.Add(CreateTextBoxCell(this.listView1.SelectedItems[0].Text, this.listView1.SelectedItems[0].Tag));
- row.Cells.Add(CreateComboBoxCell(InvariantData.judgeCondition, ""));
- row.Cells.Add(CreateTextBoxCell("0", ""));
- row.Cells.Add(CreateComboBoxCell(InvariantData.joinCondition, ""));
- this.dataGridView1.Rows.Add(row);
- this.dataGridView1.ClearSelection();
- this.dataGridView1.Rows[this.dataGridView1.Rows.Count - 1].Selected = true;
- ResetDebrisSelectionModel();
- }
- }
- /// <summary>
- /// 移出按钮
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button6_Click(object sender, EventArgs e)
- {
- if (this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count == 1)
- {
- if(this.dataGridView1.SelectedRows.Count>0)
- {
- this.dataGridView1.Rows.Remove(this.dataGridView1.SelectedRows[0]);
- this.dataGridView1.ClearSelection();
- ResetDebrisSelectionModel();
- }
- }
- }
- /// <summary>
- /// 向上移动
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button7_Click(object sender, EventArgs e)
- {
- if (this.dataGridView1.Rows.Count < 1)
- return;
- if (this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count == 1
- && this.dataGridView1.SelectedRows.Count>0)
- {
- int rowIndex = this.dataGridView1.SelectedRows[0].Index;
- if(rowIndex > 0)
- {
- this.dataGridView1.Rows.Insert(rowIndex - 1, CopyDataGridViewRow(this.dataGridView1.SelectedRows[0]));
- this.dataGridView1.Rows.RemoveAt(rowIndex + 1);
- this.dataGridView1.ClearSelection();
- this.dataGridView1.Rows[rowIndex - 1].Selected = true;
- ResetDebrisSelectionModel();
- }
- }
- }
- /// <summary>
- /// 向下移动
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button8_Click(object sender, EventArgs e)
- {
- if (this.dataGridView1.Rows.Count < 1)
- return;
- if (this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count == 1
- && this.dataGridView1.SelectedRows.Count>0)
- {
- int rowIndex = this.dataGridView1.SelectedRows[0].Index;
- if(rowIndex < this.dataGridView1.Rows.Count - 1)
- {
- this.dataGridView1.Rows.Insert(rowIndex + 2, CopyDataGridViewRow(this.dataGridView1.SelectedRows[0]));
- this.dataGridView1.Rows.RemoveAt(rowIndex);
- this.dataGridView1.ClearSelection();
- this.dataGridView1.Rows[rowIndex + 1].Selected = true;
- ResetDebrisSelectionModel();
- }
- }
- }
- /// <summary>
- /// 拷贝表格内的选中行
- /// </summary>
- /// <param name="selectedRow"></param>
- /// <returns></returns>
- private DataGridViewRow CopyDataGridViewRow(DataGridViewRow selectedRow)
- {
- DataGridViewRow row = new DataGridViewRow();
- row.Height = 25;
- DataGridViewTextBoxCell cell1 = (DataGridViewTextBoxCell)selectedRow.Cells[0];
- DataGridViewComboBoxCell cell2 = (DataGridViewComboBoxCell)selectedRow.Cells[1];
- DataGridViewTextBoxCell cell3 = (DataGridViewTextBoxCell)selectedRow.Cells[2];
- DataGridViewComboBoxCell cell4 = (DataGridViewComboBoxCell)selectedRow.Cells[3];
- row.Cells.Add(CreateTextBoxCell(cell1.Value.ToString(), cell1.Tag));
- row.Cells.Add(CreateComboBoxCell(InvariantData.judgeCondition, cell2.Tag));
- row.Cells.Add(CreateTextBoxCell(cell3.Value.ToString(), cell3.Tag));
- row.Cells.Add(CreateComboBoxCell(InvariantData.joinCondition, cell4.Tag));
- row.Cells[1].Value = cell2.Value.ToString();
- row.Cells[3].Value = cell4.Value.ToString();
- return row;
- }
- /// <summary>
- /// 向已经添加列表添加新项目
- /// </summary>
- /// <param name="itemName"></param>
- /// <param name="editStatus"></param>
- /// <param name="editIndex"></param>
- public void AddContentToListview(string itemName, bool editStatus, int editIndex)
- {
- //编辑
- if (editStatus)
- {
- if(editIndex > -1)
- {
- this.listView2.Items[editIndex].Name = itemName;
- this.listView2.Items[editIndex].Text = itemName;
- this.listView2.SelectedItems.Clear();
- this.listView2.Items[editIndex].Selected = true;
- this.debrisSelectionModel.debrisSelectionList[editIndex].itemName = itemName;
- }
- }
- //新增
- else
- {
- ListViewItem listViewItem = new ListViewItem();
- listViewItem.Name = itemName;
- listViewItem.SubItems[0].Text = itemName;
- this.listView2.Items.Add(listViewItem);
- this.listView2.SelectedItems.Clear();
- DebrisSelectionModel.DebrisSelection debrisSelection = new DebrisSelectionModel.DebrisSelection();
- debrisSelection.itemName = itemName;
- debrisSelection.conditionList = new List<DebrisSelectionModel.Condition>();
- this.debrisSelectionModel.debrisSelectionList.Add(debrisSelection);
- }
- }
- /// <summary>
- /// 添加内容单元格
- /// </summary>
- /// <param name="text"></param>
- /// <param name="tag"></param>
- /// <returns></returns>
- private DataGridViewTextBoxCell CreateTextBoxCell(string text, object tag)
- {
- DataGridViewTextBoxCell textboxcell = new DataGridViewTextBoxCell();
- textboxcell.Value = text;
- textboxcell.Tag = tag;
- return textboxcell;
- }
- /// <summary>
- /// 添加下拉框单元格
- /// </summary>
- /// <returns></returns>
- private DataGridViewComboBoxCell CreateComboBoxCell(string[] strArr, object tag)
- {
- DataGridViewComboBoxCell comboboxCell = new DataGridViewComboBoxCell();
- comboboxCell.DataSource = strArr;
- comboboxCell.Tag = tag;
- comboboxCell.Value = strArr[0];
- comboboxCell.DisplayStyle = DataGridViewComboBoxDisplayStyle.ComboBox;
- return comboboxCell;
- }
- /// <summary>
- /// 切换已添加list的选中
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void listView2_SelectedIndexChanged(object sender, EventArgs e)
- {
- this.dataGridView1.Rows.Clear();
- if (this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count == 1)
- {
- if (this.debrisSelectionModel != null && this.debrisSelectionModel.debrisSelectionList.Count > 0)
- {
- DebrisSelectionModel.DebrisSelection model = this.debrisSelectionModel.debrisSelectionList.Find(a => a.itemName.Equals(this.listView2.SelectedItems[0].Text));
- if(model != null && model.conditionList.Count > 0)
- {
- for(int i = 0; i < model.conditionList.Count; i++)
- {
- DataGridViewRow row = new DataGridViewRow();
- row.Height = 25;
- DebrisSelectionParameters parameter = (DebrisSelectionParameters)Enum.Parse(typeof(DebrisSelectionParameters), model.conditionList[i].conditionName);
- object paraName = new object();
- InvariantData.debrisSelectionparameters.TryGetValue(parameter, out paraName);
- row.Cells.Add(CreateTextBoxCell(paraName.ToString(), model.conditionList[i].conditionName));
- row.Cells.Add(CreateComboBoxCell(InvariantData.judgeCondition, ""));
- row.Cells.Add(CreateTextBoxCell(model.conditionList[i].conditionNum.ToString(), ""));
- row.Cells.Add(CreateComboBoxCell(InvariantData.joinCondition, ""));
- row.Cells[1].Value = InvariantData.judgeCondition[model.conditionList[i].judgeCondition];
- row.Cells[3].Value = InvariantData.joinCondition[model.conditionList[i].joinCondition];
- this.dataGridView1.Rows.Add(row);
- }
- this.dataGridView1.ClearSelection();
- }
- }
- }
- }
- /// <summary>
- /// 窗体关闭
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void DebrisSelectionValidConditionDialog_FormClosed(object sender, FormClosedEventArgs e)
- {
- this.debrisSelectionDialog.ReloadDebrisSelectionFromXml();
- this.debrisSelectionDialog.RefreshDebrisComboBox();
- }
- /// <summary>
- /// 动态修改条件的model
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dataGridView1_CurrentCellDirtyStateChanged(object sender, EventArgs e)
- {
- if (this.dataGridView1.IsCurrentCellDirty)
- {
- this.dataGridView1.CommitEdit(DataGridViewDataErrorContexts.Commit);
- DebrisSelectionModel.DebrisSelection model = this.debrisSelectionModel.debrisSelectionList.Find(a => a.itemName.Equals(this.listView2.SelectedItems[0].Text));
- //循环处理this.debrisSelectionModel
- for (int i = 0; i < this.dataGridView1.Rows.Count; i++)
- {
- double v;
- if (((DataGridViewTextBoxCell)this.dataGridView1.Rows[i].Cells[2]).Value != null && double.TryParse(((DataGridViewTextBoxCell)this.dataGridView1.Rows[i].Cells[2]).Value.ToString(), out v))
- {
- //this.debrisSelectionModel.debrisSelectionList[this.comboBox3.SelectedIndex].conditionList[i].conditionNum = v;// double.Parse(((DataGridViewTextBoxCell)this.dataGridView3.Rows[i].Cells[2]).Value.ToString());
- }
- else
- {
- ((DataGridViewTextBoxCell)this.dataGridView1.Rows[i].Cells[2]).Value = model.conditionList[i].conditionNum;
- }
- }
- ResetDebrisSelectionModel();
- }
- }
- private void listView1_MouseDoubleClick(object sender, MouseEventArgs e)
- {
- ListViewHitTestInfo info = this.listView1.HitTest(e.X, e.Y);
- if (info.Item != null)
- {
- this.button5.PerformClick();
- }
- }
- }
- }
|