Browse Source

Optimize related to merging particles

cxs 1 month ago
parent
commit
f834bb0005

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

@@ -1912,7 +1912,7 @@ namespace OTSIncAReportGraph.Controls
                     {
                     {
                         if (p.IsSelect)
                         if (p.IsSelect)
                         {
                         {
-                            DeleteParticlesFromLibrary(p.objParticleData.ParticleId, p.objParticleData.FieldId);
+                            DeleteParticlesFromSTDDb(p.objParticleData.ParticleId, p.objParticleData.FieldId);
 
 
                             p.IsDeleted = true;
                             p.IsDeleted = true;
                         }
                         }
@@ -1953,7 +1953,7 @@ namespace OTSIncAReportGraph.Controls
             Invalidate();
             Invalidate();
         }
         }
 
 
-        public bool DeleteParticlesFromLibrary(int in_clr_tagid, int in_clr_fieldid)
+        public bool DeleteParticlesFromSTDDb(int in_clr_tagid, int in_clr_fieldid)
         {
         {
             bool DoesItExist = false;
             bool DoesItExist = false;
             for (int i = 1; i < 201; i++)
             for (int i = 1; i < 201; i++)
@@ -2246,7 +2246,7 @@ namespace OTSIncAReportGraph.Controls
                         {
                         {
                             if (p.IsSelect)
                             if (p.IsSelect)
                             {
                             {
-                                if (!DeleteParticlesFromLibrary(p.objParticleData.ParticleId, p.objParticleData.FieldId))
+                                if (!DeleteParticlesFromSTDDb(p.objParticleData.ParticleId, p.objParticleData.FieldId))
                                 {
                                 {
                                     deleteflag = false;
                                     deleteflag = false;
                                 }
                                 }

+ 28 - 27
OTSIncAReportApp/1-UI/Control_Graph/OTSIncAReportGraphFuncation/OTSImageDisHelp.cs

@@ -9,8 +9,7 @@ using OTSModelSharp.ServiceCenter;
 using System;
 using System;
 
 
 using System.Collections.Generic;
 using System.Collections.Generic;
-
-
+using System.Data;
 using System.Drawing;
 using System.Drawing;
 using System.Drawing.Drawing2D;
 using System.Drawing.Drawing2D;
 using System.IO;
 using System.IO;
@@ -158,19 +157,9 @@ namespace OTSIncAReportGraph.OTSIncAReportGraphFuncation
 
 
             return curP;
             return curP;
         }
         }
-
-       
-      
         public SizeF GetPhysicalFieldWidthAndHeight()
         public SizeF GetPhysicalFieldWidthAndHeight()
         {
         {
-
-
-
             SizeF ret_rect = new SizeF(0, 0);
             SizeF ret_rect = new SizeF(0, 0);
-
-     
-
-
             int width = resultFile.GetImageWidth();
             int width = resultFile.GetImageWidth();
             int height = resultFile.GetImageHeight();
             int height = resultFile.GetImageHeight();
             double retioOfHeightWidth =(double) height;
             double retioOfHeightWidth =(double) height;
@@ -180,26 +169,18 @@ namespace OTSIncAReportGraph.OTSIncAReportGraphFuncation
             double d_scanFieldSize_height = 0;
             double d_scanFieldSize_height = 0;
             if (d_scanFieldSize_width != 0)
             if (d_scanFieldSize_width != 0)
                 d_scanFieldSize_height = d_scanFieldSize_width * retioOfHeightWidth;
                 d_scanFieldSize_height = d_scanFieldSize_width * retioOfHeightWidth;
-
                 ret_rect.Width = (int)d_scanFieldSize_width;
                 ret_rect.Width = (int)d_scanFieldSize_width;
                 ret_rect.Height = (int)d_scanFieldSize_height;
                 ret_rect.Height = (int)d_scanFieldSize_height;
-           
             return ret_rect;
             return ret_rect;
         }
         }
+
         public SizeF GetFieldImageSize()
         public SizeF GetFieldImageSize()
         {
         {
-
-
-
             SizeF s = new SizeF();
             SizeF s = new SizeF();
-
-
-
-          
             int width = resultFile.GetImageWidth();
             int width = resultFile.GetImageWidth();
             int height = resultFile.GetImageHeight();
             int height = resultFile.GetImageHeight();
             s.Width = width;
             s.Width = width;
-           s.Height = height;
+            s.Height = height;
             return s;
             return s;
         }
         }
 
 
@@ -268,7 +249,7 @@ namespace OTSIncAReportGraph.OTSIncAReportGraphFuncation
         /// <param name="in_clr_fieldid"></param>
         /// <param name="in_clr_fieldid"></param>
         /// <param name="Search_xray"></param>
         /// <param name="Search_xray"></param>
         /// <param name="Analysis_xray"></param>
         /// <param name="Analysis_xray"></param>
-        public void GetXrayByParticleTagIDAndFieldID_ForDrawDistrbutionImageAndBSE(int in_clr_tagid, int in_clr_fieldid, out uint[] Search_xray, out uint[] Analysis_xray, out int xray_id, out List<Element> list_celementchemistryclr)
+        public Particle GetXrayByParticleTagIDAndFieldID_ForDrawDistrbutionImageAndBSE(int in_clr_tagid, int in_clr_fieldid, out uint[] Search_xray, out uint[] Analysis_xray, out int xray_id, out List<Element> list_celementchemistryclr)
         {
         {
             Search_xray = new uint[2000];
             Search_xray = new uint[2000];
             Analysis_xray = new uint[2000];
             Analysis_xray = new uint[2000];
@@ -277,7 +258,7 @@ namespace OTSIncAReportGraph.OTSIncAReportGraphFuncation
 
 
             //防止为空校验判断
             //防止为空校验判断
             if (resultFile.List_OTSField == null)
             if (resultFile.List_OTSField == null)
-                return;
+                return null;
             Particle particle = resultFile.List_OTSField.Find(x => x.FieldID == in_clr_fieldid).ParticleList.Find(x => x.ParticleId == in_clr_tagid);
             Particle particle = resultFile.List_OTSField.Find(x => x.FieldID == in_clr_fieldid).ParticleList.Find(x => x.ParticleId == in_clr_tagid);
             
             
             var tmpPart = new ParticleData(resultFile.FilePath).GetParticleXrayDataByFidAndPid(Convert.ToString(particle.FieldId), Convert.ToString(particle.XrayId));
             var tmpPart = new ParticleData(resultFile.FilePath).GetParticleXrayDataByFidAndPid(Convert.ToString(particle.FieldId), Convert.ToString(particle.XrayId));
@@ -295,11 +276,11 @@ namespace OTSIncAReportGraph.OTSIncAReportGraphFuncation
                     list_celementchemistryclr = particle.ElementList;
                     list_celementchemistryclr = particle.ElementList;
                 }
                 }
             }
             }
-           
+            return particle;
 
 
         }
         }
-
         
         
+
         /// <summary>
         /// <summary>
         /// 传入所有的物理field坐标点,和单个物理field的宽高,返回所有field的左上角位置,和整个field组成的rect大小
         /// 传入所有的物理field坐标点,和单个物理field的宽高,返回所有field的左上角位置,和整个field组成的rect大小
         /// </summary>
         /// </summary>
@@ -427,8 +408,28 @@ namespace OTSIncAReportGraph.OTSIncAReportGraphFuncation
             }
             }
 
 
         }
         }
+        public Bitmap GetBlackAndWhiteImage(Particle particle)
+        {
+            Bitmap dpImage = new Bitmap(resultFile.GetImageWidth(), resultFile.GetImageHeight());
+
+            using (Graphics graphics = Graphics.FromImage(dpImage))
+            {
+                graphics.Clear(Color.White); // 清除位图背景为白色
+            }
+
+            foreach (Segment seg in particle.SegmentList)
+            {
+                int f_length = seg.Length;
+                for (int m = 0; m < f_length; m++)
+                {
+                    int lsjs_x = seg.Start + m;
+                    int lsjs_y = seg.Height;
+                    dpImage.SetPixel(lsjs_x, lsjs_y, Color.Black);
+                }
+            }
+            return dpImage;
+        }
 
 
-       
 
 
 
 
         #region 颗粒分割功能方法
         #region 颗粒分割功能方法

+ 44 - 54
OTSIncAReportApp/1-UI/Control_Grids/CompositionDistributionGrid.cs

@@ -1,8 +1,5 @@
 using DevExpress.Utils;
 using DevExpress.Utils;
 using DevExpress.XtraCharts;
 using DevExpress.XtraCharts;
-using DevExpress.XtraRichEdit.Layout;
-using DevExpress.XtraTreeList.Data;
-using NPOI.SS.Formula.Functions;
 using OTSCommon.DBOperate.Model;
 using OTSCommon.DBOperate.Model;
 using OTSIncAReportApp;
 using OTSIncAReportApp;
 using OTSIncAReportApp._1_UI.Control_DEVCharts;
 using OTSIncAReportApp._1_UI.Control_DEVCharts;
@@ -162,7 +159,7 @@ namespace OTSIncAReportGrids
                     continue;
                     continue;
                 }
                 }
                 int add_rowindex = gridView.Rows.Add();
                 int add_rowindex = gridView.Rows.Add();
-
+                gridView.Rows[add_rowindex].Tag= "Statistics";
                 gridView.Rows[add_rowindex].Cells[0].Value = add_rowindex + 1;
                 gridView.Rows[add_rowindex].Cells[0].Value = add_rowindex + 1;
                 for (int k = 1; k < gridView.ColumnCount; k++)
                 for (int k = 1; k < gridView.ColumnCount; k++)
                 {
                 {
@@ -218,6 +215,7 @@ namespace OTSIncAReportGrids
                     continue;
                     continue;
                 }
                 }
                 int add_rowindex = gridView.Rows.Add();
                 int add_rowindex = gridView.Rows.Add();
+                gridView.Rows[add_rowindex].Tag = "Statistics";
                 int index = FLID.IndexOf(Convert.ToInt32(dt.Rows[i]["TypeId"]));
                 int index = FLID.IndexOf(Convert.ToInt32(dt.Rows[i]["TypeId"]));
                 if (index == -1)
                 if (index == -1)
                 {
                 {
@@ -270,32 +268,37 @@ namespace OTSIncAReportGrids
             }
             }
 
 
             gridView.Name = "gridView" + num.ToString();
             gridView.Name = "gridView" + num.ToString();
+            list_table_Point.Add(SetDataGridViewStyle(gridView));
+            AddSumRow(gridView);
+
+            panel1.Controls.Add(gridView);
+
+            list_table_data.Add(dt);
+        }
 
 
+        void AddSumRow(OTSGridView gridView)
+        {
+            if (gridView.Rows == null || gridView.Rows.Count == 0)
+                return;
             int a1 = gridView.Rows.Add();
             int a1 = gridView.Rows.Add();
+            gridView.Rows[a1].Tag = "Sum";
             gridView.Rows[a1].Cells[1].Value = "Sum";
             gridView.Rows[a1].Cells[1].Value = "Sum";
-            for (int j = 0; j < gridView.Rows.Count - 2; j++)
+            gridView.Refresh();
+            for (int j = 0; j < gridView.Rows.Count - 1; j++)
             {
             {
                 if (gridView.Rows[a1].Cells[3].Value == null)
                 if (gridView.Rows[a1].Cells[3].Value == null)
-                        gridView.Rows[a1].Cells[3].Value = 0;
-                    gridView.Rows[a1].Cells[3].Value = Convert.ToInt32(gridView.Rows[a1].Cells[3].Value) + Convert.ToInt32(gridView.Rows[j].Cells[3].Value);
-                if(gridView.Rows[a1].Cells[4].Value == null)
+                    gridView.Rows[a1].Cells[3].Value = 0;
+                gridView.Rows[a1].Cells[3].Value = Convert.ToInt64(gridView.Rows[a1].Cells[3].Value) + Convert.ToInt64(gridView.Rows[j].Cells[3].Value);
+                if (gridView.Rows[a1].Cells[4].Value == null)
                     gridView.Rows[a1].Cells[4].Value = 0;
                     gridView.Rows[a1].Cells[4].Value = 0;
                 gridView.Rows[a1].Cells[4].Value = Convert.ToDouble(gridView.Rows[a1].Cells[4].Value) + Convert.ToDouble(gridView.Rows[j].Cells[4].Value);
                 gridView.Rows[a1].Cells[4].Value = Convert.ToDouble(gridView.Rows[a1].Cells[4].Value) + Convert.ToDouble(gridView.Rows[j].Cells[4].Value);
             }
             }
-			list_table_Point.Add(SetDataGridViewStyle(gridView));
-			panel1.Controls.Add(gridView);
-
-            //         Panel panel = new Panel();
-            //panel.Size = new Size(gridwidth, 27);
-            ////panel.Dock = DockStyle.Top;
-            //panel.Location=new Point(0, list_gridheight.Max());
-            //         panel.BackColor = Color.WhiteSmoke;
-            list_table_data.Add(dt);
-
-
-			//Graphics(dt, filename, GraphicType, position);
-
-		}
+            gridView.Rows[a1].Height = gridView.Rows[a1-1].Height;
+            for (int j = 1; j < gridView.Columns.Count; j++)
+            {
+                gridView.Rows[a1].DefaultCellStyle.BackColor = Color.Azure;
+            }
+        }
 
 
         private void Graphics(DataTable data,string filename,string comboBox1Text,int pos)
         private void Graphics(DataTable data,string filename,string comboBox1Text,int pos)
         {
         {
@@ -378,7 +381,7 @@ namespace OTSIncAReportGrids
             gridView.Columns[1].Width = 200;
             gridView.Columns[1].Width = 200;
 
 
             //设置序号列不排序
             //设置序号列不排序
-            gridView.Columns[0].SortMode = DataGridViewColumnSortMode.NotSortable;
+            //gridView.Columns[0].SortMode = DataGridViewColumnSortMode.NotSortable;
 
 
             //设置序号列不可以设置宽度
             //设置序号列不可以设置宽度
             gridView.Columns[0].Resizable = DataGridViewTriState.False;
             gridView.Columns[0].Resizable = DataGridViewTriState.False;
@@ -409,14 +412,16 @@ namespace OTSIncAReportGrids
             gridView.Size = new System.Drawing.Size(gridView.ColumnCount * 100 + 60, gridView.RowCount * 30);
             gridView.Size = new System.Drawing.Size(gridView.ColumnCount * 100 + 60, gridView.RowCount * 30);
 			//gridView.Size = new System.Drawing.Size(gridView.ColumnCount * 100 + 60, gridView.RowCount * 30 + 30);
 			//gridView.Size = new System.Drawing.Size(gridView.ColumnCount * 100 + 60, gridView.RowCount * 30 + 30);
 			//gridheight = gridheight + gridView.RowCount * 30 + 80;
 			//gridheight = gridheight + gridView.RowCount * 30 + 80;
-			gridheight = gridheight + gridView.RowCount * 30 + 5;
+			gridheight = gridheight + (gridView.RowCount+1) * 30 + 5;
 			gridwidth = gridwidth + gridView.ColumnCount * 100 + 60;
 			gridwidth = gridwidth + gridView.ColumnCount * 100 + 60;
             chartposition = chartposition + gridView.ColumnCount * 100;
             chartposition = chartposition + gridView.ColumnCount * 100;
 			GridPosition = gridView.ColumnCount * 100 +40;
 			GridPosition = gridView.ColumnCount * 100 +40;
 			list_gridheight.Add(gridheight);
 			list_gridheight.Add(gridheight);
 
 
 			gridView.TabIndex = 0;
 			gridView.TabIndex = 0;
-            gridView.SortCompare += new System.Windows.Forms.DataGridViewSortCompareEventHandler(this.Gview_gz_SortCompare);
+            
+
+            gridView.ColumnHeaderMouseClick += new DataGridViewCellMouseEventHandler(this.Gview_ColumnHeaderMouseClick);
             gridView.Sorted += new System.EventHandler(this.Gview_gz_Sorted);
             gridView.Sorted += new System.EventHandler(this.Gview_gz_Sorted);
 
 
             //先设置一下头的高度,否则会太矮不好看
             //先设置一下头的高度,否则会太矮不好看
@@ -426,7 +431,7 @@ namespace OTSIncAReportGrids
 			list_table_size.Add( new Point(gridView.ColumnCount * 100+40, gridView.RowCount * 30));
 			list_table_size.Add( new Point(gridView.ColumnCount * 100+40, gridView.RowCount * 30));
 
 
 
 
-			return new Point(outpos, gridheight);
+			return new Point(outpos, gridheight+30);
 		}
 		}
         #endregion
         #endregion
 
 
@@ -699,42 +704,27 @@ namespace OTSIncAReportGrids
 			}
 			}
         }
         }
 
 
-        private void Gview_gz_SortCompare(object sender, DataGridViewSortCompareEventArgs e)
-        {
-
-            //排序中
-            if (((OTSGridView)sender).Rows[e.RowIndex1].Tag != null && ((OTSGridView)sender).Rows[e.RowIndex1].Tag.ToString() == "统计行")
-            {
-                //ROW1>ROW2  
-                e.SortResult = 1;
-                if (((OTSGridView)sender).SortOrder == SortOrder.Descending)
-                    e.SortResult = -1;
-                e.Handled = true;
-                return;
-            }
 
 
-            if (((OTSGridView)sender).Rows[e.RowIndex2].Tag != null && ((OTSGridView)sender).Rows[e.RowIndex2].Tag.ToString() == "统计行")
-            {
-                //ROW1<ROW2  
-                e.SortResult = -1;
-                if (((OTSGridView)sender).SortOrder == SortOrder.Descending)
-                    e.SortResult = 1;
-                e.Handled = true;
+        void Gview_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
+        {
+            if (((OTSGridView)sender).Rows == null || ((OTSGridView)sender).Rows.Count == 0)
                 return;
                 return;
-            }
+            AddSumRow((OTSGridView)sender);
         }
         }
