Browse Source

颗粒列表添加 将颗粒添加到选择颗粒列表 和 在选择颗粒列表中去除颗粒 功能

cxs 1 year ago
parent
commit
a73b52c469

+ 5 - 11
OTSIncAReportApp/1-UI/Control_Graph/Controls/Control_DrawDistrbutionImageAndBSE.cs

@@ -362,18 +362,12 @@ namespace OTSIncAReportGraph.Controls
                 this.control_Ruler1.SetValue(m_f_ruler_size);
                 this.control_Ruler1.ShowString = Convert.ToInt32(100).ToString() + "μm";
             }
-           
-
-
-
             ProgressBarUpdate(100, table["str2"].ToString());
-
-
-
             m_frm_userprogress.Visible = false;
-          
-
-
+            if (m_ReportApp.im_ParticlesGridDevidePage != null)
+            {
+                m_ReportApp.im_ParticlesGridDevidePage.ToolStripMenuItem_Addparticlestotheselectparticleslist.Visible = true; //由于分布图和颗粒表数据来源相对独立,所以只能在这里激活颗粒表选择菜单,待日后修改数据源加载方式,此项需修改
+            }
         }
   
 
@@ -1234,7 +1228,7 @@ namespace OTSIncAReportGraph.Controls
                 }
             }
             SendSelectParticleListToReportFrame(selectedParts);
-        }
+        }   
 
         /// <summary>
         /// 显示x-ray能谱图

+ 1 - 1
OTSIncAReportApp/1-UI/Control_Graph/Controls/Control_DrawDistrbutionImageAndBSE.designer.cs

@@ -215,7 +215,6 @@
         #endregion
 
         private Control_XRayTable control_XRayTable1;
-        private System.Windows.Forms.ContextMenuStrip CMenuStrip;
         private System.Windows.Forms.ToolStripMenuItem ToolStripMenuItem_movesempoint;
         private Control_Ruler control_Ruler1;
         private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem_copyimage;
@@ -234,5 +233,6 @@
         private System.Windows.Forms.ToolStripMenuItem aSTMToolStripMenuItem;
         private System.Windows.Forms.ToolStripMenuItem 显示所有帧ToolStripMenuItem;
         private System.Windows.Forms.ToolStripMenuItem ToolStripMenuItem_ParticleSplicing;
+        public System.Windows.Forms.ContextMenuStrip CMenuStrip;
     }
 }

+ 36 - 14
OTSIncAReportApp/1-UI/Control_Grids/ParticlesGridDevidePage/ParticlesGridDevidePage.Designer.cs

@@ -72,6 +72,8 @@
             this.testToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
             this.EXCELToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
             this.ToolStripMenuItemDelete_Particle = new System.Windows.Forms.ToolStripMenuItem();
+            this.ToolStripMenuItem_Addparticlestotheselectparticleslist = new System.Windows.Forms.ToolStripMenuItem();
+            this.ToolStripMenuItem_Removeparticlesfromtheselectparticleslist = new System.Windows.Forms.ToolStripMenuItem();
             this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
             this.dgV_ParticlesDevidePage = new System.Windows.Forms.DataGridView();
             this.panel2.SuspendLayout();
@@ -317,7 +319,7 @@
             // lblTotalCount
             // 
             this.lblTotalCount.AutoSize = true;
-            this.lblTotalCount.Location = new System.Drawing.Point(36, 13);
+            this.lblTotalCount.Location = new System.Drawing.Point(24, 13);
             this.lblTotalCount.Name = "lblTotalCount";
             this.lblTotalCount.Size = new System.Drawing.Size(17, 12);
             this.lblTotalCount.TabIndex = 34;
@@ -414,61 +416,63 @@
             this.ToolStripMenuItem_exportimagefile,
             this.testToolStripMenuItem,
             this.EXCELToolStripMenuItem,
-            this.ToolStripMenuItemDelete_Particle});
+            this.ToolStripMenuItemDelete_Particle,
+            this.ToolStripMenuItem_Addparticlestotheselectparticleslist,
+            this.ToolStripMenuItem_Removeparticlesfromtheselectparticleslist});
             this.contextMenuStrip1.Name = "contextMenuStrip1";
-            this.contextMenuStrip1.Size = new System.Drawing.Size(211, 230);
+            this.contextMenuStrip1.Size = new System.Drawing.Size(221, 252);
             // 
             // ToolStripMenuItem1
             // 
             this.ToolStripMenuItem1.Name = "ToolStripMenuItem1";