-
         private void Gview_gz_Sorted(object sender, EventArgs e)
         private void Gview_gz_Sorted(object sender, EventArgs e)
         {
         {
+            if (((OTSGridView)sender).Rows == null || ((OTSGridView)sender).Rows.Count == 0)
+                return;
+            for (int i = 0; i < ((OTSGridView)sender).Rows.Count; i++)
+            {
+                if (((OTSGridView)sender).Rows[i].Tag.ToString() == "Sum")
+                { ((OTSGridView)sender).Rows.RemoveAt(i); break; }
+            }
+            ((OTSGridView)sender).Refresh();
             //排序完成,重新设置序号
             //排序完成,重新设置序号
             for (int i = 0; i < ((OTSGridView)sender).Rows.Count; i++)
             for (int i = 0; i < ((OTSGridView)sender).Rows.Count; i++)
             {
             {
-                if (((OTSGridView)sender).Rows[i].Tag != null && ((OTSGridView)sender).Rows[i].Tag.ToString() == "统计行")
-                { }
-                else
-                {
-                    ((OTSGridView)sender).Rows[i].Cells[0].Value = i.ToString();
-                }
+                ((OTSGridView)sender).Rows[i].Cells[0].Value = (i+1).ToString();
             }
             }
         }
         }
         #endregion
         #endregion

+ 85 - 85
OTSIncAReportApp/1-UI/Control_Grids/CompositionDistributionGrid.designer.cs

@@ -28,95 +28,95 @@
         /// </summary>
         /// </summary>
         private void InitializeComponent()
         private void InitializeComponent()
         {
         {
-			this.components = new System.ComponentModel.Container();
-			System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CompositionDistributionGrid));
-			this.panel1 = new System.Windows.Forms.Panel();
-			this.pictureBox1 = new System.Windows.Forms.PictureBox();
-			this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
-			this.ToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
-			this.ToolStripMenuItem2 = new System.Windows.Forms.ToolStripMenuItem();
-			this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
-			this.ToolStripMenuItem3 = new System.Windows.Forms.ToolStripMenuItem();
-			this.panel1.SuspendLayout();
-			((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
-			this.contextMenuStrip1.SuspendLayout();
-			this.SuspendLayout();
-			// 
-			// panel1
-			// 
-			this.panel1.AutoScroll = true;
-			this.panel1.Controls.Add(this.pictureBox1);
-			this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
-			this.panel1.Location = new System.Drawing.Point(0, 0);
-			this.panel1.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
-			this.panel1.Name = "panel1";
-			this.panel1.Size = new System.Drawing.Size(667, 520);
-			this.panel1.TabIndex = 5;
-			// 
-			// pictureBox1
-			// 
-			this.pictureBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
-			this.pictureBox1.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("pictureBox1.BackgroundImage")));
-			this.pictureBox1.Location = new System.Drawing.Point(497, 490);
-			this.pictureBox1.Name = "pictureBox1";
-			this.pictureBox1.Size = new System.Drawing.Size(170, 30);
-			this.pictureBox1.TabIndex = 1;
-			this.pictureBox1.TabStop = false;
-			// 
-			// contextMenuStrip1
-			// 
-			this.contextMenuStrip1.ImageScalingSize = new System.Drawing.Size(24, 24);
-			this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
+            this.components = new System.ComponentModel.Container();
+            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CompositionDistributionGrid));
+            this.panel1 = new System.Windows.Forms.Panel();
+            this.pictureBox1 = new System.Windows.Forms.PictureBox();
+            this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
+            this.ToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
+            this.ToolStripMenuItem2 = new System.Windows.Forms.ToolStripMenuItem();
+            this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
+            this.ToolStripMenuItem3 = new System.Windows.Forms.ToolStripMenuItem();
+            this.panel1.SuspendLayout();
+            ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
+            this.contextMenuStrip1.SuspendLayout();
+            this.SuspendLayout();
+            // 
+            // panel1
+            // 
+            this.panel1.AutoScroll = true;
+            this.panel1.Controls.Add(this.pictureBox1);
+            this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
+            this.panel1.Location = new System.Drawing.Point(0, 0);
+            this.panel1.Margin = new System.Windows.Forms.Padding(2);
+            this.panel1.Name = "panel1";
+            this.panel1.Size = new System.Drawing.Size(667, 520);
+            this.panel1.TabIndex = 5;
+            // 
+            // pictureBox1
+            // 
+            this.pictureBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+            this.pictureBox1.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("pictureBox1.BackgroundImage")));
+            this.pictureBox1.Location = new System.Drawing.Point(497, 490);
+            this.pictureBox1.Name = "pictureBox1";
+            this.pictureBox1.Size = new System.Drawing.Size(170, 30);
+            this.pictureBox1.TabIndex = 1;
+            this.pictureBox1.TabStop = false;
+            // 
+            // contextMenuStrip1
+            // 
+            this.contextMenuStrip1.ImageScalingSize = new System.Drawing.Size(24, 24);
+            this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
             this.ToolStripMenuItem1,
             this.ToolStripMenuItem1,
             this.ToolStripMenuItem2,
             this.ToolStripMenuItem2,
             this.toolStripSeparator1,
             this.toolStripSeparator1,
             this.ToolStripMenuItem3});
             this.ToolStripMenuItem3});
-			this.contextMenuStrip1.Name = "contextMenuStrip1";
-			this.contextMenuStrip1.Size = new System.Drawing.Size(169, 100);
-			// 
-			// ToolStripMenuItem1
-			// 
-			this.ToolStripMenuItem1.Image = global::OTSIncAReportApp.Properties.Resources.复制;
-			this.ToolStripMenuItem1.Name = "ToolStripMenuItem1";
-			this.ToolStripMenuItem1.Size = new System.Drawing.Size(168, 30);
-			this.ToolStripMenuItem1.Text = "复制整个表";
-			this.ToolStripMenuItem1.Click += new System.EventHandler(this.ToolStripMenuItem1_Click);
-			// 
-			// ToolStripMenuItem2
-			// 
-			this.ToolStripMenuItem2.Image = global::OTSIncAReportApp.Properties.Resources.复制全部;
-			this.ToolStripMenuItem2.Name = "ToolStripMenuItem2";
-			this.ToolStripMenuItem2.Size = new System.Drawing.Size(168, 30);
-			this.ToolStripMenuItem2.Text = "复制选择区域";
-			this.ToolStripMenuItem2.Click += new System.EventHandler(this.ToolStripMenuItem2_Click);
-			// 
-			// toolStripSeparator1
-			// 
-			this.toolStripSeparator1.Name = "toolStripSeparator1";
-			this.toolStripSeparator1.Size = new System.Drawing.Size(165, 6);
-			// 
-			// ToolStripMenuItem3
-			// 
-			this.ToolStripMenuItem3.Image = global::OTSIncAReportApp.Properties.Resources.恢复;
-			this.ToolStripMenuItem3.Name = "ToolStripMenuItem3";
-			this.ToolStripMenuItem3.Size = new System.Drawing.Size(168, 30);
-			this.ToolStripMenuItem3.Text = "恢复至初始状态";
-			this.ToolStripMenuItem3.Click += new System.EventHandler(this.ToolStripMenuItem3_Click);
-			// 
-			// CompositionDistributionGrid
-			// 
-			this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
-			this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
-			this.BackColor = System.Drawing.SystemColors.ButtonHighlight;
-			this.Controls.Add(this.panel1);
-			this.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
-			this.Name = "CompositionDistributionGrid";
-			this.Size = new System.Drawing.Size(667, 520);
-			this.Load += new System.EventHandler(this.CompositionDistributionGrid_Load);
-			this.panel1.ResumeLayout(false);
-			((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
-			this.contextMenuStrip1.ResumeLayout(false);
-			this.ResumeLayout(false);
+            this.contextMenuStrip1.Name = "contextMenuStrip1";
+            this.contextMenuStrip1.Size = new System.Drawing.Size(169, 100);
+            // 
+            // ToolStripMenuItem1
+            // 
+            this.ToolStripMenuItem1.Image = global::OTSIncAReportApp.Properties.Resources.复制;
+            this.ToolStripMenuItem1.Name = "ToolStripMenuItem1";
+            this.ToolStripMenuItem1.Size = new System.Drawing.Size(168, 30);
+            this.ToolStripMenuItem1.Text = "复制整个表";
+            this.ToolStripMenuItem1.Click += new System.EventHandler(this.ToolStripMenuItem1_Click);
+            // 
+            // ToolStripMenuItem2
+            // 
+            this.ToolStripMenuItem2.Image = global::OTSIncAReportApp.Properties.Resources.复制全部;
+            this.ToolStripMenuItem2.Name = "ToolStripMenuItem2";
+            this.ToolStripMenuItem2.Size = new System.Drawing.Size(168, 30);
+            this.ToolStripMenuItem2.Text = "复制选择区域";
+            this.ToolStripMenuItem2.Click += new System.EventHandler(this.ToolStripMenuItem2_Click);
+            // 
+            // toolStripSeparator1
+            // 
+            this.toolStripSeparator1.Name = "toolStripSeparator1";
+            this.toolStripSeparator1.Size = new System.Drawing.Size(165, 6);
+            // 
+            // ToolStripMenuItem3
+            // 
+            this.ToolStripMenuItem3.Image = global::OTSIncAReportApp.Properties.Resources.恢复;
+            this.ToolStripMenuItem3.Name = "ToolStripMenuItem3";
+            this.ToolStripMenuItem3.Size = new System.Drawing.Size(168, 30);
+            this.ToolStripMenuItem3.Text = "恢复至初始状态";
+            this.ToolStripMenuItem3.Click += new System.EventHandler(this.ToolStripMenuItem3_Click);
+            // 
+            // CompositionDistributionGrid
+            // 
+            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+            this.BackColor = System.Drawing.SystemColors.ButtonHighlight;
+            this.Controls.Add(this.panel1);
+            this.Margin = new System.Windows.Forms.Padding(2);
+            this.Name = "CompositionDistributionGrid";
+            this.Size = new System.Drawing.Size(667, 520);
+            this.Load += new System.EventHandler(this.CompositionDistributionGrid_Load);
+            this.panel1.ResumeLayout(false);
+            ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
+            this.contextMenuStrip1.ResumeLayout(false);
+            this.ResumeLayout(false);
 
 
         }
         }
 
 

+ 27 - 27
OTSIncAReportApp/1-UI/Control_Grids/CompositionDistributionGrid.resx

@@ -121,33 +121,33 @@
   <data name="pictureBox1.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
   <data name="pictureBox1.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
     <value>
     <value>
         iVBORw0KGgoAAAANSUhEUgAAAKoAAAAfCAYAAAB3cVZEAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
         iVBORw0KGgoAAAANSUhEUgAAAKoAAAAfCAYAAAB3cVZEAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
-        wgAADsIBFShKgAAABhBJREFUeF7tmI1NZDEMhGmBGmiBHiiBGmiBDuiADqiACmiABuiAHvb0oTU3O2s7
-        eYvQ3ZMykgW8OI5/xk7urg4LCzvAIurCr+Lt7e3w+Ph4uLu7O1xdXZ3I7e3t4eHh4UtnhEXUhV8B5Lu5
-        uTkjZyUQ+f39/bj7HEOifnx8pB1xfX399e35+fnw+fl51D4Ha53DdBX2OUeB05n+SJ6eno4W/gIf8BN/
-        8Vv1+Zad77i/vz/ZxySoQJFCj/MuBXY4hxzp2eQTf15eXo6ap/AYZ4Q8KDRnrkeOu5qTT90zK/hd1aEk
-        Ko7MHsgBVTcQbLbHBRuaeJKR6Y2E8xT8PVu4qvBV07y+vh41TqG+Q6qtoFhOkEogsZJGm2SLQPwAcY1y
-        5sQO0FiqR/zUwPlBjJzj+pXdlKgE7l08kqob3JFOsBFJv4So7sOWs0My8kHgTBf7GZRklU4FCjrbWCHU
-        KnApUSPu2ZssIxQ2VMeHRgWPOePRGVEzktIVFCtIxE/+9oRmRVFbmlCQdW5GlIASgH0dnKToQ35NAmdl
-        sTqqm6XyQXVmiwUykhKz5gT/syaubgPg+j7dFJpjhDxG3TmbeIIPCnTUd12neZjYus7f6of6mOXsjKhe
-        FAoZjjq8g7LC6XpGZD8PhyuoXtbRgcyvqjjEprqI62rxnNjeWOzVdYo0C7fdTWPPm17dDidfBc+FD5YO
-        EDP2aQ275yN1icGhN0HGgROv2eSGKpIGVB9R+DWUdYp3ezUZnAAdoel41R2RxQvp+rqmBUGcTL4+C9/X
-        NSLw3Hb6Osk6Pbe5hajRZMoZ6q32MgldPXtIVL8uK9IoVB9RuKMZYXyKVJPPC+mTLDAiUoaOqN4gJFZ9
-        pjAKnSBbCu3NpU+UDLNE9eGDfxV8oiIz+dN9oc83b5CIiZ/8rbY3EVUNI8H2DqqPKJz4Dk929j4MuK2q
-        kFyBqlcRWtERVYkfpOxuAbU1U2TgzTBD8FmieuOqrxk8Fwh16fKoT62w73kbcUnjad+oHnj35lHoHiea
-        Th5NPk5TbG+MLhndFFOovU5P4cXRJtAGCTL4lNJc6fcs4Rmc+DP7vF5VU/gbsbqxAsTm0z2E+DPCqf/R
-        5HpuN8UDevuGDcU3Uf2azsavoyM3AenaSEbTR3Wr6eGTqdJz6B4ntzaI5kS/I8Tr52cJz+C3wMy+WXJ7
-        E86AWPwGCyFuJ6v6EtBz2RPNz170nbyagwzfXz3w0RUBvFt1j5O4EyVABrdV6bvezNWr11a2R9d04ntj
-        E7vbmoWTqXrWKLxRqj2qM9u4ARrPfUO8KTKiOjdctIY61KqbvCTqqKsx7le3dprbcyEBBDxTFCdF9USY
-        JbTCC6G23Z76yu+6RoI1Zog0C/dhBPerOssn/MwVnMGnqxNe446nBT+dHypKdiV1NSAvnqjeMT6J/Dr7
-        CTxRFbm3TlSfgP7G1gbJ3rs61VjXmLeQwok6al6fplWt+D6jN4LntSOqDgfISk6UsOxVkqqP3T+mS6K6
-        MwpPAI74u0Uf5FumSwYnRAVPaOZXIOt49iu0QbJ8+KRX2UIKJ6oW2zGabgofJjHttsLj9CbEbqyR09lz
-        3K7nX/FNVD0shG7QQ/ndJyXiV7G+OZDRZBtBbXWFAU4+SK7+Ma28KZFsAmqDZOTx619ltlggIzzn6WQl
-        Bp+kxNpNX2+ACjQVg4UcqN+RK89pdqafRc3x2XWxT7z+PwujG+jE+4yEI8kmh082HLsUbqubNiAr+kiq
-        RlIdb8ZAlbMtoLG9cCOZmVyq3zX4lrpX+ccXJ/SsjGoKTjJKwrwzKqG7q0RxsOp2I30EJ15FGIVfeZWQ
-        2MqeN0g1ufwZhIymfgZyOUtWiFU9aQLY0z3dxPLnRCbkajRwONOnfifEO8uNtPUpHsnwxOFEjPQOShRs
-        /ARKVGx1V52CpOGrJw4bxAbBumLrudiogA09oyP/CNjCL4ju04lvfjV3UKLO+MS55MtrzrnkYtQYCs7K
-        ch/2iGPr8Np2Ry0s/CMsoi7sAouoC7vAF1H9HbFkyX8ni6hLdiEQdWHhf8ci6sIusIi6sAssoi7sAouo
-        CzvA4fAHgW7crI7nKn8AAAAASUVORK5CYII=
+        wQAADsEBuJFr7QAABflJREFUeF7tmYFNbDkMRWmBGmiBHiiBGmiBDuiADqiACmiABuiAHlhdJI/uHHyT
+        PHZXYqQcyfpiJi9x7Gsnb/7V12ZzAVzxg83mv+Tt7e3r8fHx6+7u7uvq6urMbm9vvx4eHr7HzNhC3fwv
+        SHw3Nzc/xJlMQn5/f+c0J6ZC/fj4aCvi+vr6+7Pn5+evz89PPnZC340cVlVpfq3jyGmOXbGnp6ezeYR8
+        kJ/yV377eH3WrU/u7+/PnlMnSChJNU7r/RbNo3UUI19b8ZQ/Ly8vfOQb7nHFFAfHY8ZxivEo54on518x
+        +Z3yEIUqR1YX1AKpGrRZju9Mc3jgFQyOWTGtx/VXE5cSn4rm9fWVQ79x3yWqoyhZFEgyidhF40VyxCT8
+        QvuaxYzCLlRYPk77Vw6oD+1R63B8mrcVqjbOKp5ZqgY6MjLNUUH/jVDpw5G1yzrxScAcJ0td1UWWxiSU
+        0JlIaMpV8Vuh1r5TUdI6QWkOH8OmkeCeOx39EGonUlWFklUi0r/6mwHtkuJzeUBFV7mdUAoXwOxIpUg1
+        XuL3IGitbq8knSzJBx+zmizBhMm0Z4+J/O+KOJ0GguPZ3Rx2csWx8q61tZ/Sg6Mx7rt/r+JRx/bv9bf7
+        4T52MfshVCaFR4vDCuoSx00TrtfdMQsf11V00fmVkqO9+VgZx3ryKGwWFjvSyhttwbm7eBWMmx/dhOJL
+        MBZsLCP81PEc0k83PwH9JOg0cOa1HuJESaQFF3d4DHWVwmpnpRYUQLeZgi9vM7EwkRxP//xvionfr8Ln
+        RoUoGNvReO9ko3Gc84hQq8hcMyvvJzX2kFB5XCbROFzYoaMUgGAXYTcrmEh2soLjKKSOkVBZILwa8RTx
+        DnIk0Syu7p7mUFRJgGw+8i/BjipbiZ8/V+N5FZB/tad6WfS5DwmV96NZNxXcmEPhEwa7ux8WnCslkj8j
+        JUE7I6G68EuUo1PA51pJsmAxrAicsUtCZeHOmg9jIVNeRnH0q1bNz7jNtOT76U7ek3q48dGdx+GGnPQi
+        JaeVbBbGKBijLub4fKNxDpOTfjkoMbBLeaz88y7gHRT+ynPMVyoK3hHTiVVob+zuZdp/Jzj3v4rc1x11
+        8cJP3+7kPQmVx3TXfgmD5QnrjpGRpUAXPjZ1D3amNI74MxS3F4jHhFcW7ZfrdwHv4Cmw8tyquFmEK2gv
+        PMHKupdr96XwdfVMFX81KYrXY9Bx+pQbnx0RgtXKnyS4yWSzouBcaTzHzcQv+AsBn/HvvOOzsLV3zrUK
+        xZSuNQ4LJT3jY1YLt1Dh0TcZi6ITKrVB8xx6U0sneRTqrKp5WZZ5pXE+mgKgDacAOxRFuiJQqEnQDhPh
+        c3M+97U7/n3PK/fMgj7MoF9pLXZ4drFV2F0peN93XS2634TdXOwu6tQgo1DTAwUrhp2Ix9m/gYFK4mYC
+        6RNhB+Qd2wuEVwLBe7Pv+YgoKNS0v4LdNOXq6ItUgnEdCdWbg8TKH/qrQRXuI+PvRKHSGYcB6N7q/EKe
+        Kn4VCiLBgHZ+FV3F8xTpXqQcdnq3I6KgUEcnAYu286tgM5m9SCW4Txahd27FdHUdzsv4Oyeh8piQ8b+5
+        qkI4jkcxX6RmnW2GzzVKjKD4JPKV/4Jk8EV6kSp4/LutJkswYbWed1btgZ1Uex11XxZAQkWlxqIYuN8V
+        K8a0W5NrKefymWM1v/bLXxa6+Dtn3ncinFnXOdjZePk+AufqBON0SZ9ZKiQfw2IsUsyOoMJm4ma20rl8
+        /KjA0x46S/HvTqhVS3M6ZxFVwFgZyVTdKVDsWKOWPoPCS4JxeOQlU2DTfCwQdoaC1yDZSBQJxXJVrBJW
+        utIUPCFHHYvXic4Uq1nD0Zrs+iPTfle10Za+kqdgMHByolr6CBfK6IK8ggtVcyXBEAVNvjJwmkN7k8BG
+        yfZ1R3dszcE79Cw+Cc0lvyR0did9xqN5BO+NM5+0ruLFnNfLzyhWRGt1sfd9rAq0aIW62fw1tlA3F8EW
+        6uYi+BYq7xHbtv0520LddhHGFrvZ/EW2UDcXwRbq5iLYQt1cBFuom4vgH4Fu3Kxz2zYiAAAAAElFTkSu
+        QmCC
 </value>
 </value>
   </data>
   </data>
   <metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
   <metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">

+ 2 - 33
OTSIncAReportApp/1-UI/Control_Grids/ElementCompositionAvgGrid.cs

@@ -276,7 +276,6 @@ namespace OTSIncAReportGrids
 			gridheight = gridheight + gridView.RowCount * 30 + 5;
 			gridheight = gridheight + gridView.RowCount * 30 + 5;
 			gridwidth = gridwidth + gridView.ColumnCount * 100;
 			gridwidth = gridwidth + gridView.ColumnCount * 100;
 			gridView.TabIndex = 0;
 			gridView.TabIndex = 0;
-            gridView.SortCompare += new System.Windows.Forms.DataGridViewSortCompareEventHandler(this.Gview_gz_SortCompare);
             gridView.Sorted += new System.EventHandler(this.Gview_gz_Sorted);
             gridView.Sorted += new System.EventHandler(this.Gview_gz_Sorted);
 
 
             //先设置一下头的高度,否则会太矮不好看
             //先设置一下头的高度,否则会太矮不好看
@@ -616,42 +615,12 @@ namespace OTSIncAReportGrids
 
 
             //SetDataGridViewStyle();
             //SetDataGridViewStyle();
         }
         }
-
-        private void Gview_gz_SortCompare(object sender, DataGridViewSortCompareEventArgs e)
-        {
-            //排序中
-            if (this.Gview_gz.Rows[e.RowIndex1].Tag != null && this.Gview_gz.Rows[e.RowIndex1].Tag.ToString() == "统计行")
-            {
-                //ROW1>ROW2  
-                e.SortResult = 1;
-                if (this.Gview_gz.SortOrder == SortOrder.Descending)
-                    e.SortResult = -1;
-                e.Handled = true;
-                return;
-            }
-
-            if (this.Gview_gz.Rows[e.RowIndex2].Tag != null && this.Gview_gz.Rows[e.RowIndex2].Tag.ToString() == "统计行")
-            {
-                //ROW1<ROW2  
-                e.SortResult = -1;
-                if (this.Gview_gz.SortOrder == SortOrder.Descending)
-                    e.SortResult = 1;
-                e.Handled = true;
-                return;
-            }
-        }
-
         private void Gview_gz_Sorted(object sender, EventArgs e)
         private void Gview_gz_Sorted(object sender, EventArgs e)
         {
         {
             //排序完成,重新设置序号
             //排序完成,重新设置序号
-            for (int i = 0; i < Gview_gz.Rows.Count; i++)
+            for (int i = 0; i < ((OTSGridView)sender).Rows.Count; i++)
             {
             {
-                if (Gview_gz.Rows[i].Tag != null && this.Gview_gz.Rows[i].Tag.ToString() == "统计行")
-                { }
-                else
-                {
-                    Gview_gz.Rows[i].Cells[0].Value = i.ToString();
-                }
+                ((OTSGridView)sender).Rows[i].Cells[0].Value = (i+1).ToString();
             }
             }
         }
         }
 
 

+ 4 - 3
OTSIncAReportApp/1-UI/Control_Grids/ParticlesGridDevidePage/ListOfSimilarParticles.cs

@@ -107,7 +107,7 @@ namespace OTSIncAReportApp._1_UI.Control_Grids.ParticlesGridDevidePage
                 DataTable mergeParticles = _particlesGridDevidePage.Particledata.GetInfoForPartucleDevidePage_mergeParticles("");
                 DataTable mergeParticles = _particlesGridDevidePage.Particledata.GetInfoForPartucleDevidePage_mergeParticles("");
                 if (mergeParticles != null && mergeParticles.Rows.Count > 0)
                 if (mergeParticles != null && mergeParticles.Rows.Count > 0)
                 {
                 {
-                    _particlesGridDevidePage.RemoveMergeParticles(ref particlesAll, mergeParticles);
+                    _particlesGridDevidePage.Particledata.RemoveMergeParticles(ref particlesAll, mergeParticles);
                 }
                 }
                 DataTable XRayData = _particlesGridDevidePage.Particledata.GetXRayData();
                 DataTable XRayData = _particlesGridDevidePage.Particledata.GetXRayData();
                 particlesAll.Columns.Add("XRayDataCount");
                 particlesAll.Columns.Add("XRayDataCount");
@@ -366,9 +366,10 @@ namespace OTSIncAReportApp._1_UI.Control_Grids.ParticlesGridDevidePage
                                     Bitmap tempbit = _particlesGridDevidePage.Particledata.ReadImageFile(imagePatht);
                                     Bitmap tempbit = _particlesGridDevidePage.Particledata.ReadImageFile(imagePatht);
                                     int pixw = tempbit.Width;
                                     int pixw = tempbit.Width;
                                     double xs = pixw / ScanFieldSize;
                                     double xs = pixw / ScanFieldSize;
-
+                                    OTS_X_AXIS_DIRECTION X_AXIS_DIRECTION = _particlesGridDevidePage.result.GetXAxisDirEnum();
+                                    OTS_Y_AXIS_DIRECTION Y_AXIS_DIRECTION = _particlesGridDevidePage.result.GetYAxisDirEnum();
                                     particleM = particleM + "," + subt;
                                     particleM = particleM + "," + subt;
-                                    Bitmap bmap = _particlesGridDevidePage.Particledata.GetBitmapForBig(subt, xs, _particlesGridDevidePage.result.FilePath, tempbit.Height, tempbit.Width);
+                                    Bitmap bmap = _particlesGridDevidePage.Particledata.GetBitmapForBig(subt, xs, _particlesGridDevidePage.result.FilePath, tempbit.Height, tempbit.Width, X_AXIS_DIRECTION, Y_AXIS_DIRECTION);
                                     if (bmap != null)
                                     if (bmap != null)
                                     {
                                     {
                                         string[] str = subt.Split(',');
                                         string[] str = subt.Split(',');

+ 220 - 230
OTSIncAReportApp/1-UI/Control_Grids/ParticlesGridDevidePage/ParticlesGridDevidePage.cs

@@ -15,7 +15,6 @@ using OTSIncAReportGraph.Controls;
 using OTSIncAReportGraph.OTSIncAReportGraphFuncation;
 using OTSIncAReportGraph.OTSIncAReportGraphFuncation;
 using OTSIncAReportGrids.OTSIncAReportGridsFuncation;
 using OTSIncAReportGrids.OTSIncAReportGridsFuncation;
 using OTSIncAReportMailInterface;
 using OTSIncAReportMailInterface;
-using OTSPeriodicTable;
 using System;
 using System;
 using System.Collections;
 using System.Collections;
 using System.Collections.Generic;
 using System.Collections.Generic;
@@ -78,10 +77,16 @@ namespace OTSIncAReportGrids
         DataTable particlesAll;
         DataTable particlesAll;
         DataTable particles;
         DataTable particles;
         public ParticleData Particledata;
         public ParticleData Particledata;
-        UserLibraryData userLibrary;
-        DataTable userLibraryData;
+        UserSTDDbData userSTDDb;
+        DataTable userSTDDbData;
         NLog.Logger log = NLog.LogManager.GetCurrentClassLogger();
         NLog.Logger log = NLog.LogManager.GetCurrentClassLogger();
 
 
+
+
+
+
+
+
         enum SelItem
         enum SelItem
         {
         {
             analyticalParticle = 0,
             analyticalParticle = 0,
@@ -89,7 +94,7 @@ namespace OTSIncAReportGrids
             MergeParticles = 2,
             MergeParticles = 2,
             allParticles = 3
             allParticles = 3
         }
         }
-        //ListOfSimilarParticles Form_listOfSimilarParticles;
+
         #region 分页器相关
         #region 分页器相关
 
 
         #region 分页字段和属性
         #region 分页字段和属性
@@ -225,15 +230,15 @@ namespace OTSIncAReportGrids
                 var systype = m_ReportApp.m_RptConfigFile.Systype;
                 var systype = m_ReportApp.m_RptConfigFile.Systype;
                 if (systype == OTS_SysType_ID.TCCleannessA || systype == OTS_SysType_ID.BatteryCleannessA)
                 if (systype == OTS_SysType_ID.TCCleannessA || systype == OTS_SysType_ID.BatteryCleannessA)
                 {
                 {
-                    string str_libraryName = result.GetSTDName();
-                    userLibrary = new UserLibraryData(str_libraryName, result.FilePath + "\\");
-                    if (userLibrary.GetSqlHelper() != null)
+                    string str_STDDbName = result.GetSTDName();
+                    userSTDDb = new UserSTDDbData(str_STDDbName, result.FilePath + "\\");
+                    if (userSTDDb.GetSqlHelper() != null)
                     {
                     {
-                        userLibraryData = userLibrary.GetSubAttributeFromDatabase();
+                        userSTDDbData = userSTDDb.GetSubAttributeFromDatabase();
                     }
                     }
                     else
                     else
                     {
                     {
-                        userLibraryData = null;
+                        userSTDDbData = null;
                     }
                     }
                 }
                 }
                 //初始化底层操作类
                 //初始化底层操作类
@@ -254,7 +259,7 @@ namespace OTSIncAReportGrids
             }
             }
             ProgressStart();//进度条关闭通过cbB_PageSize.SelectedIndex事件
             ProgressStart();//进度条关闭通过cbB_PageSize.SelectedIndex事件
 
 
-            if (!UpdateTable())
+            if (!UpdateDataGrid())
             {
             {
                 return;
                 return;
             }
             }
@@ -287,27 +292,27 @@ namespace OTSIncAReportGrids
 
 
 
 
         #region 自定义方法
         #region 自定义方法
-        bool UpdateTable()
+        bool UpdateDataGrid()
         {
         {
             int sel = m_ReportApp.m_conditionChoose.m_conditionData.GetComboDownListIndexByItemName(OTSIncAReportApp.OTSSampleReportInfo.OTS_REPORT_PROP_GRID_ITEMS.PARTICE_LIST);
             int sel = m_ReportApp.m_conditionChoose.m_conditionData.GetComboDownListIndexByItemName(OTSIncAReportApp.OTSSampleReportInfo.OTS_REPORT_PROP_GRID_ITEMS.PARTICE_LIST);
             particlesAll = new DataTable();
             particlesAll = new DataTable();
             if (sel == (int)SelItem.analyticalParticle)
             if (sel == (int)SelItem.analyticalParticle)
             {
             {
 
 
-                particlesAll = Particledata.GetInfoForPartucleDevidePage_analyticalParticle(condition);
+                DataTable particlesAll = Particledata.GetInfoForPartucleDevidePage_analyticalParticle(condition);
                 DataTable mergeParticles = Particledata.GetInfoForPartucleDevidePage_mergeParticles(condition);
                 DataTable mergeParticles = Particledata.GetInfoForPartucleDevidePage_mergeParticles(condition);
                 if (mergeParticles != null && mergeParticles.Rows.Count > 0)
                 if (mergeParticles != null && mergeParticles.Rows.Count > 0)
                 {
                 {
-                    RemoveMergeParticles(ref particlesAll, mergeParticles);
+                    Particledata.RemoveMergeParticles(ref particlesAll, mergeParticles);
                 }
                 }
             }
             }
             if (sel == (int)SelItem.otherParticles)
             if (sel == (int)SelItem.otherParticles)
             {
             {
-                particlesAll = Particledata.GetInfoForPartucleDevidePage_otherParticle(condition);
+                DataTable particlesAll = Particledata.GetInfoForPartucleDevidePage_otherParticle(condition);
                 DataTable mergeParticles = Particledata.GetInfoForPartucleDevidePage_mergeParticles(condition);
                 DataTable mergeParticles = Particledata.GetInfoForPartucleDevidePage_mergeParticles(condition);
                 if (mergeParticles != null && mergeParticles.Rows.Count > 0)
                 if (mergeParticles != null && mergeParticles.Rows.Count > 0)
                 {
                 {
-                    RemoveMergeParticles(ref particlesAll, mergeParticles);
+                    Particledata.RemoveMergeParticles(ref particlesAll, mergeParticles);
                 }
                 }
             }
             }
             if (sel == (int)SelItem.MergeParticles)
             if (sel == (int)SelItem.MergeParticles)
@@ -316,16 +321,21 @@ namespace OTSIncAReportGrids
             }
             }
             if (sel == (int)SelItem.allParticles)
             if (sel == (int)SelItem.allParticles)
             {
             {
-                particlesAll = Particledata.GetInfoForPartucleDevidePage_allParticles(condition);
+                DataTable particlesAll = Particledata.GetInfoForPartucleDevidePage_allParticles(condition);
+                DataTable mergeParticles = Particledata.GetInfoForPartucleDevidePage_mergeParticles(condition);
+                if (mergeParticles != null && mergeParticles.Rows.Count > 0)
+                {
+                    Particledata.RemoveMergeParticles(ref particlesAll, mergeParticles);
+                }
             }
             }
             particlesAll.Columns.Add("Hardness");
             particlesAll.Columns.Add("Hardness");
             particlesAll.Columns.Add("Density");
             particlesAll.Columns.Add("Density");
             particlesAll.Columns.Add("Electrical_conductivity");
             particlesAll.Columns.Add("Electrical_conductivity");