-            this.ToolStripMenuItem1.Size = new System.Drawing.Size(210, 22);
+            this.ToolStripMenuItem1.Size = new System.Drawing.Size(220, 22);
             this.ToolStripMenuItem1.Text = "复制整个表";
             this.ToolStripMenuItem1.Click += new System.EventHandler(this.ToolStripMenuItem1_Click);
             // 
             // ToolStripMenuItem2
             // 
             this.ToolStripMenuItem2.Name = "ToolStripMenuItem2";
-            this.ToolStripMenuItem2.Size = new System.Drawing.Size(210, 22);
+            this.ToolStripMenuItem2.Size = new System.Drawing.Size(220, 22);
             this.ToolStripMenuItem2.Text = "复制选择区域";
             this.ToolStripMenuItem2.Click += new System.EventHandler(this.ToolStripMenuItem2_Click);
             // 
             // toolStripMenuItem4
             // 
             this.toolStripMenuItem4.Name = "toolStripMenuItem4";
-            this.toolStripMenuItem4.Size = new System.Drawing.Size(210, 22);
+            this.toolStripMenuItem4.Size = new System.Drawing.Size(220, 22);
             this.toolStripMenuItem4.Text = "复制图像";
             this.toolStripMenuItem4.Click += new System.EventHandler(this.toolStripMenuItem4_Click);
             // 
             // toolStripSeparator1
             // 
             this.toolStripSeparator1.Name = "toolStripSeparator1";
-            this.toolStripSeparator1.Size = new System.Drawing.Size(207, 6);
+            this.toolStripSeparator1.Size = new System.Drawing.Size(217, 6);
             // 
             // ToolStripMenuItem3
             // 
             this.ToolStripMenuItem3.Name = "ToolStripMenuItem3";
-            this.ToolStripMenuItem3.Size = new System.Drawing.Size(210, 22);
+            this.ToolStripMenuItem3.Size = new System.Drawing.Size(220, 22);
             this.ToolStripMenuItem3.Text = "恢复至初始状态";
             this.ToolStripMenuItem3.Click += new System.EventHandler(this.ToolStripMenuItem3_Click);
             // 
             // ToolStripMenuItem5
             // 
             this.ToolStripMenuItem5.Name = "ToolStripMenuItem5";
-            this.ToolStripMenuItem5.Size = new System.Drawing.Size(210, 22);
+            this.ToolStripMenuItem5.Size = new System.Drawing.Size(220, 22);
             this.ToolStripMenuItem5.Text = "移动SEM到颗粒视域位置";
             this.ToolStripMenuItem5.Click += new System.EventHandler(this.ToolStripMenuItem5_Click);
             // 
             // ToolStripMenuItem_exportimagefile
             // 
             this.ToolStripMenuItem_exportimagefile.Name = "ToolStripMenuItem_exportimagefile";
-            this.ToolStripMenuItem_exportimagefile.Size = new System.Drawing.Size(210, 22);
+            this.ToolStripMenuItem_exportimagefile.Size = new System.Drawing.Size(220, 22);
             this.ToolStripMenuItem_exportimagefile.Text = "导出图像文件";
             this.ToolStripMenuItem_exportimagefile.Click += new System.EventHandler(this.ToolStripMenuItem_exportimagefile_Click);
             // 
             // testToolStripMenuItem
             // 
             this.testToolStripMenuItem.Name = "testToolStripMenuItem";
-            this.testToolStripMenuItem.Size = new System.Drawing.Size(210, 22);
+            this.testToolStripMenuItem.Size = new System.Drawing.Size(220, 22);
             this.testToolStripMenuItem.Text = "显示能谱数据";
             this.testToolStripMenuItem.Visible = false;
             this.testToolStripMenuItem.Click += new System.EventHandler(this.testToolStripMenuItem_Click);
@@ -476,17 +480,33 @@
             // EXCELToolStripMenuItem
             // 
             this.EXCELToolStripMenuItem.Name = "EXCELToolStripMenuItem";
-            this.EXCELToolStripMenuItem.Size = new System.Drawing.Size(210, 22);
+            this.EXCELToolStripMenuItem.Size = new System.Drawing.Size(220, 22);
             this.EXCELToolStripMenuItem.Text = "导出EXCEL";
             this.EXCELToolStripMenuItem.Click += new System.EventHandler(this.EXCELToolStripMenuItem_Click);
             // 
             // ToolStripMenuItemDelete_Particle
             // 
             this.ToolStripMenuItemDelete_Particle.Name = "ToolStripMenuItemDelete_Particle";