-            if (userLibraryData != null)
+            if (userSTDDbData != null)
             {
             {
                 for (int i = 0; i < particlesAll.Rows.Count; i++)
                 for (int i = 0; i < particlesAll.Rows.Count; i++)
                 {
                 {
-                    DataRow[] dr = userLibraryData.Select("STDId=" + particlesAll.Rows[i]["TypeId"].ToString());
+                    DataRow[] dr = userSTDDbData.Select("STDId=" + particlesAll.Rows[i]["TypeId"].ToString());
                     if (dr.Length > 0)
                     if (dr.Length > 0)
                     {
                     {
                         particlesAll.Rows[i]["Hardness"] = dr[0]["Hardness"].ToString();
                         particlesAll.Rows[i]["Hardness"] = dr[0]["Hardness"].ToString();
@@ -361,6 +371,7 @@ namespace OTSIncAReportGrids
                 #endregion
                 #endregion
                 return false;
                 return false;
             }
             }
+
             DataTable elementchemistry = Particledata.GetElementChemistry();
             DataTable elementchemistry = Particledata.GetElementChemistry();
             for (int i = 0; i < particlesAll.Rows.Count; i++)
             for (int i = 0; i < particlesAll.Rows.Count; i++)
             {
             {
@@ -373,10 +384,10 @@ namespace OTSIncAReportGrids
                 }
                 }
                 particlesAll.Rows[i]["Element"] = ConcatenatedString;
                 particlesAll.Rows[i]["Element"] = ConcatenatedString;
             }
             }
+            particlesAll.Columns.Add("XRayDataCount");
             if (sel != (int)SelItem.MergeParticles)
             if (sel != (int)SelItem.MergeParticles)
             {
             {
                 DataTable XRayData = Particledata.GetXRayData();
                 DataTable XRayData = Particledata.GetXRayData();
-                particlesAll.Columns.Add("XRayDataCount");
                 for (int i = 0; i < particlesAll.Rows.Count; i++)
                 for (int i = 0; i < particlesAll.Rows.Count; i++)
                 {
                 {
                     if (int.Parse(particlesAll.Rows[i]["particleId"].ToString()) > -1)
                     if (int.Parse(particlesAll.Rows[i]["particleId"].ToString()) > -1)
@@ -384,6 +395,8 @@ namespace OTSIncAReportGrids
                         particlesAll.Rows[i]["XRayDataCount"] = 0;
                         particlesAll.Rows[i]["XRayDataCount"] = 0;
                         string str = " XrayIndex= " + particlesAll.Rows[i]["particleId"].ToString() + " and fieldid = " + particlesAll.Rows[i]["fieldid"].ToString();
                         string str = " XrayIndex= " + particlesAll.Rows[i]["particleId"].ToString() + " and fieldid = " + particlesAll.Rows[i]["fieldid"].ToString();
                         DataRow[] drs = XRayData.Select(str);
                         DataRow[] drs = XRayData.Select(str);
+                        
+                        
                         uint xraycount = 0;
                         uint xraycount = 0;
                         if (drs != null)
                         if (drs != null)
                         {
                         {
@@ -404,127 +417,37 @@ namespace OTSIncAReportGrids
                     }
                     }
                 }
                 }
             }
             }
+            else
+            {
+                for (int i = 0; i < particlesAll.Rows.Count; i++)
+                {
+                    particlesAll.Rows[i]["XRayDataCount"] = 0;
+                    DataRow dgvr = particlesAll.Rows[i];
+                    var tPt = new ParticleData(ReportFun.resultFile.FilePath);
+                    uint[] Search_xray = new uint[2000];
+                    uint[] Analysis_xray = new uint[2000];
+                    tPt.GetXrayByParticleTagIDAndFieldID_ForMergeParticle(Convert.ToInt32(dgvr["particleId"]), Convert.ToInt32(dgvr["fieldid"]), out Search_xray, out Analysis_xray);
+                    uint xraycount = 0;
+                    for (int j = 0; j < 2000; j++)
+                    {
+                        xraycount += Analysis_xray[j];
+                    }
+                    particlesAll.Rows[i]["XRayDataCount"] = xraycount;
+                }
+            }
             return true;
             return true;
         }
         }
 
 
-        private void BindDataGridView()
+        private void DisplayGridView()
         {
         {
             dgV_ParticlesDevidePage.Visible = false;
             dgV_ParticlesDevidePage.Visible = false;
             if (m_frm_userprogress.IsDisposed)
             if (m_frm_userprogress.IsDisposed)
             {
             {
                 ProgressStart();
                 ProgressStart();
             }
             }
-            dgV_ParticlesDevidePage.Rows.Clear();
-            dgV_ParticlesDevidePage.Columns.Clear();
-
-            var startFun = m_ReportApp.m_RptConfigFile.Systype;
-
-            string str_DefaultComputedColName = "", str_ElementsColName = "";
-            DataSet ds = XMLoperate.GetXmlData(Application.StartupPath + RptConfigFile.m_ReportMgrParamFile, "XMLData");
-            DataTable dt = ds.Tables["Member"];
-            foreach (DataRow element in dt.Rows)
-            {
-                string RegName = element["RegName"].ToString();
-
-                if (RegName == "DefaultComputedColName")
-                {
-                    str_DefaultComputedColName = element["strValue"].ToString();
-                }
 
 
-                if (RegName == "ElementsColName")
-                {
-                    str_ElementsColName = element["strValue"].ToString();
-                }
-            }
-            string[] strs = str_DefaultComputedColName.Split(',');
-            Dictionary<string, string> keyValues = new Dictionary<string, string>() { };
-            keyValues.Add("rowid", table["str4"].ToString());
-            keyValues.Add("TypeName", table["str6"].ToString());
-            keyValues.Add("ParticleImage", table["str5"].ToString());
-            keyValues.Add("FieldId", "FieldId");
-            keyValues.Add("ParticleId", "ParticleId");
-            keyValues.Add("SEMPosX", "SEMPosX");
-            keyValues.Add("SEMPosY", "SEMPosY");
-            for (int i = 0; i < strs.Count(); i++)
-            {
-                if (strs[i] == "ParticleCoordinate")
-                {
-                    keyValues.Add("AbPosX", "PosX");
-                    keyValues.Add("AbPosY", "PosY");
-                }
-                if (strs[i] == "Area")
-                {
-                    keyValues.Add("Area", table["str21"].ToString());
-                }
-                if (strs[i] == "EquivalentCircleDiameter")
-                {
-                    keyValues.Add("Equivalent", table["str22"].ToString());
-                }
-                if (strs[i] == "MaxDiameter")
-                {
-                    keyValues.Add("DMAX", table["str23"].ToString());
-                }
-                if (strs[i] == "MinDiameter")
-                {
-                    keyValues.Add("DMIN", table["str24"].ToString());
-                }
-                if (strs[i] == "DiameterRatio")
-                {
-                    keyValues.Add("DiameterRatio", table["str25"].ToString());
-                }
-                if (strs[i] == "FerretDiameter")
-                {
-                    keyValues.Add("DFERET", table["str26"].ToString());
-                }
-                if (strs[i] == "PERP")
-                {
-                    keyValues.Add("DPERP", table["str27"].ToString());
-                }
-                if (strs[i] == "PERI")
-                {
-                    keyValues.Add("PERIMETER", table["str28"].ToString());
-                }
-                if (strs[i] == "INSCR")
-                {
-                    keyValues.Add("DINSCR", table["str29"].ToString());
-                }
-                if (strs[i] == "MEAN")
-                {
-                    keyValues.Add("DMEAN", table["str30"].ToString());
-                }
-                if (strs[i] == "ELONG")
-                {
-                    keyValues.Add("DELONG", table["str31"].ToString());
-                }
-                if (strs[i] == "ASPECT_ELONG")
-                {
-                    keyValues.Add("ASPECT_ELONG", table["str32"].ToString());
-                }
-                if (strs[i] == "Orientation")
-                {
-                    keyValues.Add("ORIENTATION", table["str33"].ToString());
-                }
-                if (strs[i] == "XRayDataCount")
-                {
-                    keyValues.Add("XRayDataCount", "XRay计数");
-                }
-                if (startFun == OTS_SysType_ID.TCCleannessA || startFun == OTS_SysType_ID.BatteryCleannessA)
-                {
-                    if (strs[i] == "Hardness")
-                    {
-                        keyValues.Add("Hardness", table["str34"].ToString());
-                    }
-                    if (strs[i] == "Density")
-                    {
-                        keyValues.Add("Density", table["str35"].ToString());
-                    }
-                    if (strs[i] == "Electrical_conductivity")
-                    {
-                        keyValues.Add("Electrical_conductivity", table["str36"].ToString());
-                    }
-                }
-            }
-            keyValues.Add("Element", "Element");
+            string str_ElementsColName = null;
+            Dictionary<string, string> keyValues = InitializeTable(ref str_ElementsColName);
             Dictionary<string, string>.Enumerator en = keyValues.GetEnumerator();
             Dictionary<string, string>.Enumerator en = keyValues.GetEnumerator();
             for (int irow = 0; irow < keyValues.Count; irow++)
             for (int irow = 0; irow < keyValues.Count; irow++)
             {
             {
@@ -535,6 +458,7 @@ namespace OTSIncAReportGrids
                         DataGridViewImageColumn iconColumn = new DataGridViewImageColumn();
                         DataGridViewImageColumn iconColumn = new DataGridViewImageColumn();
                         iconColumn.Name = en.Current.Key;
                         iconColumn.Name = en.Current.Key;
                         iconColumn.HeaderText = en.Current.Value;
                         iconColumn.HeaderText = en.Current.Value;
+                        iconColumn.ImageLayout = DataGridViewImageCellLayout.Zoom;
                         dgV_ParticlesDevidePage.Columns.Add(iconColumn);
                         dgV_ParticlesDevidePage.Columns.Add(iconColumn);
                     }
                     }
                     else if (en.Current.Key == "Element")
                     else if (en.Current.Key == "Element")
@@ -614,15 +538,17 @@ namespace OTSIncAReportGrids
                                     Bitmap tempbit = Particledata.ReadImageFile(imagePatht);
                                     Bitmap tempbit = Particledata.ReadImageFile(imagePatht);
                                     int pixw = tempbit.Width;
                                     int pixw = tempbit.Width;
                                     double xs = pixw / ScanFieldSize;
                                     double xs = pixw / ScanFieldSize;
-
+                                    OTS_X_AXIS_DIRECTION X_AXIS_DIRECTION = result.GetXAxisDirEnum();
+                                    OTS_Y_AXIS_DIRECTION Y_AXIS_DIRECTION = result.GetYAxisDirEnum();
                                     particleM = particleM + "," + subt;
                                     particleM = particleM + "," + subt;
-                                    Bitmap bmap = Particledata.GetBitmapForBig(subt, xs, result.FilePath, tempbit.Height, tempbit.Width);
+                                    Bitmap bmap = Particledata.GetBitmapForBig(subt, xs, result.FilePath, tempbit.Height, tempbit.Width, X_AXIS_DIRECTION,Y_AXIS_DIRECTION);
                                     if (bmap != null)
                                     if (bmap != null)
                                     {
                                     {
                                         string[] str = subt.Split(',');
                                         string[] str = subt.Split(',');
                                         bmap.Tag = new List<string>() { str[0].Split(':')[0], str[0].Split(':')[1], particles.Rows[i]["TypeId"].ToString() };
                                         bmap.Tag = new List<string>() { str[0].Split(':')[0], str[0].Split(':')[1], particles.Rows[i]["TypeId"].ToString() };
                                         dgV_ParticlesDevidePage.Rows[add_rowindex].Height = 150;
                                         dgV_ParticlesDevidePage.Rows[add_rowindex].Height = 150;
                                         dgV_ParticlesDevidePage.Rows[add_rowindex].Cells[k].Value = bmap;
                                         dgV_ParticlesDevidePage.Rows[add_rowindex].Cells[k].Value = bmap;
+                                        //dgV_ParticlesDevidePage.Rows[add_rowindex].Height= dgV_ParticlesDevidePage.Rows[add_rowindex].Height< bmap.Height ? bmap.Height: dgV_ParticlesDevidePage.Rows[add_rowindex].Height;
                                         dgV_ParticlesDevidePage.Rows[add_rowindex].Cells[k].Style.BackColor = Color.Azure;
                                         dgV_ParticlesDevidePage.Rows[add_rowindex].Cells[k].Style.BackColor = Color.Azure;
                                         dgV_ParticlesDevidePage.Rows[add_rowindex].DefaultCellStyle.ForeColor = Color.Chocolate;
                                         dgV_ParticlesDevidePage.Rows[add_rowindex].DefaultCellStyle.ForeColor = Color.Chocolate;
                                     }
                                     }
@@ -651,10 +577,6 @@ namespace OTSIncAReportGrids
                         {
                         {
                             double d = Convert.ToDouble(particles.Rows[i]["DMAX"]) / Convert.ToDouble(particles.Rows[i]["DMIN"]);
                             double d = Convert.ToDouble(particles.Rows[i]["DMAX"]) / Convert.ToDouble(particles.Rows[i]["DMIN"]);
                             dgV_ParticlesDevidePage.Rows[add_rowindex].Cells[k].Value = Math.Round(d, 2);
                             dgV_ParticlesDevidePage.Rows[add_rowindex].Cells[k].Value = Math.Round(d, 2);
-                        }
-                        if (en.Current.Key == "Element")
-                        {
-
                         }
                         }
                         if (enl.Current.Key == "ASPECT_ELONG")
                         if (enl.Current.Key == "ASPECT_ELONG")
                         {
                         {
@@ -704,8 +626,6 @@ namespace OTSIncAReportGrids
                         }
                         }
                         if (enl.Current.Key == "TypeName")
                         if (enl.Current.Key == "TypeName")
                         {
                         {
-
-
                             if (particles.Rows[i]["TypeId"].ToString() == "9")
                             if (particles.Rows[i]["TypeId"].ToString() == "9")
                             {
                             {
                                 dgV_ParticlesDevidePage.Rows[add_rowindex].Cells[k].Value = "Not Identified";
                                 dgV_ParticlesDevidePage.Rows[add_rowindex].Cells[k].Value = "Not Identified";
@@ -747,7 +667,121 @@ namespace OTSIncAReportGrids
             #endregion
             #endregion
             dgV_ParticlesDevidePage.Visible = true;
             dgV_ParticlesDevidePage.Visible = true;
         }
         }
+        Dictionary<string, string> InitializeTable(ref string str_ElementsColName)
+        {
+            dgV_ParticlesDevidePage.Rows.Clear();
+            dgV_ParticlesDevidePage.Columns.Clear();
+
+            var startFun = m_ReportApp.m_RptConfigFile.Systype;
+
+            string str_DefaultComputedColName = "";str_ElementsColName = "";
+            DataSet ds = XMLoperate.GetXmlData(Application.StartupPath + RptConfigFile.m_ReportMgrParamFile, "XMLData");
+            DataTable dt = ds.Tables["Member"];
+            foreach (DataRow element in dt.Rows)
+            {
+                string RegName = element["RegName"].ToString();
+
+                if (RegName == "DefaultComputedColName")
+                {
+                    str_DefaultComputedColName = element["strValue"].ToString();
+                }
 
 
+                if (RegName == "ElementsColName")
+                {
+                    str_ElementsColName = element["strValue"].ToString();
+                }
+            }
+            string[] strs = str_DefaultComputedColName.Split(',');
+            Dictionary<string, string> keyValues = new Dictionary<string, string>() { };
+            keyValues.Add("rowid", table["str4"].ToString());
+            keyValues.Add("TypeName", table["str6"].ToString());
+            keyValues.Add("ParticleImage", table["str5"].ToString());
+            keyValues.Add("FieldId", "FieldId");
+            keyValues.Add("ParticleId", "ParticleId");
+            keyValues.Add("SEMPosX", "SEMPosX");
+            keyValues.Add("SEMPosY", "SEMPosY");
+            for (int i = 0; i < strs.Count(); i++)
+            {
+                if (strs[i] == "ParticleCoordinate")
+                {
+                    keyValues.Add("AbPosX", "PosX");
+                    keyValues.Add("AbPosY", "PosY");
+                }
+                if (strs[i] == "Area")
+                {
+                    keyValues.Add("Area", table["str21"].ToString());
+                }
+                if (strs[i] == "EquivalentCircleDiameter")
+                {
+                    keyValues.Add("Equivalent", table["str22"].ToString());
+                }
+                if (strs[i] == "MaxDiameter")
+                {
+                    keyValues.Add("DMAX", table["str23"].ToString());
+                }
+                if (strs[i] == "MinDiameter")
+                {
+                    keyValues.Add("DMIN", table["str24"].ToString());
+                }
+                if (strs[i] == "DiameterRatio")
+                {
+                    keyValues.Add("DiameterRatio", table["str25"].ToString());
+                }
+                if (strs[i] == "FerretDiameter")
+                {
+                    keyValues.Add("DFERET", table["str26"].ToString());
+                }
+                if (strs[i] == "PERP")
+                {
+                    keyValues.Add("DPERP", table["str27"].ToString());
+                }
+                if (strs[i] == "PERI")
+                {
+                    keyValues.Add("PERIMETER", table["str28"].ToString());
+                }
+                if (strs[i] == "INSCR")
+                {
+                    keyValues.Add("DINSCR", table["str29"].ToString());
+                }
+                if (strs[i] == "MEAN")
+                {
+                    keyValues.Add("DMEAN", table["str30"].ToString());
+                }
+                if (strs[i] == "ELONG")
+                {
+                    keyValues.Add("DELONG", table["str31"].ToString());
+                }
+                if (strs[i] == "ASPECT_ELONG")
+                {
+                    keyValues.Add("ASPECT_ELONG", table["str32"].ToString());
+                }
+                if (strs[i] == "Orientation")
+                {
+                    keyValues.Add("ORIENTATION", table["str33"].ToString());
+                }
+                if (strs[i] == "XRayDataCount")
+                {
+                    keyValues.Add("XRayDataCount", "XRay计数");
+                }
+                if (startFun == OTS_SysType_ID.TCCleannessA || startFun == OTS_SysType_ID.BatteryCleannessA)
+                {
+                    if (strs[i] == "Hardness")
+                    {
+                        keyValues.Add("Hardness", table["str34"].ToString());
+                    }
+                    if (strs[i] == "Density")
+                    {
+                        keyValues.Add("Density", table["str35"].ToString());
+                    }
+                    if (strs[i] == "Electrical_conductivity")
+                    {
+                        keyValues.Add("Electrical_conductivity", table["str36"].ToString());
+                    }
+                }
+            }
+            keyValues.Add("Element", "Element");
+            return keyValues;
+        }
 
 
 
 
         /// <summary>
         /// <summary>
@@ -1275,7 +1309,7 @@ namespace OTSIncAReportGrids
                 ProgressStart();
                 ProgressStart();
             }
             }
 
 
-            UpdateTable();
+            UpdateDataGrid();
 
 
             lnkFirst_Click(null, null);
             lnkFirst_Click(null, null);
             SetDataGridViewStyle();
             SetDataGridViewStyle();
@@ -1304,7 +1338,7 @@ namespace OTSIncAReportGrids
         /// </summary>
         /// </summary>
         private void DrawControl(bool callEvent)
         private void DrawControl(bool callEvent)
         {
         {
-            BindDataGridView();
+            DisplayGridView();
             lblTotalCount.Text = RecordCount.ToString();
             lblTotalCount.Text = RecordCount.ToString();
             lblPageCount.Text = PageCount.ToString();
             lblPageCount.Text = PageCount.ToString();
             txtPageNum.Text = PageIndex.ToString();
             txtPageNum.Text = PageIndex.ToString();
@@ -1863,7 +1897,7 @@ namespace OTSIncAReportGrids
 
 
 
 
                 
                 
-                UpdateTable();
+                UpdateDataGrid();
                 lnkFirst_Click(null, null);
                 lnkFirst_Click(null, null);
                 SetDataGridViewStyle();
                 SetDataGridViewStyle();
                 DataTable table = GetClassificationOfAllParticles();
                 DataTable table = GetClassificationOfAllParticles();
@@ -1947,7 +1981,7 @@ namespace OTSIncAReportGrids
                         {
                         {
                             if (i_ls_fieldid == item.FieldId && i_ls_particleid == item.ParticleId)
                             if (i_ls_fieldid == item.FieldId && i_ls_particleid == item.ParticleId)
                             {
                             {
-                                if (DeleteParticlesFromLibrary(item.ParticleId, item.FieldId))
+                                if (DeleteParticlesFromSTDDb(item.ParticleId, item.FieldId))
                                 {
                                 {
                                     for (int i = 0; i < particlesAll.Rows.Count; i++)
                                     for (int i = 0; i < particlesAll.Rows.Count; i++)
                                     {
                                     {
@@ -1990,13 +2024,13 @@ namespace OTSIncAReportGrids
                     var _Control_DrawDistrbutionImageAndBSE = new OTSIncAReportGraph.Controls.Control_DrawDistrbutionImageAndBSE(m_ReportApp);
                     var _Control_DrawDistrbutionImageAndBSE = new OTSIncAReportGraph.Controls.Control_DrawDistrbutionImageAndBSE(m_ReportApp);
                     foreach (var p in list_Part)
                     foreach (var p in list_Part)
                     {
                     {
-                        _Control_DrawDistrbutionImageAndBSE.DeleteParticlesFromLibrary(p.ParticleId, p.FieldId);
+                        _Control_DrawDistrbutionImageAndBSE.DeleteParticlesFromSTDDb(p.ParticleId, p.FieldId);
                     }
                     }
                 }
                 }
             }
             }
         }
         }
 
 
-        private bool DeleteParticlesFromLibrary(int in_clr_tagid, int in_clr_fieldid)
+        private bool DeleteParticlesFromSTDDb(int in_clr_tagid, int in_clr_fieldid)
         {
         {
             bool DoesItExist = false;
             bool DoesItExist = false;
             for (int i = 1; i < 201; i++)
             for (int i = 1; i < 201; i++)
@@ -2354,37 +2388,7 @@ namespace OTSIncAReportGrids
                 }
                 }
             }
             }
         }
         }
-        /// <summary>
-        /// 去除拼接颗粒组成颗粒
-        /// </summary>
-        /// <param name="dataTable_Particle"></param>
-        /// <param name="dataTable_MergeParticles"></param>
-        public void RemoveMergeParticles(ref DataTable dataTable_Particle, DataTable dataTable_MergeParticles)
-        {
-            foreach (DataRow row in dataTable_Particle.Rows)
-            {
-                foreach (DataRow MergeParticlesRow in dataTable_MergeParticles.Rows)
-                {
-                    string subt = MergeParticlesRow["SubParticles"].ToString();
-                    string[] sub = subt.Split(',');
-                    if (row.RowState == DataRowState.Deleted)
-                    {
-                        break;
-                    }
-                    if (row["fieldid"].ToString() == Convert.ToString(sub[0]).Split(':')[0] && row["ParticleId"].ToString() == Convert.ToString(sub[0]).Split(':')[1])
-                    {
-                        row.Delete();
-                        break;
-                    }
-                    if (row["fieldid"].ToString() == Convert.ToString(sub[1]).Split(':')[0] && row["ParticleId"].ToString() == Convert.ToString(sub[1]).Split(':')[1])
-                    {
-                        row.Delete();
-                        break; ;
-                    }
-                }
-            }
-            dataTable_Particle.AcceptChanges();
-        }
+        
 
 
         private void btn_showconfig_Click(object sender, EventArgs e)
         private void btn_showconfig_Click(object sender, EventArgs e)
         {
         {
@@ -2418,7 +2422,7 @@ namespace OTSIncAReportGrids
             {
             {
                 dgV_ParticlesDevidePage.Rows.Clear();
                 dgV_ParticlesDevidePage.Rows.Clear();
                 dgV_ParticlesDevidePage.Columns.Clear();
                 dgV_ParticlesDevidePage.Columns.Clear();
-                BindDataGridView();
+                DisplayGridView();
                 SetDataGridViewStyle();
                 SetDataGridViewStyle();
             }
             }
         }
         }
@@ -2458,13 +2462,11 @@ namespace OTSIncAReportGrids
             return Particleslist_selecttodisplay;
             return Particleslist_selecttodisplay;
         }
         }
 
 
+
+
         private void dgV_ParticlesDevidePage_MouseUp(object sender, MouseEventArgs e)
         private void dgV_ParticlesDevidePage_MouseUp(object sender, MouseEventArgs e)
         {
         {
             int sel = m_ReportApp.m_conditionChoose.m_conditionData.GetComboDownListIndexByItemName(OTSIncAReportApp.OTSSampleReportInfo.OTS_REPORT_PROP_GRID_ITEMS.PARTICE_LIST);
             int sel = m_ReportApp.m_conditionChoose.m_conditionData.GetComboDownListIndexByItemName(OTSIncAReportApp.OTSSampleReportInfo.OTS_REPORT_PROP_GRID_ITEMS.PARTICE_LIST);
-            if (sel == (int)SelItem.MergeParticles)
-            {
-                return;
-            }
             ToolStripMenuItem_SimilarityReclassification.Enabled = false;
             ToolStripMenuItem_SimilarityReclassification.Enabled = false;
             var SelectRows = dgV_ParticlesDevidePage.SelectedRows;
             var SelectRows = dgV_ParticlesDevidePage.SelectedRows;
             if (SelectRows.Count != 0)
             if (SelectRows.Count != 0)
@@ -2473,77 +2475,46 @@ namespace OTSIncAReportGrids
                 {
                 {
                     DataGridViewRow dgvr = SelectRows[0];
                     DataGridViewRow dgvr = SelectRows[0];
                     Bitmap ls_bp = (Bitmap)dgvr.Cells[2].Value;
                     Bitmap ls_bp = (Bitmap)dgvr.Cells[2].Value;
-                    List<string> list_str = (List<string>)ls_bp.Tag;
+                    
+                    
+                    
                     uint[] Search_xray = new uint[2000];
                     uint[] Search_xray = new uint[2000];
                     uint[] Analysis_xray = new uint[2000];
                     uint[] Analysis_xray = new uint[2000];
                     int i_xray_id = 0;
                     int i_xray_id = 0;
                     List<Element> list_celementchemistryclr = new List<Element>();
                     List<Element> list_celementchemistryclr = new List<Element>();
-                    ReportFun.GetXrayByParticleTagIDAndFieldID_ForDrawDistrbutionImageAndBSE(Convert.ToInt32(dgvr.Cells["particleId"].Value), Convert.ToInt32(dgvr.Cells["fieldid"].Value), out Search_xray, out Analysis_xray, out i_xray_id, out list_celementchemistryclr);
-
-                    List<ShowElementInfo> list_showelementinfo = new List<ShowElementInfo>();
-                    for (int i = 0; i < list_celementchemistryclr.Count; i++)
+                    Particle particle=new Particle();
+                    var tPt = new ParticleData(ReportFun.resultFile.FilePath);
+                    if (sel == (int)SelItem.MergeParticles)
                     {
                     {
-                        ShowElementInfo ls_sei = new ShowElementInfo();
-                        ls_sei.ElementName = list_celementchemistryclr[i].Name;
-                        ls_sei.Percentage = list_celementchemistryclr[i].Percentage;
-                        ls_sei.dKF = Convert.ToDouble(CListPeriodic.GetPeriodicByEleName(ls_sei.ElementName).K_Peak);
-                        double de_sx2 = 0;
-                        if (CListPeriodic.GetPeriodicByEleName(ls_sei.ElementName).L_Peak == "" || CListPeriodic.GetPeriodicByEleName(ls_sei.ElementName).L_Peak == "-")
-                        {
-                            de_sx2 = 0;
-                        }
-                        else
-                        {
-                            de_sx2 = Convert.ToDouble(CListPeriodic.GetPeriodicByEleName(ls_sei.ElementName).L_Peak);
-                        }
-                        ls_sei.dLF = de_sx2;
-                        list_showelementinfo.Add(ls_sei);
+                        particle = tPt.GetXrayByParticleTagIDAndFieldID_ForMergeParticle(Convert.ToInt32(dgvr.Cells["particleId"].Value), Convert.ToInt32(dgvr.Cells["fieldid"].Value), out Search_xray, out Analysis_xray);
+                        list_celementchemistryclr = particle.ElementList;
+                    }
+                    else
+                    {
+                        particle = ReportFun.GetXrayByParticleTagIDAndFieldID_ForDrawDistrbutionImageAndBSE(Convert.ToInt32(dgvr.Cells["particleId"].Value), Convert.ToInt32(dgvr.Cells["fieldid"].Value), out Search_xray, out Analysis_xray, out i_xray_id, out list_celementchemistryclr);
                     }
                     }
 
 
-
-                    list_showelementinfo.Sort((p1, p2) => p2.Percentage.CompareTo(p1.Percentage));
+                    List<ShowElementInfo> list_showelementinfo = tPt.GetShowElementInfos_ForMergeParticle(list_celementchemistryclr);
                     string str_IncAName = "";
                     string str_IncAName = "";
                     str_IncAName = Convert.ToString(dgvr.Cells[1].Value);
                     str_IncAName = Convert.ToString(dgvr.Cells[1].Value);
-                    Particle particle = result.List_OTSField.Find(x => x.FieldID == Convert.ToInt32(dgvr.Cells["fieldid"].Value)).ParticleList.Find(x => x.ParticleId == Convert.ToInt32(dgvr.Cells["particleId"].Value));
                     if (particle == null)
                     if (particle == null)
                     {
                     {
                         return;
                         return;
                     }
                     }
                     control_XRayTable1.SetParticleInfo("Area:" + Math.Round(particle.Area, 2) + "  " + "DMAX:" + Math.Round(particle.DMAX, 2) + "  " + "DELONG:" + Math.Round(particle.DELONG, 2) + "  " + "DFERET:" + Math.Round(particle.DFERET, 2) + "  " + "DINSCR:" + Math.Round(particle.DINSCR, 2) + "\n" + "DMEAN:" + Math.Round(particle.DMEAN, 2) + "  " + "DMIN:" + Math.Round(particle.DMIN, 2) + "  " + "DPERP:" + Math.Round(particle.DPERP, 2) + "  " + "ORIENTATION:" + Math.Round(particle.ORIENTATION, 2) + "  " + "PERIMETER:" + Math.Round(particle.PERIMETER, 2));
                     control_XRayTable1.SetParticleInfo("Area:" + Math.Round(particle.Area, 2) + "  " + "DMAX:" + Math.Round(particle.DMAX, 2) + "  " + "DELONG:" + Math.Round(particle.DELONG, 2) + "  " + "DFERET:" + Math.Round(particle.DFERET, 2) + "  " + "DINSCR:" + Math.Round(particle.DINSCR, 2) + "\n" + "DMEAN:" + Math.Round(particle.DMEAN, 2) + "  " + "DMIN:" + Math.Round(particle.DMIN, 2) + "  " + "DPERP:" + Math.Round(particle.DPERP, 2) + "  " + "ORIENTATION:" + Math.Round(particle.ORIENTATION, 2) + "  " + "PERIMETER:" + Math.Round(particle.PERIMETER, 2));
-
                     control_XRayTable1.Visible = true;
                     control_XRayTable1.Visible = true;
                     control_XRayTable1.SetXRayShowLineValue(null, Analysis_xray, list_showelementinfo);
                     control_XRayTable1.SetXRayShowLineValue(null, Analysis_xray, list_showelementinfo);
-                    //颗粒国标信息
                     control_XRayTable1.GBInfoStr = "";
                     control_XRayTable1.GBInfoStr = "";
-                    control_XRayTable1.MaterialName = str_IncAName;//杂夹物
-
+                    control_XRayTable1.MaterialName = str_IncAName;
                     control_XRayTable1.List_ShowElementInfo = list_showelementinfo;
                     control_XRayTable1.List_ShowElementInfo = list_showelementinfo;
 
 
-                    string str = " particleId= " + dgvr.Cells["particleId"].Value.ToString() + " and fieldid = " + dgvr.Cells["fieldid"].Value.ToString();
-                    DataRow[] drs = particles.Select(str);
-                    if (drs.Length > 0)
+                    if (sel != (int)SelItem.MergeParticles)
                     {
                     {
                         Rectangle rectangle = new Rectangle() { X = Convert.ToInt32(particle.RectLeft), Y = Convert.ToInt32(particle.RectTop), Width = Convert.ToInt32(particle.RectWidth), Height = Convert.ToInt32(particle.RectHeight) };
                         Rectangle rectangle = new Rectangle() { X = Convert.ToInt32(particle.RectLeft), Y = Convert.ToInt32(particle.RectTop), Width = Convert.ToInt32(particle.RectWidth), Height = Convert.ToInt32(particle.RectHeight) };
-                        Bitmap dpImage = new Bitmap(result.GetImageWidth(), result.GetImageHeight());
-                        using (Graphics graphics = Graphics.FromImage(dpImage))
-                        {
-                            graphics.Clear(Color.White); // 清除位图背景为白色
-                        }
+                        Bitmap dpImage = ReportFun.GetBlackAndWhiteImage(particle);
                         string filePath = result.FilePath + "\\FIELD_FILES\\";
                         string filePath = result.FilePath + "\\FIELD_FILES\\";
                         string imagePath = filePath + "Field" + dgvr.Cells["fieldid"].Value.ToString() + ".bmp";
                         string imagePath = filePath + "Field" + dgvr.Cells["fieldid"].Value.ToString() + ".bmp";
                         Bitmap m_originalImage = DrawFunction.ReadImageFile(imagePath);
                         Bitmap m_originalImage = DrawFunction.ReadImageFile(imagePath);
-
-                        foreach (Segment seg in particle.SegmentList)
-                        {
-                            int f_length = seg.Length;
-                            for (int m = 0; m < f_length; m++)
-                            {
-                                int lsjs_x = seg.Start + m;
-                                int lsjs_y = seg.Height;
-                                var pixelColor = m_originalImage.GetPixel(lsjs_x, lsjs_y);
-                                dpImage.SetPixel(lsjs_x, lsjs_y, Color.Black);
-                            }
-                        }
                         Bitmap bmap = Particledata.GetBitmapByParticle(dpImage, rectangle);
                         Bitmap bmap = Particledata.GetBitmapByParticle(dpImage, rectangle);
                         Bitmap bmap1 = Particledata.GetBitmapByParticle(m_originalImage, rectangle);
                         Bitmap bmap1 = Particledata.GetBitmapByParticle(m_originalImage, rectangle);
                         control_XRayTable1.SetBitmapOfPictureBox(bmap1, bmap);
                         control_XRayTable1.SetBitmapOfPictureBox(bmap1, bmap);
@@ -2551,7 +2522,21 @@ namespace OTSIncAReportGrids
                     }
                     }
                     else
                     else
                     {
                     {
-                        control_XRayTable1.Visible = false;
+                        double ScanFieldSize = result.GetScanFieldSizeX();
+                        string filePatht = result.FilePath + "\\FIELD_FILES\\";
+                        string str = " particleId= " + dgvr.Cells["particleId"].Value.ToString() + " and fieldid = " + dgvr.Cells["fieldid"].Value.ToString();
+                        DataRow[] drs = particles.Select(str);
+                        DataRow row = drs[0];
+                        string subt = row["SubParticles"].ToString();
+                        string imagePatht = filePatht + "Field" + subt.Split(',')[0].Split(':')[0].ToString() + ".bmp";
+                        Bitmap tempbit = Particledata.ReadImageFile(imagePatht);
+                        int pixw = tempbit.Width;
+                        double xs = pixw / ScanFieldSize;
+                        OTS_X_AXIS_DIRECTION X_AXIS_DIRECTION = result.GetXAxisDirEnum();
+                        OTS_Y_AXIS_DIRECTION Y_AXIS_DIRECTION = result.GetYAxisDirEnum();
+                        Bitmap bp= Particledata.GetBitmapForBigBlackAndWhiteImage(subt, xs, result.FilePath, tempbit.Height, tempbit.Width, X_AXIS_DIRECTION, Y_AXIS_DIRECTION);  
+                        control_XRayTable1.SetBitmapOfPictureBox(ls_bp,bp);
+                        Invalidate();
                     }
                     }
                     ToolStripMenuItem_SimilarityReclassification.Enabled = true;
                     ToolStripMenuItem_SimilarityReclassification.Enabled = true;
                 }
                 }
@@ -2580,13 +2565,18 @@ namespace OTSIncAReportGrids
         private void tbx_Type_Click(object sender, EventArgs e)
         private void tbx_Type_Click(object sender, EventArgs e)
         {
         {
             ParticleClassificationSelect particleClassificationSelect = new ParticleClassificationSelect(this, tbx_Type.Text);
             ParticleClassificationSelect particleClassificationSelect = new ParticleClassificationSelect(this, tbx_Type.Text);
+            
             DialogResult result = particleClassificationSelect.ShowDialog();
             DialogResult result = particleClassificationSelect.ShowDialog();
+            
+            
             if (result == DialogResult.OK)
             if (result == DialogResult.OK)
             {
             {
                 condition = "";
                 condition = "";
                 tbx_Type.Text = particleClassificationSelect.ParticleClassificationSelected;
                 tbx_Type.Text = particleClassificationSelect.ParticleClassificationSelected;
                 string[] tr = tbx_Type.Text.Split(',');
                 string[] tr = tbx_Type.Text.Split(',');
                 condition += " and (";
                 condition += " and (";
+                
+                
                 for (int i = 0; i < tr.Length; i++)
                 for (int i = 0; i < tr.Length; i++)
                 {
                 {
                     if (i == 0)
                     if (i == 0)
@@ -2605,7 +2595,7 @@ namespace OTSIncAReportGrids
                     ProgressStart();
                     ProgressStart();
                 }
                 }
 
 
-                UpdateTable();
+                UpdateDataGrid();
                 lnkFirst_Click(null, null);
                 lnkFirst_Click(null, null);
                 SetDataGridViewStyle();
                 SetDataGridViewStyle();
             }
             }
@@ -2681,7 +2671,7 @@ namespace OTSIncAReportGrids
             DialogResult result3 = Form_listOfSimilarParticles.ShowDialog();
             DialogResult result3 = Form_listOfSimilarParticles.ShowDialog();
             if (result3 == DialogResult.OK)
             if (result3 == DialogResult.OK)
             {
             {
-                UpdateTable();
+                UpdateDataGrid();
                 lnkFirst_Click(null, null);
                 lnkFirst_Click(null, null);
                 SetDataGridViewStyle();
                 SetDataGridViewStyle();
                 DataTable table = GetClassificationOfAllParticles();
                 DataTable table = GetClassificationOfAllParticles();

+ 11 - 36
OTSIncAReportApp/1-UI/Control_Grids/ParticlesSizeGrid.cs

@@ -73,8 +73,6 @@ namespace OTSIncAReportGrids
             OTSGridView gridView = new OTSGridView();
             OTSGridView gridView = new OTSGridView();
             OTSIncAReportApp.DataOperation.DataAccess.ParticleData particledata = new OTSIncAReportApp.DataOperation.DataAccess.ParticleData(path);
             OTSIncAReportApp.DataOperation.DataAccess.ParticleData particledata = new OTSIncAReportApp.DataOperation.DataAccess.ParticleData(path);
 
 
-
-
             DataTable dtp = particledata.GetParticleAll("");
             DataTable dtp = particledata.GetParticleAll("");
             string sizestr = null;
             string sizestr = null;
             string con = "";
             string con = "";
@@ -164,6 +162,7 @@ namespace OTSIncAReportGrids
                 gridView.Columns.Add(colid[i], colname[i]);
                 gridView.Columns.Add(colid[i], colname[i]);
                 if (!m_dt.Columns.Contains(colid[i]))
                 if (!m_dt.Columns.Contains(colid[i]))
                     m_dt.Columns.Add(colid[i]);
                     m_dt.Columns.Add(colid[i]);
+                gridView.Columns[i].ValueType = typeof(System.Int32);
             }
             }
             if (!m_dt.Columns.Contains("Class"))
             if (!m_dt.Columns.Contains("Class"))
                 m_dt.Columns.Add("Class");
                 m_dt.Columns.Add("Class");
@@ -284,11 +283,18 @@ namespace OTSIncAReportGrids
             gridView.Rows[a1].Cells[1].Value = "Sum";
             gridView.Rows[a1].Cells[1].Value = "Sum";
             for(int j=0;j< gridView.Rows.Count-2;j++)
             for(int j=0;j< gridView.Rows.Count-2;j++)
             {
             {
-                for(int k=4;k< gridView.Columns.Count;k++)
+                for(int k=3;k< gridView.Columns.Count;k++)
                 {
                 {
                     if (gridView.Rows[a1].Cells[k].Value == null)
                     if (gridView.Rows[a1].Cells[k].Value == null)
                         gridView.Rows[a1].Cells[k].Value = 0;
                         gridView.Rows[a1].Cells[k].Value = 0;
-                    gridView.Rows[a1].Cells[k].Value = Convert.ToInt32(gridView.Rows[a1].Cells[k].Value)+ Convert.ToInt32(gridView.Rows[j].Cells[k].Value);
+                    if (k == 5)
+                    {
+                        gridView.Rows[a1].Cells[k].Value = Convert.ToInt64(gridView.Rows[a1].Cells[k].Value) + Convert.ToInt64(gridView.Rows[j].Cells[k].Value);
+                    }
+                    else
+                    {
+                        gridView.Rows[a1].Cells[k].Value = Convert.ToInt32(gridView.Rows[a1].Cells[k].Value) + Convert.ToInt32(gridView.Rows[j].Cells[k].Value);
+                    }
                 }
                 }
             }
             }
             list_table_Point.Add(SetDataGridViewStyle(gridView));
             list_table_Point.Add(SetDataGridViewStyle(gridView));
@@ -366,8 +372,6 @@ namespace OTSIncAReportGrids
 			gridheight = gridheight + gridView.RowCount * 30 + 5;
 			gridheight = gridheight + gridView.RowCount * 30 + 5;
             gridwidth = gridwidth + gridView.ColumnCount * 100;
             gridwidth = gridwidth + gridView.ColumnCount * 100;
 			gridView.TabIndex = 0;
 			gridView.TabIndex = 0;
-
-            gridView.SortCompare += Gview_gz_SortCompare;
             gridView.Sorted += Gview_gz_Sorted;
             gridView.Sorted += Gview_gz_Sorted;
             //先设置一下头的高度,否则会太矮不好看
             //先设置一下头的高度,否则会太矮不好看
             gridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing;
             gridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing;
@@ -664,41 +668,12 @@ namespace OTSIncAReportGrids
             }
             }
         }
         }
 
 