-            this.ToolStripMenuItemDelete_Particle.Size = new System.Drawing.Size(210, 22);
+            this.ToolStripMenuItemDelete_Particle.Size = new System.Drawing.Size(220, 22);
             this.ToolStripMenuItemDelete_Particle.Text = "删除颗粒";
             this.ToolStripMenuItemDelete_Particle.Click += new System.EventHandler(this.ToolStripMenuItem_Delete_Particle_Click);
             // 
+            // ToolStripMenuItem_Addparticlestotheselectparticleslist
+            // 
+            this.ToolStripMenuItem_Addparticlestotheselectparticleslist.Name = "ToolStripMenuItem_Addparticlestotheselectparticleslist";
+            this.ToolStripMenuItem_Addparticlestotheselectparticleslist.Size = new System.Drawing.Size(220, 22);
+            this.ToolStripMenuItem_Addparticlestotheselectparticleslist.Text = "将颗粒添加到选择颗粒列表";
+            this.ToolStripMenuItem_Addparticlestotheselectparticleslist.Visible = false;
+            this.ToolStripMenuItem_Addparticlestotheselectparticleslist.Click += new System.EventHandler(this.ToolStripMenuItem_Addparticlestotheselectparticleslist_Click);
+            // 
+            // ToolStripMenuItem_Removeparticlesfromtheselectparticleslist
+            // 
+            this.ToolStripMenuItem_Removeparticlesfromtheselectparticleslist.Name = "ToolStripMenuItem_Removeparticlesfromtheselectparticleslist";
+            this.ToolStripMenuItem_Removeparticlesfromtheselectparticleslist.Size = new System.Drawing.Size(220, 22);
+            this.ToolStripMenuItem_Removeparticlesfromtheselectparticleslist.Text = "在选择颗粒列表中去除颗粒";
+            this.ToolStripMenuItem_Removeparticlesfromtheselectparticleslist.Visible = false;
+            this.ToolStripMenuItem_Removeparticlesfromtheselectparticleslist.Click += new System.EventHandler(this.ToolStripMenuItem_Removeparticlesfromtheselectparticleslist_Click);
+            // 
             // tableLayoutPanel1
             // 
             this.tableLayoutPanel1.ColumnCount = 1;
@@ -545,7 +565,6 @@
         #endregion
         private System.Windows.Forms.Panel panel2;
         private System.Windows.Forms.Panel panel1;
-        private System.Windows.Forms.ContextMenuStrip contextMenuStrip1;
         private System.Windows.Forms.ToolStripMenuItem ToolStripMenuItem1;
         private System.Windows.Forms.ToolStripMenuItem ToolStripMenuItem2;
         private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem4;
@@ -588,5 +607,8 @@
         private System.Windows.Forms.TextBox tB_ParticleId;
         private System.Windows.Forms.Label label3;
         private System.Windows.Forms.Button btn_showconfig;
+        private System.Windows.Forms.ToolStripMenuItem ToolStripMenuItem_Removeparticlesfromtheselectparticleslist;
+        public System.Windows.Forms.ContextMenuStrip contextMenuStrip1;
+        public System.Windows.Forms.ToolStripMenuItem ToolStripMenuItem_Addparticlestotheselectparticleslist;
     }
 }

+ 72 - 81
OTSIncAReportApp/1-UI/Control_Grids/ParticlesGridDevidePage/ParticlesGridDevidePage.cs

@@ -253,7 +253,10 @@ namespace OTSIncAReportGrids
             cbB_PageSize.Items.Add("5000");
             cbB_PageSize.Items.Add("All");
             cbB_PageSize.SelectedIndex = 0;
-
+            if (m_ReportApp.im_Control_DrawDistrbutionImageAndBSE != null)
+            {
+                ToolStripMenuItem_Addparticlestotheselectparticleslist.Visible = true;
+            }
         }
 
         #region 自定义方法
@@ -332,6 +335,7 @@ namespace OTSIncAReportGrids
                 particlesAll = new DataTable();
                 particlesAll = dtUelect.Copy();
                 btn_Sel.Enabled = false;
+                ToolStripMenuItem_Removeparticlesfromtheselectparticleslist.Visible = true;
             }
             else
             {
@@ -394,6 +398,7 @@ namespace OTSIncAReportGrids
                 }
 
                 btn_Sel.Enabled = true;
+                ToolStripMenuItem_Removeparticlesfromtheselectparticleslist.Visible = false;
             }
             if (particlesAll == null)
             {
@@ -1268,43 +1273,6 @@ namespace OTSIncAReportGrids
 
         }
 