-        private void Gview_gz_SortCompare(object sender, DataGridViewSortCompareEventArgs e)
-        {
-            //排序中
-            if (((OTSGridView)sender).Rows[e.RowIndex1].Tag != null && ((OTSGridView)sender).Rows[e.RowIndex1].Tag.ToString() == "统计行")
-            {
-                //ROW1>ROW2  
-                e.SortResult = 1;
-                if (((OTSGridView)sender).SortOrder == SortOrder.Descending)
-                    e.SortResult = -1;
-                e.Handled = true;
-                return;
-            }
-
-            if (((OTSGridView)sender).Rows[e.RowIndex2].Tag != null && ((OTSGridView)sender).Rows[e.RowIndex2].Tag.ToString() == "统计行")
-            {
-                //ROW1<ROW2  
-                e.SortResult = -1;
-                if (((OTSGridView)sender).SortOrder == SortOrder.Descending)
-                    e.SortResult = 1;
-                e.Handled = true;
-                return;
-            }
-        }
-
         private void Gview_gz_Sorted(object sender, EventArgs e)
         private void Gview_gz_Sorted(object sender, EventArgs e)
         {
         {
             //排序完成,重新设置序号
             //排序完成,重新设置序号
             for (int i = 0; i < ((OTSGridView)sender).Rows.Count; i++)
             for (int i = 0; i < ((OTSGridView)sender).Rows.Count; i++)
             {
             {
-                if (((OTSGridView)sender).Rows[i].Tag != null && ((OTSGridView)sender).Rows[i].Tag.ToString() == "统计行")
-                { }
-                else
-                {
-                    ((OTSGridView)sender).Rows[i].Cells[0].Value = i.ToString();
-                }
+                ((OTSGridView)sender).Rows[i].Cells[0].Value = (i+1).ToString();
             }
             }
         }
         }
         #endregion
         #endregion

+ 30 - 4
OTSIncAReportApp/1-UI/frmMeasureRstMgr.cs

@@ -1,3 +1,6 @@
+using DevExpress.CodeParser;
+using DevExpress.XtraCharts.Native;
+using DevExpress.XtraEditors.Filtering;
 using Microsoft.Office.Core;
 using Microsoft.Office.Core;
 using OTS.WinFormsUI.Docking;
 using OTS.WinFormsUI.Docking;
 using OTSCLRINTERFACE;
 using OTSCLRINTERFACE;
@@ -16,6 +19,7 @@ using System.IO;
 using System.Runtime.InteropServices;
 using System.Runtime.InteropServices;
 using System.Text.RegularExpressions;
 using System.Text.RegularExpressions;
 using System.Windows.Forms;
 using System.Windows.Forms;
+using static DevExpress.CodeParser.CodeStyle.Formatting.Rules.LineBreaks;
 using static DevExpress.XtraCharts.GLGraphics.GL;
 using static DevExpress.XtraCharts.GLGraphics.GL;
 using static OTSDataType.otsdataconst;
 using static OTSDataType.otsdataconst;
 
 
@@ -770,17 +774,18 @@ namespace OTSIncAReportApp
         }
         }
         public bool SaveMergedParticles(List<COTSParticleClr> mergedParts,string dbfile)
         public bool SaveMergedParticles(List<COTSParticleClr> mergedParts,string dbfile)
         {
         {
-
+            CheckExistGroupfield(dbfile);
             CIncAFileMgr pDBFileMgr = new CIncAFileMgr(dbfile);
             CIncAFileMgr pDBFileMgr = new CIncAFileMgr(dbfile);
             var mergedpartdb = pDBFileMgr.GetMergedParticleDB();
             var mergedpartdb = pDBFileMgr.GetMergedParticleDB();
             mergedpartdb.RemoveAllRows();
             mergedpartdb.RemoveAllRows();
 
 
-            foreach (COTSParticleClr part in mergedParts)
+            
+            CPosXrayDBMgr pXrayDBMgr = pDBFileMgr.GetPosXrayDBMgr();
+            CElementChemistryDB xraydb = pXrayDBMgr.GetElementChemistryDB();foreach (COTSParticleClr part in mergedParts)
             {
             {
                 mergedpartdb.SaveAParticle(part, part.GetXray(), (Point)part.GetSEMPos());
                 mergedpartdb.SaveAParticle(part, part.GetXray(), (Point)part.GetSEMPos());
+                xraydb.DeleteElementChemistryById(part.GetFieldId(), part.GetParticleId());
             }
             }
-            CPosXrayDBMgr pXrayDBMgr = pDBFileMgr.GetPosXrayDBMgr();
-            CElementChemistryDB xraydb = pXrayDBMgr.GetElementChemistryDB();
             List<CPosXrayClr> ches = new List<CPosXrayClr>();
             List<CPosXrayClr> ches = new List<CPosXrayClr>();
             foreach (COTSParticleClr part in mergedParts)
             foreach (COTSParticleClr part in mergedParts)
             {
             {
@@ -789,6 +794,27 @@ namespace OTSIncAReportApp
             xraydb.SaveElementChemistriesList_Batch(ches);
             xraydb.SaveElementChemistriesList_Batch(ches);
             return true;
             return true;
         }
         }
+        void CheckExistGroupfield(string dbfile)
+        {
+            DataOperation.DataAccess.SqlHelper dbHelper = new DataOperation.DataAccess.SqlHelper("data source='" + dbfile + "'");
+            System.Data.DataTable DT = null;
+            string sql = "select * from MergedParticleInfo";
+            DT = dbHelper.ExecuteDataTable(sql, null);
+            bool fg = false;
+            foreach (System.Data.DataColumn l in DT.Columns)
+            {
+                if (l.ColumnName == "GroupId"){ fg = true; break; }
+            }
+            if (!fg)
+            {
+                List<string> sqll = new List<string>();
+                sqll.Add("ALTER TABLE MergedParticleInfo ADD COLUMN GroupId INTEGER");
+                sqll.Add("ALTER TABLE MergedParticleInfo ADD COLUMN GroupName STRING");
+                sqll.Add("ALTER TABLE MergedParticleInfo ADD COLUMN GroupColor STRING");
+                dbHelper.ExecuteMultipleStatementsWithTransaction(sqll);
+            }
+        }
+
 
 
         private void ToolStripMenuItem_Zeroelementprocess_Click(object sender, EventArgs e)
         private void ToolStripMenuItem_Zeroelementprocess_Click(object sender, EventArgs e)
         {
         {

+ 1 - 1
OTSIncAReportApp/1-UI/frmReMeasure.cs

@@ -468,7 +468,7 @@ namespace OTSIncAReportApp
             }
             }
             string str_libraryName = ReportFun.resultFile.GetSTDName();
             string str_libraryName = ReportFun.resultFile.GetSTDName();
             DataTable userLibraryData = new DataTable();
             DataTable userLibraryData = new DataTable();
-            UserLibraryData userLibrary = new UserLibraryData(str_libraryName, ReportFun.resultFile.FilePath+"\\");
+            UserSTDDbData userLibrary = new UserSTDDbData(str_libraryName, ReportFun.resultFile.FilePath+"\\");
             if (userLibrary.GetSqlHelper() != null)
             if (userLibrary.GetSqlHelper() != null)
             {
             {
                 userLibraryData = userLibrary.GetSubAttributeFromDatabase();
                 userLibraryData = userLibrary.GetSubAttributeFromDatabase();

+ 460 - 82
OTSIncAReportApp/3-ServiceCenter/DataOperation/DataAccess/ParticleData.cs

@@ -1,6 +1,11 @@
-using OTSCommon.DBOperate;
+using DevExpress.Charts.Native;
+using DevExpress.XtraDiagram.Bars;
+using DevExpress.XtraEditors.Filtering;
+using OTSCommon.DBOperate;
 using OTSCommon.DBOperate.Model;
 using OTSCommon.DBOperate.Model;
 using OTSIncAReportApp._1_UI.OTSReportExport.DataIntegration;
 using OTSIncAReportApp._1_UI.OTSReportExport.DataIntegration;
+using OTSIncAReportGraph.Controls;
+using OTSPeriodicTable;
 using System;
 using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Data;
 using System.Data;
@@ -9,7 +14,6 @@ using System.Drawing;
 using System.Drawing.Imaging;
 using System.Drawing.Imaging;
 using System.IO;
 using System.IO;
 using System.Linq;
 using System.Linq;
-using static DevExpress.XtraEditors.Mask.Design.MaskSettingsForm.DesignInfo.MaskManagerInfo;
 using static OTSDataType.otsdataconst;
 using static OTSDataType.otsdataconst;
 using static OTSIncAReportApp.OTSReport_Export;
 using static OTSIncAReportApp.OTSReport_Export;
 
 
@@ -92,16 +96,50 @@ namespace OTSIncAReportApp.DataOperation.DataAccess
         /// </summary>
         /// </summary>
         /// <param name="model">Feature</param>
         /// <param name="model">Feature</param>
         /// <returns></returns>
         /// <returns></returns>
-        public DataTable GetMergedParticleInfo()
+        public Particle GetMergedParticleInfo(int fieldid, int particleid, out uint[] Search_xray, out uint[] Analysis_xray)
         {
         {
 
 
             string sqlp = @"select *,
             string sqlp = @"select *,
                             (select group_concat(name||'-'||Percentage,';')  
                             (select group_concat(name||'-'||Percentage,';')  
                             from ElementChemistry where XRayId	=MergedParticleInfo.XRayId		and fieldid=MergedParticleInfo.fieldid	) as Element
                             from ElementChemistry where XRayId	=MergedParticleInfo.XRayId		and fieldid=MergedParticleInfo.fieldid	) as Element
-                            from 	MergedParticleInfo ";
+                            from 	MergedParticleInfo  where FieldId=" + fieldid.ToString() + " and ParticleId="+ particleid.ToString();
 
 
             DataTable DT = dbHelper.ExecuteDataTable(sqlp, null);
             DataTable DT = dbHelper.ExecuteDataTable(sqlp, null);
-            return DT;
+            List<Particle> listp = dbHelper.TableToList<Particle>(DT);
+            Particle pte = new Particle();
+            Analysis_xray =new uint[2000];
+            Search_xray= new uint[2000];
+            if (listp.Count > 0)
+            {
+                pte = listp[0];
+                List<OTSCommon.DBOperate.Model.Element> ElementList = new List<OTSCommon.DBOperate.Model.Element>();
+                string element = DT.Rows[0]["Element"].ToString();
+                for (int i = 0; i < element.Split(';').Count(); i++)
+                {
+                    string elestr = element.Split(';')[i];
+                    if (elestr != "")
+                    {
+                        OTSCommon.DBOperate.Model.Element ele = new OTSCommon.DBOperate.Model.Element() { Name = elestr.Split('-')[0], Percentage = Convert.ToDouble(elestr.Split('-')[1]) };
+                        ElementList.Add(ele);
+                    }
+                }
+                pte.ElementList = ElementList;
+                string SubParticlesstr = DT.Rows[0]["SubParticles"].ToString();
+                string[] SubParticlesstrG = SubParticlesstr.Split(',');
+                foreach (string s in SubParticlesstrG)
+                {
+                    string fieldid1 = s.Split(':')[0];
+                    string pid1 = s.Split(':')[1];
+                    Particle particle1 = GetParticleXrayDataByFidAndPid(fieldid1, pid1);
+                    byte[] bytes = particle1.XRayData;
+                    for (int i = 0; i < 2000; i++)
+                    {
+                        Analysis_xray[i] = Analysis_xray[i]+ BitConverter.ToUInt32(bytes, i * 4);
+                    }
+                    Search_xray = Analysis_xray;
+                }
+            }
+            return pte;
         }
         }
 
 
         /// <summary>
         /// <summary>
@@ -120,14 +158,8 @@ namespace OTSIncAReportApp.DataOperation.DataAccess
             return DT;
             return DT;
         }
         }
 
 
-        /// <summary>
-        /// 获取ParticleList
-        /// </summary>
-        /// <param name="model">Feature</param>
-        /// <returns></returns>
         public DataTable GetParticleListForParticlSize(string con, string fieldAndPartic)
         public DataTable GetParticleListForParticlSize(string con, string fieldAndPartic)
         {
         {
-
             string sqlp = @"select TypeId,TypeName,GroupId ,TypeColor,count(1) as con,avg(" + con
             string sqlp = @"select TypeId,TypeName,GroupId ,TypeColor,count(1) as con,avg(" + con
                 + ") as av,max(" + con
                 + ") as av,max(" + con
                 + ") as max ,GroupName";
                 + ") as max ,GroupName";
@@ -138,7 +170,6 @@ namespace OTSIncAReportApp.DataOperation.DataAccess
             }
             }
 
 
             sqlp = sqlp + " group by TypeId ";
             sqlp = sqlp + " group by TypeId ";
-
             DataTable DT = dbHelper.ExecuteDataTable(sqlp, null);
             DataTable DT = dbHelper.ExecuteDataTable(sqlp, null);
 
 
             if (con == "area")
             if (con == "area")
@@ -150,6 +181,12 @@ namespace OTSIncAReportApp.DataOperation.DataAccess
             }
             }
             return DT;
             return DT;
         }
         }
+
+
+
+
+
+
 		/// <summary>
 		/// <summary>
 		/// 获取ParticleList
 		/// 获取ParticleList
 		/// </summary>
 		/// </summary>
@@ -157,7 +194,6 @@ namespace OTSIncAReportApp.DataOperation.DataAccess
 		/// <returns></returns>
 		/// <returns></returns>
 		public DataTable GetParticleListForParticlSizeID(string con, string fieldAndPartic)
 		public DataTable GetParticleListForParticlSizeID(string con, string fieldAndPartic)
 		{
 		{
-
 			string sqlp = @"select TypeId,TypeName,TypeColor,count(1) as con,avg(" + con
 			string sqlp = @"select TypeId,TypeName,TypeColor,count(1) as con,avg(" + con
 				+ ") as av,max(" + con
 				+ ") as av,max(" + con
 				+ ") as max ,GroupName ,GroupId,GroupColor";
 				+ ") as max ,GroupName ,GroupId,GroupColor";
@@ -180,6 +216,7 @@ namespace OTSIncAReportApp.DataOperation.DataAccess
 			}
 			}
 			return DT;
 			return DT;
 		}
 		}
+
 		/// <summary>
 		/// <summary>
 		/// 获取element含量
 		/// 获取element含量
 		/// </summary>
 		/// </summary>
@@ -246,6 +283,9 @@ namespace OTSIncAReportApp.DataOperation.DataAccess
         }
         }
 
 
 
 
+
+
+
         public DataTable GetParticleAllForBig(string fieldAndPartic)
         public DataTable GetParticleAllForBig(string fieldAndPartic)
         {
         {
             string sqlp = @"select * from INcAData where";
             string sqlp = @"select * from INcAData where";
@@ -260,9 +300,7 @@ namespace OTSIncAReportApp.DataOperation.DataAccess
             {
             {
                 DT.Rows[i]["ECD"] = Math.Sqrt((double)DT.Rows[i]["Area"] / Math.PI) * 2;
                 DT.Rows[i]["ECD"] = Math.Sqrt((double)DT.Rows[i]["Area"] / Math.PI) * 2;
             }
             }
-
             DataTable data = DT.Clone();
             DataTable data = DT.Clone();
-
             for (int i = 0; i < DT.Rows.Count; i++)
             for (int i = 0; i < DT.Rows.Count; i++)
             {
             {
                 if (Convert.ToInt32(DT.Rows[i]["ParticleId"]) > -1)
                 if (Convert.ToInt32(DT.Rows[i]["ParticleId"]) > -1)
@@ -274,20 +312,25 @@ namespace OTSIncAReportApp.DataOperation.DataAccess
             return data;
             return data;
         }
         }
 
 
+
         public DataTable GetParticleAllforparticlelist(string fieldAndPartic)
         public DataTable GetParticleAllforparticlelist(string fieldAndPartic)
         {
         {
-            string sqlp = @"select * from INcAData";
+            string sqlp = @"select * from INcAData where typeid !=-1";
             if (fieldAndPartic != "")
             if (fieldAndPartic != "")
             {
             {
-                sqlp = sqlp + " where '" + fieldAndPartic + "' like ('%,'||fieldid||'-'||particleid||',%')";
+                sqlp = sqlp + " and '" + fieldAndPartic + "' like ('%,'||fieldid||'-'||particleid||',%')";
             }
             }
             DataTable DT = dbHelper.ExecuteDataTable(sqlp, null);
             DataTable DT = dbHelper.ExecuteDataTable(sqlp, null);
-            for (int i = 0; i < DT.Rows.Count; i++)
+            return DT;
+        }
+        public DataTable GetMergedParticle(string fieldAndPartic)
+        {
+            string sqlp = @"select * from MergedParticleInfo where typeid !=-1";
+            if (fieldAndPartic != "")
             {
             {
-                DT.Rows[i]["Area"] = Math.Sqrt((double)DT.Rows[i]["Area"] / Math.PI) * 2;
+                sqlp = sqlp + " and '" + fieldAndPartic + "' like ('%,'||fieldid||'-'||particleid||',%')";
             }
             }
-
-
+            DataTable DT = dbHelper.ExecuteDataTable(sqlp, null);
             return DT;
             return DT;
         }
         }
         /// <summary>
         /// <summary>
@@ -324,9 +367,6 @@ namespace OTSIncAReportApp.DataOperation.DataAccess
                 incaSql = incaSql + " and '" + fieldAndPartic + "' like ('%,'||fieldid||'-'||particleid||',%')";
                 incaSql = incaSql + " and '" + fieldAndPartic + "' like ('%,'||fieldid||'-'||particleid||',%')";
             }
             }
             DataTable incaDT = dbHelper.ExecuteDataTable(incaSql, null);
             DataTable incaDT = dbHelper.ExecuteDataTable(incaSql, null);
-
-
-
             incaDT.Columns.Add("Element");
             incaDT.Columns.Add("Element");
 
 
             DataTable dt_element = GetElementChemistry();
             DataTable dt_element = GetElementChemistry();
@@ -743,7 +783,11 @@ namespace OTSIncAReportApp.DataOperation.DataAccess
             DT = dbHelper.ExecuteQuery(sqliteString);
             DT = dbHelper.ExecuteQuery(sqliteString);
             return DT;
             return DT;
         }
         }
-
+        /// <summary>
+        /// 获取拼接颗粒
+        /// </summary>
+        /// <param name="condition">帅选条件</param>
+        /// <returns></returns>
         public DataTable GetInfoForPartucleDevidePage_mergeParticles(string condition)
         public DataTable GetInfoForPartucleDevidePage_mergeParticles(string condition)
         {
         {
             string sqliteString = "select fieldid,particleid,AveGray,RectLeft,RectTop,RectWidth,RectHeight,Area,PosX,PosY,TypeId,SegmentNum,FieldPosX " +
             string sqliteString = "select fieldid,particleid,AveGray,RectLeft,RectTop,RectWidth,RectHeight,Area,PosX,PosY,TypeId,SegmentNum,FieldPosX " +
@@ -827,7 +871,151 @@ namespace OTSIncAReportApp.DataOperation.DataAccess
 
 
         }
         }
 
 
-        public Bitmap GetBitmapForBig(string sub, double xs, string path, int picHeight, int picWidth)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+        /// <summary>
+        /// 全部颗粒不带元素
+        /// </summary>
+        /// <param name="condition"></param>
+        /// <returns></returns>
+        public DataTable GetAllParticleWithMergeParticlesWithoutEle(string condition)
+        {
+            DataTable particlesAll = new DataTable();
+            DataTable particlesAll1 = GetParticleAllforparticlelist(condition);
+            DataTable mergeParticles = GetMergedParticle(condition);
+            if (mergeParticles != null && mergeParticles.Rows.Count > 0)
+            {
+                RemoveMergeParticles(ref particlesAll1, mergeParticles);
+            }
+            particlesAll = particlesAll1.Copy();
+            foreach (DataRow item in mergeParticles.Rows)
+            {
+                particlesAll.ImportRow(item);
+            }
+            return particlesAll;
+        }
+
+
+
+
+        /// <summary>
+        /// 全部颗粒带元素
+        /// </summary>
+        /// <param name="condition"></param>
+        /// <returns></returns>
+        public DataTable GetAllParticleWithMergeParticles(string condition)
+        {
+            DataTable particlesAll=new DataTable();
+            DataTable particlesAll1 = GetInfoForPartucleDevidePage_allParticles(condition);
+            DataTable mergeParticles = GetInfoForPartucleDevidePage_mergeParticles(condition);
+            if (mergeParticles != null && mergeParticles.Rows.Count > 0)
+            {
+                RemoveMergeParticles(ref particlesAll1, mergeParticles);
+            }
+            particlesAll = particlesAll1.Copy();
+            foreach (DataRow item in mergeParticles.Rows)
+            {
+                particlesAll.ImportRow(item);
+            }
+            DataTable elementchemistry = GetElementChemistry();
+            for (int i = 0; i < particlesAll.Rows.Count; i++)
+            {
+                string str = "XRayId = " + particlesAll.Rows[i]["particleId"].ToString() + " and fieldid = " + particlesAll.Rows[i]["fieldid"].ToString();
+                DataRow[] drs = elementchemistry.Select(str);
+                string ConcatenatedString = "";
+                for (int j = 0; j < drs.Length; j++)
+                {
+                    ConcatenatedString += drs[j]["name"] + "-" + drs[j]["Percentage"] + ';';
+                }
+                particlesAll.Rows[i]["Element"] = ConcatenatedString;
+            }
+            return particlesAll;
+        }
+
+        /// <summary>
+        /// 去除拼接颗粒组成颗粒
+        /// </summary>
+        /// <param name="dataTable_Particle"></param>
+        /// <param name="dataTable_MergeParticles"></param>
+        public void RemoveMergeParticles(ref DataTable dataTable_Particle, DataTable dataTable_MergeParticles)
+        {
+            foreach (DataRow row in dataTable_Particle.Rows)
+            {
+                foreach (DataRow MergeParticlesRow in dataTable_MergeParticles.Rows)
+                {
+                    string subt = MergeParticlesRow["SubParticles"].ToString();
+                    string[] sub = subt.Split(',');
+                    if (row.RowState == DataRowState.Deleted)
+                    {
+                        break;
+                    }
+                    if (row["fieldid"].ToString() == Convert.ToString(sub[0]).Split(':')[0] && row["ParticleId"].ToString() == Convert.ToString(sub[0]).Split(':')[1])
+                    {
+                        row.Delete();
+                        break;
+                    }
+                    if (row["fieldid"].ToString() == Convert.ToString(sub[1]).Split(':')[0] && row["ParticleId"].ToString() == Convert.ToString(sub[1]).Split(':')[1])
+                    {
+                        row.Delete();
+                        break; ;
+                    }
+                }
+            }
+            dataTable_Particle.AcceptChanges();
+        }
+
+        /// <summary>
+        /// 拼接颗粒图
+        /// </summary>
+        /// <param name="sub">拼接字符串</param>
+        /// <param name="xs">xs = pixw / ScanFieldSize</param>
+        /// <param name="path">报告文件路径</param>
+        /// <param name="picHeight">图像高</param>
+        /// <param name="picWidth">帧图宽</param>
+        /// <param name="X_AXIS_DIRECTION">电镜x轴正方向</param>
+        /// <param name="Y_AXIS_DIRECTION">电镜y轴正方向</param>
+        /// <returns></returns>
+        public Bitmap GetBitmapForBig(string sub, double xs, string path, int picHeight, int picWidth, OTS_X_AXIS_DIRECTION X_AXIS_DIRECTION, OTS_Y_AXIS_DIRECTION Y_AXIS_DIRECTION)
         {
         {
             string vs = "," + sub.Replace(':', '-') + ",";
             string vs = "," + sub.Replace(':', '-') + ",";
 
 
@@ -836,22 +1024,85 @@ namespace OTSIncAReportApp.DataOperation.DataAccess
             {
             {
                 return null;
                 return null;
             }
             }
-
             //内接矩形
             //内接矩形
-            double max_Y = Convert.ToInt64(dataTable.Rows[0]["FieldPosY"]) * xs - Convert.ToInt64(dataTable.Rows[0]["RectTop"]);
-            double max_X = Convert.ToInt64(dataTable.Rows[0]["FieldPosX"]) * xs + Convert.ToInt64(dataTable.Rows[0]["RectLeft"]);
+            double max_Y = Convert.ToInt64(dataTable.Rows[0]["RectTop"]);
+            double max_X = Convert.ToInt64(dataTable.Rows[0]["RectLeft"]);
             double min_Y = max_Y;
             double min_Y = max_Y;
-            double min_X = max_X;
 
 
+            double min_X = max_X;
             //拼接field矩形
             //拼接field矩形
-            double MAX_Y = Convert.ToInt64(dataTable.Rows[0]["FieldPosY"]) * xs;
-            double MAX_X = Convert.ToInt64(dataTable.Rows[0]["FieldPosX"]) * xs;
-            double MIN_Y = MAX_Y;
-            double MIN_X = MAX_X;
+            double B_Y = Convert.ToInt64(dataTable.Rows[0]["FieldPosY"]) * xs;
+            double R_X = Convert.ToInt64(dataTable.Rows[0]["FieldPosX"]) * xs;
+            double T_Y = B_Y;
+            double L_X = R_X;
             foreach (DataRow item in dataTable.Rows)
             foreach (DataRow item in dataTable.Rows)
             {
             {
+                double lefttopXH = Convert.ToInt64(item["FieldPosX"]) * xs;
+                if (X_AXIS_DIRECTION == OTS_X_AXIS_DIRECTION.LEFT_TOWARD)
+                {
+                    if (lefttopXH > L_X)
+                    {
+                        L_X = lefttopXH;
+                    }
+                    if (lefttopXH < R_X)
+                    {
+                        R_X = lefttopXH;
+                    }
+                }
+                else
+                {
+                    if (lefttopXH < R_X)
+                    {
+                        R_X = lefttopXH;
+                    }
+                    if (lefttopXH > L_X)
+                    {
+                        L_X = lefttopXH;
+                    }
+                }
+                double lrfttopYH = Convert.ToInt64(item["FieldPosY"]) * xs;
+                if (Y_AXIS_DIRECTION == OTS_Y_AXIS_DIRECTION.UP_TOWARD)
+                {
+                    if (lrfttopYH < B_Y)
+                    {
+                        B_Y = lrfttopYH;
+                    }
+                    if (lrfttopYH > T_Y)
+                    {
+                        T_Y = lrfttopYH;
+                    }
+                }
+                else
+                {
+                    if (lrfttopYH > B_Y)
+                    {
+                         B_Y= lrfttopYH;
+                    }
+                    if (lrfttopYH < T_Y)
+                    {
+                        T_Y = lrfttopYH;
+                    }
+                }
+            }
+            int WIDTH = Math.Abs(Convert.ToInt32(R_X - L_X)) + picWidth;
+            int HEIGHT = Math.Abs(Convert.ToInt32(B_Y - T_Y)) + picHeight;
+            //构造最终的图片白板
+            Bitmap tableChartImage = new Bitmap(WIDTH, HEIGHT);
+            Graphics graph = Graphics.FromImage(tableChartImage);
+            //初始化这个大图
+            graph.DrawImage(tableChartImage, 0, 0);
+            foreach (DataRow item in dataTable.Rows)
+            {
+                string filePath = path + "\\FIELD_FILES\\";
+                string imagePath = filePath + "Field" + item["fieldid"].ToString() + ".bmp";
+                //然后将取出的数据,转换成Bitmap对象
+                Bitmap ls_bt = ReadImageFile(imagePath);
+                int x = Math.Abs(Convert.ToInt32(Convert.ToDouble(item["FieldPosX"]) * xs - L_X));
+                int y = Math.Abs(Convert.ToInt32(Convert.ToDouble(item["FieldPosY"]) * xs - T_Y));
+
+                graph.DrawImage(ls_bt, x, y);
                 //颗粒外接矩形
                 //颗粒外接矩形
-                double lefttopX = Convert.ToInt64(item["FieldPosX"]) * xs + Convert.ToInt64(item["RectLeft"]);
+                double lefttopX = x+Convert.ToInt64(item["RectLeft"]);
                 if (lefttopX < min_X)
                 if (lefttopX < min_X)
                 {
                 {
                     min_X = lefttopX;
                     min_X = lefttopX;
@@ -860,66 +1111,160 @@ namespace OTSIncAReportApp.DataOperation.DataAccess
                 {
                 {
                     max_X = lefttopX + Convert.ToInt64(item["RectWidth"]);
                     max_X = lefttopX + Convert.ToInt64(item["RectWidth"]);
                 }
                 }
-                double lrfttopY = Convert.ToInt64(item["FieldPosY"]) * xs - Convert.ToInt64(item["RectTop"]);
-                if (max_Y < lrfttopY)
+                double lrfttopY = y+ Convert.ToInt64(item["RectTop"]);
+                if (lrfttopY + Convert.ToInt64(item["RectHeight"]) > max_Y)
                 {
                 {
-                    max_Y = lrfttopY;
+                    max_Y = lrfttopY + Convert.ToInt64(item["RectHeight"]);
                 }
                 }
-                if (min_Y > lrfttopY - Convert.ToInt64(item["RectHeight"]))
+                if ( lrfttopY< min_Y)
                 {
                 {
-                    min_Y = lrfttopY - Convert.ToInt64(item["RectHeight"]);
+                    min_Y = lrfttopY;
                 }
                 }
-                //画布
+            }
+            int width = Convert.ToInt32(max_X - min_X);
+            int height = Convert.ToInt32(max_Y - min_Y);
+            int X = Convert.ToInt32(min_X);
+            int Y = Convert.ToInt32(min_Y);
+            Rectangle rectangle = new Rectangle() { X = X, Y = Y, Width = width, Height = height };
+            Bitmap bmap = tableChartImage.Clone(rectangle, PixelFormat.Format8bppIndexed);
+            return bmap;
+        }
+
+
+        /// <summary>
+        /// 拼接颗粒黑白图
+        /// </summary>
+        /// <param name="sub">拼接字符串</param>
+        /// <param name="xs">xs = pixw / ScanFieldSize</param>
+        /// <param name="path">报告文件路径</param>
+        /// <param name="picHeight">图像高</param>
+        /// <param name="picWidth">帧图宽</param>
+        /// <param name="X_AXIS_DIRECTION">电镜x轴正方向</param>
+        /// <param name="Y_AXIS_DIRECTION">电镜y轴正方向</param>
+        /// <returns></returns>
+        public Bitmap GetBitmapForBigBlackAndWhiteImage(string sub, double xs, string path, int picHeight, int picWidth, OTS_X_AXIS_DIRECTION X_AXIS_DIRECTION, OTS_Y_AXIS_DIRECTION Y_AXIS_DIRECTION)
+        {
+            string vs = "," + sub.Replace(':', '-') + ",";
+            DataTable dataTable = GetParticleAllForBig(vs);
+            if (dataTable.Rows.Count == 0)
+            {
+                return null;
+            }
+            //内接矩形
+            double max_Y = Convert.ToInt64(dataTable.Rows[0]["RectTop"]);
+            double max_X = Convert.ToInt64(dataTable.Rows[0]["RectLeft"]);
+            double min_Y = max_Y;
+            double min_X = max_X;
+            //拼接field矩形
+            double B_Y = Convert.ToInt64(dataTable.Rows[0]["FieldPosY"]) * xs;
+            double R_X = Convert.ToInt64(dataTable.Rows[0]["FieldPosX"]) * xs;
+            double T_Y = B_Y;
+            double L_X = R_X;
+            foreach (DataRow item in dataTable.Rows)
+            {
                 double lefttopXH = Convert.ToInt64(item["FieldPosX"]) * xs;
                 double lefttopXH = Convert.ToInt64(item["FieldPosX"]) * xs;
-                if (lefttopXH > MAX_X)
+                if (X_AXIS_DIRECTION == OTS_X_AXIS_DIRECTION.LEFT_TOWARD)
                 {
                 {
-                    MAX_X = lefttopXH;
+                    if (lefttopXH > L_X)
+                    {
+                        L_X = lefttopXH;
+                    }
+                    if (lefttopXH < R_X)
+                    {
+                        R_X = lefttopXH;
+                    }
                 }
                 }
-                if (lefttopXH < MIN_X)
+                else
                 {
                 {
-                    MIN_X = lefttopXH;
+                    if (lefttopXH < R_X)
+                    {
+                        R_X = lefttopXH;
+                    }
+                    if (lefttopXH > L_X)
+                    {
+                        L_X = lefttopXH;
+                    }
                 }
                 }
                 double lrfttopYH = Convert.ToInt64(item["FieldPosY"]) * xs;
                 double lrfttopYH = Convert.ToInt64(item["FieldPosY"]) * xs;
-                if (MAX_Y < lrfttopYH)
+                if (Y_AXIS_DIRECTION == OTS_Y_AXIS_DIRECTION.UP_TOWARD)
                 {
                 {
-                    MAX_Y = lrfttopYH;
+                    if (lrfttopYH < B_Y)
+                    {
+                        B_Y = lrfttopYH;
+                    }
+                    if (lrfttopYH > T_Y)
+                    {
+                        T_Y = lrfttopYH;
+                    }
                 }
                 }
-                if (MIN_Y > lrfttopYH)
+                else
                 {
                 {
-                    MIN_Y = lrfttopYH;
+                    if (lrfttopYH > B_Y)
+                    {
+                        B_Y = lrfttopYH;
+                    }
+                    if (lrfttopYH < T_Y)
+                    {
+                        T_Y = lrfttopYH;
+                    }
                 }
                 }
             }
             }
-            int WIDTH = Convert.ToInt32(MAX_X - MIN_X) + picWidth;
-            int HEIGHT = Convert.ToInt32(MAX_Y - MIN_Y) + picHeight;
+            int WIDTH = Math.Abs(Convert.ToInt32(R_X - L_X)) + picWidth;
+            int HEIGHT = Math.Abs(Convert.ToInt32(B_Y - T_Y)) + picHeight;
             //构造最终的图片白板
             //构造最终的图片白板
             Bitmap tableChartImage = new Bitmap(WIDTH, HEIGHT);
             Bitmap tableChartImage = new Bitmap(WIDTH, HEIGHT);
             Graphics graph = Graphics.FromImage(tableChartImage);
             Graphics graph = Graphics.FromImage(tableChartImage);
+            graph.Clear(Color.White);
             //初始化这个大图
             //初始化这个大图
             graph.DrawImage(tableChartImage, 0, 0);
             graph.DrawImage(tableChartImage, 0, 0);
-
-            int width = Convert.ToInt32(max_X - min_X);
-            int height = Convert.ToInt32(max_Y - min_Y);
-            int X = Convert.ToInt32(min_X - MIN_X);
-            int Y = Convert.ToInt32(MAX_Y - max_Y);
-            Rectangle rectangle = new Rectangle() { X = X, Y = Y, Width = width, Height = height };
-
             foreach (DataRow item in dataTable.Rows)
             foreach (DataRow item in dataTable.Rows)
             {
             {
-                string filePath = path + "\\FIELD_FILES\\";
-                string imagePath = filePath + "Field" + item["fieldid"].ToString() + ".bmp";
-                //然后将取出的数据,转换成Bitmap对象
-                Bitmap ls_bt = ReadImageFile(imagePath);
-                int x = Convert.ToInt32(Convert.ToDouble(item["FieldPosX"]) * xs - MIN_X);
-                int y = Convert.ToInt32(Convert.ToDouble(item["FieldPosY"]) * xs - MIN_Y);
-
-                graph.DrawImage(ls_bt, x, y);
-
+                string strs = @"select *  from Segment where FieldId="+item["fieldid"].ToString()+" and ParticleId="+item["particleid"].ToString();
+                DataTable DTS = dbHelper.ExecuteDataTable(strs, null);
+                DataRow[] dd = DTS.Select();
+                List<Segment> flist = dbHelper.RowsToList<Segment>(dd);
+                int x = Math.Abs(Convert.ToInt32(Convert.ToDouble(item["FieldPosX"]) * xs - L_X));
+                int y = Math.Abs(Convert.ToInt32(Convert.ToDouble(item["FieldPosY"]) * xs - T_Y));
+                //颗粒外接矩形
+                double lefttopX = x + Convert.ToInt64(item["RectLeft"]);
+                if (lefttopX < min_X)
+                {
+                    min_X = lefttopX;
+                }
+                if (lefttopX + Convert.ToInt64(item["RectWidth"]) > max_X)
+                {
+                    max_X = lefttopX + Convert.ToInt64(item["RectWidth"]);
+                }
+                double lrfttopY = y + Convert.ToInt64(item["RectTop"]);
+                if (lrfttopY + Convert.ToInt64(item["RectHeight"]) > max_Y)
+                {
+                    max_Y = lrfttopY + Convert.ToInt64(item["RectHeight"]);
+                }
+                if (lrfttopY < min_Y)
+                {
+                    min_Y = lrfttopY;
+                }
+                foreach (Segment seg in flist)
+                {
+                    int f_length = seg.Length;
+                    for (int m = 0; m < f_length; m++)
+                    {
+                        int lsjs_x = seg.Start + m+ x;
+                        int lsjs_y = seg.Height+ y;
+                        tableChartImage.SetPixel(lsjs_x, lsjs_y, Color.Black);
+                    }
+                }
             }
             }
-
-            Bitmap bmap = tableChartImage.Clone(rectangle, PixelFormat.Format8bppIndexed);
+            int width = Convert.ToInt32(max_X - min_X);
+            int height = Convert.ToInt32(max_Y - min_Y);
+            int X = Convert.ToInt32(min_X);
+            int Y = Convert.ToInt32(min_Y);
+            Rectangle rectangle = new Rectangle() { X = X, Y = Y, Width = width, Height = height };
+            Bitmap bmap = GetBitmapByParticle(tableChartImage, rectangle);
             return bmap;
             return bmap;
         }
         }
 
 
+
         /// <summary>
         /// <summary>
         /// 通过FileStream 来打开文件,这样就可以实现不锁定Image文件,到时可以让多用户同时访问Image文件
         /// 通过FileStream 来打开文件,这样就可以实现不锁定Image文件,到时可以让多用户同时访问Image文件
         /// </summary>
         /// </summary>
@@ -1020,7 +1365,45 @@ namespace OTSIncAReportApp.DataOperation.DataAccess
 
 
             }
             }
         }
         }