-        private void ToolStripMenuItem_selectparticle_Click(object sender, EventArgs e)
-        {
-            string path = result.FilePath;
-            ParticleData fielddata = new ParticleData(result.FilePath);
-            List<Particle> particles = fielddata.GetParticleAllList();
-
-            List<Particle> ls_list_cotsparticleclr = new List<Particle>();
-            for (int l = 0; l < dgV_ParticlesDevidePage.SelectedRows.Count; l++)
-            {
-                //从事先加载的Bitmap对象的Tag中取出List<string>
-                DataGridViewRow dgvr = dgV_ParticlesDevidePage.SelectedRows[l];
-                Bitmap ls_bp = (Bitmap)dgvr.Cells[2].Value;
-                List<string> list_str = (List<string>)ls_bp.Tag;
-                if (list_str != null)
-                {
-                    int i_ls_fieldid = Convert.ToInt32(list_str[0]);
-                    int i_ls_particleid = Convert.ToInt32(list_str[1]);
-                    foreach (Particle item in particles)
-                    {
-                        if (i_ls_fieldid == item.FieldId && i_ls_particleid == item.ParticleId)
-                        {
-                            ls_list_cotsparticleclr.Add(item);
-                            break;
-                        }
-                    }
-
-                }
-            }
-            m_ReportApp.SetSelectedParticles(ls_list_cotsparticleclr);
-            string str1 = table["str1"].ToString();
-            //然后循环得出,list cotsparticleclr列表,返回给框架
-            //m_sec.SendCall(str1, "", "", ls_list_cotsparticleclr);
-            string str2 = table["str2"].ToString();
-            string str3 = table["str3"].ToString();
-            MessageBox.Show(str2 + ls_list_cotsparticleclr.Count.ToString() + str3);
-        }
-
         private void ToolStripMenuItem_exportimagefile_Click(object sender, EventArgs e)
         {
             FolderBrowserDialog fbd = new FolderBrowserDialog();
@@ -2432,49 +2400,6 @@ namespace OTSIncAReportGrids
             GC.WaitForPendingFinalizers();
         }
 
-        private void ImportSTDDb_Click(object sender, EventArgs e)
-        {
-            //Dictionary<string, object> sampleMembers = ((Dictionary<string, object>)((Dictionary<string, object>)resultFile.ResultInfo["Sample"])["Members"]);
-            string STDName = resultFile.GetSTDName();
-            string ResultDbPath = resultFile.GetResultDBPath();
-            if (STDName.ToLower().Split('.')[0] == "nostddb")
-            {
-                OpenFileDialog openFileDialog = new OpenFileDialog();
-                openFileDialog.Filter = "(*.db)|*.db";
-                openFileDialog.RestoreDirectory = true;
-                openFileDialog.FilterIndex = 1;
-                openFileDialog.Title = "Please choose a STD to add the rule!";
-                if (openFileDialog.ShowDialog() == DialogResult.OK)
-                {
-                    try
-                    {
-                        string arguments = openFileDialog.FileName;
-                        var SelectRows = dgV_ParticlesDevidePage.SelectedRows;
-                        DataGridViewRow dgvr = SelectRows[0];
-                        Bitmap ls_bp = (Bitmap)dgvr.Cells[2].Value;
-                        List<string> list_str = (List<string>)ls_bp.Tag;
-                        arguments += " " + ResultDbPath + " " + list_str[0].ToString() + " " + list_str[1].ToString() + " " + list_str[3].ToString();
-                        System.Diagnostics.Process p = System.Diagnostics.Process.Start(".\\OTSPartA_STDEditor.exe", arguments);
-                        p.WaitForExit();
-                    }
-                    catch (Exception ex)
-                    {
-                        log.Error("OTSPartA_STDEditor:" + ex.ToString());
-                    }
-                }
-            }
-            else
-            {
-                string arguments = ".\\Config\\SysData\\" + STDName.Split('.')[0] + ".db";
-                var selectRow = dgV_ParticlesDevidePage.SelectedRows[0];
-                Bitmap ls_bp = (Bitmap)selectRow.Cells[2].Value;
-                List<string> list_str = (List<string>)ls_bp.Tag;
-                arguments += " " + ResultDbPath + " " + list_str[0].ToString() + " " + list_str[1].ToString() + " " + list_str[3].ToString();
-                System.Diagnostics.Process p = System.Diagnostics.Process.Start(".\\OTSPartA_STDEditor.exe", arguments);
-                p.WaitForExit();
-            }
-        }
-
         private void dgV_ParticlesDevidePage_MouseDown(object sender, MouseEventArgs e)
         {
 
@@ -2551,6 +2476,72 @@ namespace OTSIncAReportGrids
                 SetDataGridViewStyle();
             }
         }