-
+        /// <summary>
+        /// 传入颗粒的tagid和fieldid,来获取该颗粒下对应的xray数据
+        /// </summary>
+        /// <param name="in_clr_tagid">颗粒id</param>
+        /// <param name="in_clr_fieldid"></param>
+        /// <param name="Search_xray"></param>
+        /// <param name="Analysis_xray"></param>
+        public Particle GetXrayByParticleTagIDAndFieldID_ForMergeParticle(int in_clr_tagid, int in_clr_fieldid, out uint[] Search_xray, out uint[] Analysis_xray)
+        {
+            Search_xray = new uint[2000];
+            Analysis_xray = new uint[2000];
+            Particle particle = new Particle();
+            particle = GetMergedParticleInfo(in_clr_fieldid, in_clr_tagid, out Search_xray, out Analysis_xray);
+            return particle;
+        }
+        public List<ShowElementInfo> GetShowElementInfos_ForMergeParticle(List<Element> list_celementchemistryclr)
+        {
+            List<ShowElementInfo> list_showelementinfo = new List<ShowElementInfo>();
+            for (int i = 0; i < list_celementchemistryclr.Count; i++)
+            {
+                ShowElementInfo ls_sei = new ShowElementInfo();
+                ls_sei.ElementName = list_celementchemistryclr[i].Name;
+                ls_sei.Percentage = list_celementchemistryclr[i].Percentage;
+                ls_sei.dKF = Convert.ToDouble(CListPeriodic.GetPeriodicByEleName(ls_sei.ElementName).K_Peak);
+                double de_sx2 = 0;
+                if (CListPeriodic.GetPeriodicByEleName(ls_sei.ElementName).L_Peak == "" || CListPeriodic.GetPeriodicByEleName(ls_sei.ElementName).L_Peak == "-")
+                {
+                    de_sx2 = 0;
+                }
+                else
+                {
+                    de_sx2 = Convert.ToDouble(CListPeriodic.GetPeriodicByEleName(ls_sei.ElementName).L_Peak);
+                }
+                ls_sei.dLF = de_sx2;
+                list_showelementinfo.Add(ls_sei);
+            }
+            list_showelementinfo.Sort((p1, p2) => p2.Percentage.CompareTo(p1.Percentage));
+            return list_showelementinfo;
+        }
         #endregion
         #endregion
 
 
 
 
@@ -1206,8 +1589,6 @@ namespace OTSIncAReportApp.DataOperation.DataAccess
 			}
 			}
 			return ClassName;
 			return ClassName;
 		}
 		}
-
-
 		public DataTable ReadClassification(BasicData basicData)
 		public DataTable ReadClassification(BasicData basicData)
 		{
 		{
 			DataTable dt_stl = new DataTable();
 			DataTable dt_stl = new DataTable();
@@ -1219,24 +1600,24 @@ namespace OTSIncAReportApp.DataOperation.DataAccess
 
 
 	}
 	}
 
 
-	public class UserLibraryData
+	public class UserSTDDbData
     {
     {
         private SqlHelper dbHelper;
         private SqlHelper dbHelper;
 
 
-        public UserLibraryData(string libraryName,string resultpath)
+        public UserSTDDbData(string STDDbName,string resultpath)
         {
         {
             NLog.Logger log = NLog.LogManager.GetCurrentClassLogger();
             NLog.Logger log = NLog.LogManager.GetCurrentClassLogger();
-            if (!libraryName.Contains(".db"))
+            if (!STDDbName.Contains(".db"))
             {
             {
-                libraryName += ".db";
+                STDDbName += ".db";
             }
             }
-            if(libraryName.ToLower()== "nostddb.db")
+            if(STDDbName.ToLower()== "nostddb.db")
             {
             {
                 dbHelper = null;
                 dbHelper = null;
                 log.Error("Failed to load user-defined library" + "!");
                 log.Error("Failed to load user-defined library" + "!");
             }
             }
-            string fullPath = resultpath + libraryName;
-            string fullPath2 = System.IO.Directory.GetCurrentDirectory() + "\\Config\\SysData\\" + libraryName;
+            string fullPath = resultpath + STDDbName;
+            string fullPath2 = System.IO.Directory.GetCurrentDirectory() + "\\Config\\SysData\\" + STDDbName;
             if (System.IO.File.Exists(fullPath))
             if (System.IO.File.Exists(fullPath))
             {
             {
                 dbHelper = new SqlHelper("data source='" + fullPath + "'");
                 dbHelper = new SqlHelper("data source='" + fullPath + "'");
@@ -1263,8 +1644,5 @@ namespace OTSIncAReportApp.DataOperation.DataAccess
         }
         }
 
 
         public SqlHelper GetSqlHelper() { return dbHelper; }
         public SqlHelper GetSqlHelper() { return dbHelper; }
-
-
-        
     }
     }
 }
 }

+ 28 - 0
OTSIncAReportApp/3-ServiceCenter/DataOperation/DataAccess/SqlHelper.cs

@@ -750,5 +750,33 @@ namespace OTSIncAReportApp.DataOperation.DataAccess
                 }
                 }
             }
             }
         }
         }
+        /// <summary>
+        /// 使用事务执行多条SQL语句
+        /// </summary>
+        /// <param name="sqlStatements">SQL语句列表</param>
+        public void ExecuteMultipleStatementsWithTransaction(List<string> sqlStatements)
+        {
+            SQLiteTransaction transaction = dbConnection.BeginTransaction();
+
+            try
+            {
+                foreach (string sql in sqlStatements)
+                {
+                    if (!string.IsNullOrWhiteSpace(sql))
+                    {
+                        using (SQLiteCommand cmd = new SQLiteCommand(sql, dbConnection, transaction))
+                        {
+                            cmd.ExecuteNonQuery();
+                        }
+                    }
+                }
+                transaction.Commit();
+            }
+            catch (Exception ex)
+            {
+                transaction.Rollback();
+                throw;
+            }
+        }
     }
     }
 }
 }

+ 3 - 0
OTSIncAReportApp/App.config

@@ -11,6 +11,9 @@
   <connectionStrings>
   <connectionStrings>
     <!--<add name="XMLFilePath" connectionString="TestData.XML"/>-->
     <!--<add name="XMLFilePath" connectionString="TestData.XML"/>-->
     <add name="XMLFilePath" connectionString="Resources/XMLData/SystemData.XML"/>
     <add name="XMLFilePath" connectionString="Resources/XMLData/SystemData.XML"/>
+    <add name="LogAppPath" connectionString="Log\\Nlog"/>
+    <add name="LogPath" connectionString="Log\\Nlog"/>
+    <add name="XMLFileName" connectionString="Config/ProData/HardwareConfig.xml"/>
   </connectionStrings>
   </connectionStrings>
   <nlog>
   <nlog>
     <!-- optional, add some variables
     <!-- optional, add some variables

+ 1 - 0
OTSIncAReportApp/OTSIncAReportApp.csproj

@@ -507,6 +507,7 @@
       <Private>False</Private>
       <Private>False</Private>
     </Reference>
     </Reference>
     <Reference Include="System.Core" />
     <Reference Include="System.Core" />
+    <Reference Include="System.Data.DataSetExtensions" />
     <Reference Include="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
     <Reference Include="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
     <Reference Include="System.Data.SQLite">
     <Reference Include="System.Data.SQLite">
       <HintPath>..\OpenDll\SQLiteDll\System.Data.SQLite.dll</HintPath>
       <HintPath>..\OpenDll\SQLiteDll\System.Data.SQLite.dll</HintPath>

+ 1 - 0
OTSIncAReportApp/packages.config

@@ -11,6 +11,7 @@
   <package id="SharpZipLib" version="1.3.3" targetFramework="net462" />
   <package id="SharpZipLib" version="1.3.3" targetFramework="net462" />
   <package id="System.Buffers" version="4.5.1" targetFramework="net462" />
   <package id="System.Buffers" version="4.5.1" targetFramework="net462" />
   <package id="System.Collections" version="4.3.0" targetFramework="net472" />
   <package id="System.Collections" version="4.3.0" targetFramework="net472" />
+  <package id="System.Data.DataSetExtensions" version="4.5.0" targetFramework="net48" />
   <package id="System.Data.SQLite.EF6" version="1.0.115.0" targetFramework="net472" />
   <package id="System.Data.SQLite.EF6" version="1.0.115.0" targetFramework="net472" />
   <package id="System.Data.SQLite.Linq" version="1.0.115.0" targetFramework="net472" />
   <package id="System.Data.SQLite.Linq" version="1.0.115.0" targetFramework="net472" />
   <package id="System.Data.SQLite.x64" version="1.0.115.0" targetFramework="net472" />
   <package id="System.Data.SQLite.x64" version="1.0.115.0" targetFramework="net472" />