+
+        private void ToolStripMenuItem_Addparticlestotheselectparticleslist_Click(object sender, EventArgs e)
+        {
+            string path = result.FilePath;
+            ParticleData fielddata = new ParticleData(result.FilePath);
+            List<Particle> particles = fielddata.GetParticleAllList();
+
+            List<Particle> ls_list_cotsparticleclr = new List<Particle>();
+            for (int l = 0; l < dgV_ParticlesDevidePage.SelectedRows.Count; l++)
+            {
+                //从事先加载的Bitmap对象的Tag中取出List<string>
+                DataGridViewRow dgvr = dgV_ParticlesDevidePage.SelectedRows[l];
+                Bitmap ls_bp = (Bitmap)dgvr.Cells[2].Value;
+                List<string> list_str = (List<string>)ls_bp.Tag;
+                if (list_str != null)
+                {
+                    int i_ls_fieldid = Convert.ToInt32(list_str[0]);
+                    int i_ls_particleid = Convert.ToInt32(list_str[1]);
+                    foreach (Particle item in particles)
+                    {
+                        if (i_ls_fieldid == item.FieldId && i_ls_particleid == item.ParticleId)
+                        {
+                            ls_list_cotsparticleclr.Add(item);
+                            break;
+                        }
+                    }
+
+                }
+            }
+            m_ReportApp.AddParticlesToSelectedParticles(ls_list_cotsparticleclr);
+        }
+
+        private void ToolStripMenuItem_Removeparticlesfromtheselectparticleslist_Click(object sender, EventArgs e)
+        {
+            string path = result.FilePath;
+            ParticleData fielddata = new ParticleData(result.FilePath);
+            List<Particle> particles = fielddata.GetParticleAllList();
+
+            List<Particle> ls_list_cotsparticleclr = new List<Particle>();
+            for (int l = 0; l < dgV_ParticlesDevidePage.SelectedRows.Count; l++)
+            {
+                //从事先加载的Bitmap对象的Tag中取出List<string>
+                DataGridViewRow dgvr = dgV_ParticlesDevidePage.SelectedRows[l];
+                Bitmap ls_bp = (Bitmap)dgvr.Cells[2].Value;
+                List<string> list_str = (List<string>)ls_bp.Tag;
+                if (list_str != null)
+                {
+                    int i_ls_fieldid = Convert.ToInt32(list_str[0]);
+                    int i_ls_particleid = Convert.ToInt32(list_str[1]);
+                    foreach (Particle item in particles)
+                    {
+                        if (i_ls_fieldid == item.FieldId && i_ls_particleid == item.ParticleId)
+                        {
+                            ls_list_cotsparticleclr.Add(item);
+                            break;
+                        }
+                    }
+
+                }
+            }
+            m_ReportApp.DeleteParticlesFromSelectedParticles(ls_list_cotsparticleclr);
+            foreach (DataGridViewRow Row in dgV_ParticlesDevidePage.SelectedRows)
+            {
+                dgV_ParticlesDevidePage.Rows.Remove(Row);
+            }
+        }
     }
 }
 

+ 27 - 5
OTSIncAReportApp/1-UI/frmReportApp.cs

@@ -191,7 +191,7 @@ namespace OTSIncAReportApp
                 dp.IsSelect = false;
             }
         }
-        public void SetSelectedParticles(List<Particle> value)
+        public void AddParticlesToSelectedParticles(List<Particle> value)
         {
             foreach (var p in im_Control_DrawDistrbutionImageAndBSE.m_list_allDPart)
             {
@@ -202,20 +202,42 @@ namespace OTSIncAReportApp
                     {
                         if (dp.objParticleData.ParticleId == p2.ParticleId)
                         {
-                            dp.IsSelect = true;
+                            if (!selectedParticles.ContainsKey(dp.guid))
+                            {
+                                dp.IsSelect = true;
+                                selectedParticles.Add(dp.guid, dp);
+                                break;
+                            }
+                        }
+                    }
+                }
+            }
+        }
+
+        public void DeleteParticlesFromSelectedParticles(List<Particle> value)
+        {
+            foreach (var p2 in value)
+            {
+                foreach (var p in selectedParticles.Values)
+                {
+                    if (p.objParticleData.FieldId == p2.FieldId)
+                    {
+                        if (p.objParticleData.ParticleId == p2.ParticleId)
+                        {
+                            p.IsSelect = false;
+                            selectedParticles.Remove(p.guid);
+                            break;
                         }
                     }
                 }
-              
             }
-           
         }
 
         #endregion //--------------------------------------------------------------------------------------------
 
 
         #region 窗体初始化及构造函数
-        
+
         /// <summary>
         /// 窗体构造函数
         /// </summary>