소스 검색

解决帧图没有坐标位置导致报错的问题(未测试)

zhangjiaxin 3 년 전
부모
커밋
a4de893d1c

+ 24 - 6
OTSIncAReportApp/Control_Graph/Controls/Control_DrawDistrbutionImageAndBSE.cs

@@ -11,9 +11,11 @@ using System.Collections.Generic;
 using System.Data;
 using System.Drawing;
 using System.Drawing.Drawing2D;
+using System.IO;
 using System.Linq;
 using System.Threading;
 using System.Windows.Forms;
+using System.Xml;
 
 namespace OTSIncAReportGraph.Controls
 {
@@ -163,7 +165,9 @@ namespace OTSIncAReportGraph.Controls
         private List<string> originalImageNames = new List<string>();
         //背景使用原图
         private bool OriginalBackground = false;
- 
+
+     
+
         /// <summary>
         /// 当前正在显示的数据源名称,用来与框架调用条件判断使用
         /// </summary>
@@ -207,7 +211,7 @@ namespace OTSIncAReportGraph.Controls
         //List<CGridDataClr> m_list_cgriddataclr = null;
 
         public List<Particle> SelectedParticles { set; get; }
-        OTSIncAReportApp.frmReportApp m_ReportApp;
+        OTSIncAReportApp.frmReportApp m_ReportApp=new OTSIncAReportApp.frmReportApp();
         ResultFile resultFile = null;
 
 
@@ -231,12 +235,12 @@ namespace OTSIncAReportGraph.Controls
             m_mythread_state = false;
 
             m_mythread = new Thread(new ParameterizedThreadStart(Thread_GO));
-
+            
             m_ReportApp = ReportApp;
             resultFile = m_ReportApp.resultFilesList[m_ReportApp.WorkingResult];
 
             //初始化底层操作类
-            m_OTSIncAReportFun = new OTSIncAReportFun(this, resultFile);
+            m_OTSIncAReportFun = new OTSIncAReportFun(this, resultFile, ReportApp);
             
             InitializeComponent();
             #region 国际化语言
@@ -295,15 +299,16 @@ namespace OTSIncAReportGraph.Controls
                     m_list_dfield[i].Show_Rect.Y,
                     m_list_dfield[i].Show_Rect.Width,
                     m_list_dfield[i].Show_Rect.Height);
-
                 m_old_list_dfield.Add(df);
             }
-
+            ResetPicturePosition();
             //进入时首先对XRayTable进行隐藏
             control_XRayTable1.Visible = false;
 
             m_frm_userprogress.SetProgressValueAndText(100, table["str2"].ToString());
 
+            
+
             //加载完成,关闭进度条
             m_frm_userprogress.Close();
         }
@@ -1926,6 +1931,19 @@ namespace OTSIncAReportGraph.Controls
                 }
             }
         }
+
+        private void ResetPicturePosition()
+        {
+            DirectoryInfo info = new DirectoryInfo(resultFile.FilePath + "\\FIELD_FILES");
+            int count = info.GetFiles("*.bmp").Length;
+            //m_list_dfield.Clear();
+            //for (int i=0;i< count;i++)
+            //{
+            //    m_list_dfield[i].Current_Rect.X
+            //}
+        }
+
+        
         #endregion
 
         #region Debug下执行的辅助测试代码

+ 7 - 5
OTSIncAReportApp/Control_Graph/OTSIncAReportGraphFuncation/OTSIncAReportFun.cs

@@ -76,6 +76,8 @@ namespace OTSIncAReportGraph.OTSIncAReportGraphFuncation
         //连接到电镜的ID号
         public int m_SEM_ID = 0;
 
+        private OTSIncAReportApp.frmReportApp ReportApp = new OTSIncAReportApp.frmReportApp();
+
         //国际化
         Language lan = new Language();
         Hashtable table;
@@ -87,13 +89,13 @@ namespace OTSIncAReportGraph.OTSIncAReportGraphFuncation
         /// </summary>
         /// <param name="in_Control_DrawDistrbutionImageAndBSE"></param>
         /// <param name="in_Cotsreportprojfilemgrclr"></param>
-        public OTSIncAReportFun(Control_DrawDistrbutionImageAndBSE in_Control_DrawDistrbutionImageAndBSE, ResultFile result)
+        public OTSIncAReportFun(Control_DrawDistrbutionImageAndBSE in_Control_DrawDistrbutionImageAndBSE, ResultFile result, OTSIncAReportApp.frmReportApp a_ReportApp)
         {
             m_Control_DrawDistrbutionImageAndBSE = in_Control_DrawDistrbutionImageAndBSE;
             resultFile = result;
             m_cfun = new COTSControlFunExport();//重新new一下试试呢,不New并不好用  It's better to reinitialize, but it's not good to uninitialize
-
-            table = lan.GetNameTable("OTSIncAReportFun");
+            ReportApp = a_ReportApp;
+              table = lan.GetNameTable("OTSIncAReportFun");
         }
 
         /// <summary>
@@ -613,9 +615,9 @@ namespace OTSIncAReportGraph.OTSIncAReportGraphFuncation
             //对底层加载速度进行计时
             Stopwatch stopwatch = new Stopwatch();
             stopwatch.Start();
-
+          
             string path = resultFile.FilePath;
-            FieldData fieldData = new FieldData(path);
+            FieldData fieldData = new FieldData(path, ReportApp);
             List<Field> fieldlist = fieldData.GetFieldList();
 
             //防止有时底层返回的Field的List是0,直接返回

+ 50 - 7
OTSIncAReportApp/DataOperation/DataAccess/FieldData.cs

@@ -9,6 +9,7 @@ namespace OTSIncAReportApp.DataOperation.DataAccess
     public class FieldData
     {
         private SqlHelper dbHelper;
+        private frmReportApp m_Report=new frmReportApp();
         //测量文件地址
         private string filePath;
         public FieldData(string path)
@@ -16,7 +17,14 @@ namespace OTSIncAReportApp.DataOperation.DataAccess
             dbHelper = new SqlHelper("data source='" + path + "\\FIELD_FILES\\Inclusion.db'");
             filePath = path + "\\FIELD_FILES\\";
         }
-
+        
+        public FieldData(string path, frmReportApp a_ReportApp)
+        {
+           
+            dbHelper = new SqlHelper("data source='" + path + "\\FIELD_FILES\\Inclusion.db'");
+            filePath = path + "\\FIELD_FILES\\";
+            m_Report = a_ReportApp;
+        }
         /// <summary>
         /// 获取SegmentList
         /// </summary>
@@ -39,26 +47,31 @@ namespace OTSIncAReportApp.DataOperation.DataAccess
             DataTable DTE = dbHelper.ExecuteDataTable(sqle, null);
 
             List<Model.Field> Fields = new List<Model.Field>();
-            foreach (DataRow dr in DT.Rows)
+
+            DirectoryInfo info = new DirectoryInfo(filePath);
+            int count = info.GetFiles("*.bmp").Length;
+            
+            for (int i=0;i< count; i++)
             {
-                string imagePath = filePath + "Field" + dr["fieldid"].ToString() + ".bmp";
+                
+                string imagePath = filePath + "Field" + m_Report.OriginalPoint.Rows[i]["ID"].ToString() + ".bmp";
 
 
-                Model.Field modelf = new Model.Field() { FieldID = Convert.ToInt32(dr["fieldid"]), FieldPosX = Convert.ToInt32(dr["fieldposx"]), FieldPosY = Convert.ToInt32(dr["fieldposy"]), FieldImage = imagePath };
+                Model.Field modelf = new Model.Field() { FieldID = Convert.ToInt32(m_Report.OriginalPoint.Rows[i]["ID"].ToString()), FieldPosX = Convert.ToInt32(m_Report.OriginalPoint.Rows[i]["FieldX"].ToString()), FieldPosY = Convert.ToInt32(m_Report.OriginalPoint.Rows[i]["FieldY"].ToString()), FieldImage = imagePath };
 
-                DataRow[] drp = DTP.Select("fieldid=" + dr["fieldid"].ToString());
+                DataRow[] drp = DTP.Select("fieldid=" + m_Report.OriginalPoint.Rows[i]["ID"].ToString());
 
                 List<Model.Particle> listp = dbHelper.RowsToList<Model.Particle>(drp);
 
                 foreach (Model.Particle modelp in listp)
                 {
                     //添加FeatureList信息
-                    DataRow[] drs = DTS.Select("fieldid=" + dr["fieldid"].ToString() + " and particleid=" + modelp.ParticleId.ToString());
+                    DataRow[] drs = DTS.Select("fieldid=" + m_Report.OriginalPoint.Rows[i]["ID"].ToString() + " and particleid=" + modelp.ParticleId.ToString());
                     List<Model.Feature> flist = dbHelper.RowsToList<Model.Feature>(drs);
                     modelp.FeatureList = flist;
 
                     //添加ElementList信息
-                    DataRow[] dre = DTE.Select("fieldid=" + dr["fieldid"].ToString() + " and XRayId=" + modelp.XrayId.ToString());
+                    DataRow[] dre = DTE.Select("fieldid=" + m_Report.OriginalPoint.Rows[i]["ID"].ToString() + " and XRayId=" + modelp.XrayId.ToString());
                     List<Model.Element> elist = dbHelper.RowsToList<Model.Element>(dre);
                     modelp.ElementList = elist;
                 }
@@ -67,6 +80,36 @@ namespace OTSIncAReportApp.DataOperation.DataAccess
 
                 Fields.Add(modelf);
             }
+            
+
+            //foreach (DataRow dr in DT.Rows)
+            //{
+            //    string imagePath = filePath + "Field" + dr["fieldid"].ToString() + ".bmp";
+                
+
+            //    Model.Field modelf = new Model.Field() { FieldID = Convert.ToInt32(dr["fieldid"]), FieldPosX = Convert.ToInt32(dr["fieldposx"]), FieldPosY = Convert.ToInt32(dr["fieldposy"]), FieldImage = imagePath };
+
+            //    DataRow[] drp = DTP.Select("fieldid=" + dr["fieldid"].ToString());
+
+            //    List<Model.Particle> listp = dbHelper.RowsToList<Model.Particle>(drp);
+
+            //    foreach (Model.Particle modelp in listp)
+            //    {
+            //        //添加FeatureList信息
+            //        DataRow[] drs = DTS.Select("fieldid=" + dr["fieldid"].ToString() + " and particleid=" + modelp.ParticleId.ToString());
+            //        List<Model.Feature> flist = dbHelper.RowsToList<Model.Feature>(drs);
+            //        modelp.FeatureList = flist;
+
+            //        //添加ElementList信息
+            //        DataRow[] dre = DTE.Select("fieldid=" + dr["fieldid"].ToString() + " and XRayId=" + modelp.XrayId.ToString());
+            //        List<Model.Element> elist = dbHelper.RowsToList<Model.Element>(dre);
+            //        modelp.ElementList = elist;
+            //    }
+
+            //    modelf.ParticleList = listp;
+
+            //    Fields.Add(modelf);
+            //}
 
             return Fields;
 

+ 24 - 17
OTSIncAReportApp/DataOperation/DataAccess/XMLoperate.cs

@@ -195,29 +195,34 @@ namespace OTSIncAReportApp.DataOperation.DataAccess
             {
 
                 string name = element.Name;
-                int attributes = element.Attributes.Count;
-                Dictionary<string, object> obj = new Dictionary<string, object>();
-                string key = "";
-                foreach (System.Xml.XmlAttribute item in element.Attributes)
+                if ("Collection"!= name)
                 {
-                    if (item.Name == "RegName")
-                    {
-                        key = item.Value;
-                    }
-                    else
+                    int attributes = element.Attributes.Count;
+                    Dictionary<string, object> obj = new Dictionary<string, object>();
+                    string key = "";
+                    foreach (System.Xml.XmlAttribute item in element.Attributes)
                     {
-                        obj.Add(item.Name, item.Value);
+                        if (item.Name == "RegName")
+                        {
+                            key = item.Value;
+                        }
+                        else
+                        {
+                            obj.Add(item.Name, item.Value);
+                        }
                     }
-                }
-                if (element.ChildNodes.Count > 0)
-                {
-                    Dictionary<string, object> childList = GetChildInfo(element.ChildNodes);
-                    if (childList.Count > 0)
+
+                    if (element.ChildNodes.Count > 0)
                     {
-                        obj.Add("Members", childList);
+                        Dictionary<string, object> childList = GetChildInfo(element.ChildNodes);
+                        if (childList.Count > 0)
+                        {
+                            obj.Add("Members", childList);
+                        }
                     }
+                    suggestions.Add(key, obj);
                 }
-                suggestions.Add(key, obj);
+               
             }
             return suggestions;
         }
@@ -244,6 +249,8 @@ namespace OTSIncAReportApp.DataOperation.DataAccess
                 }
                 if (element.ChildNodes.Count > 0)
                 {
+                    
+
                     Dictionary<string, object> childList = GetChildInfo(element.ChildNodes);
                     if (childList.Count > 0)
                     {

+ 1 - 6
OTSIncAReportApp/OTSMgrInfo/FormNewLJFile.cs

@@ -101,7 +101,7 @@ namespace OTSIncAReportApp.OTSMgrInfo
                     MessageBox.Show("File name conflict");
                     return;
                 }
-                if(partsize.Rows[i]["Name"].ToString() == tb_new_ljz.Text)
+                if(partsize.Rows[i]["Name"].ToString() == tb_new_ljm.Text)
                 {
                     MessageBox.Show("Particle name conflict");
                     return;
@@ -115,11 +115,6 @@ namespace OTSIncAReportApp.OTSMgrInfo
             file.Close();
 
             this.Close();
-            ////再重新绑定显示
-            //BindGridView();
-
-            ////为全局选择变量进行重新赋值
-            //ReControlsValue();
 
         }
 

+ 45 - 2
OTSIncAReportApp/frmMeasureRstMgr.cs

@@ -5,9 +5,12 @@ using OTSIncAReportApp.SysMgrTools;
 using System;
 using System.Collections;
 using System.Collections.Generic;
+using System.Data;
 using System.Drawing;
+using System.IO;
 using System.Runtime.InteropServices;
 using System.Windows.Forms;
+using System.Xml;
 
 namespace OTSIncAReportApp
 {
@@ -301,12 +304,12 @@ namespace OTSIncAReportApp
             {
                 return;
             }
-           
+
             //为了使用国标,保留clr向底层加载的代码部份-----------------------------------------------
             //m_ReportApp.m_ReportProjFileMgr.AddASmplMsrResultMgr(str_path);
             //m_ReportApp.m_ReportProjFileMgr.SetSelectedPicture(1);
             //-----------------------------------------------------------------------------------------
-
+           m_ReportApp.OriginalPoint= ReadXML(str_path);
 
             //加载测量结果文件
             Dictionary<string, object> suggestions = DataOperation.DataAccess.XMLoperate.GetXMLAllInfo(str_path);
@@ -638,5 +641,45 @@ namespace OTSIncAReportApp
 
         #endregion
 
+        //读取rst文件中的帧图位置信息
+        private DataTable ReadXML(string a_position)
+        {
+            //创建空列
+            DataTable dt = new DataTable();
+            dt.TableName = "Fields";
+            dt.Columns.Add("FieldX");
+            dt.Columns.Add("FieldY");
+            dt.Columns.Add("ID");
+
+            XmlDocument doc = new XmlDocument();
+            XmlReaderSettings settings = new XmlReaderSettings();
+            settings.IgnoreComments = true;//忽略文档里的注释
+            XmlReader reader = XmlReader.Create(a_position, settings);
+            doc.Load(reader);
+            //得到根结点
+            XmlNode xn = doc.SelectSingleNode("XMLData");
+            //得到根结点的所有子节点
+            XmlNodeList xnl = xn.ChildNodes;
+            foreach (XmlNode xml in xnl)
+            {
+                if (xml.Name.ToString() == "Collection")
+                {
+                    for (int i = 0; i < xml.ChildNodes.Count; i++)
+                    {
+                        if (xml.ChildNodes[i].Name.ToLower() == "member")
+                        {
+                                DataRow dr = dt.NewRow();
+                                dr["FieldX"] = xml.ChildNodes[i].Attributes.GetNamedItem("FieldX").Value;
+                                dr["FieldY"] = xml.ChildNodes[i].Attributes.GetNamedItem("FieldY").Value;
+                                dr["ID"] = xml.ChildNodes[i].Attributes.GetNamedItem("ID").Value;
+                                dt.Rows.Add(dr);
+                            
+                        }
+                    }
+                }
+            }
+            return dt;
+        }
+
     }
 }

+ 6 - 0
OTSIncAReportApp/frmReportApp.cs

@@ -12,6 +12,7 @@ using System.Collections;
 using System.Collections.Generic;
 using System.Data;
 using System.Diagnostics;
+using System.Drawing;
 using System.Windows.Forms;
 
 namespace OTSIncAReportApp
@@ -48,6 +49,9 @@ namespace OTSIncAReportApp
         public List<OTSSampleMeaInfo> SourceGridDataList = new List<OTSSampleMeaInfo>();                            //所有模块的SourceGrid
         public List<OTSSampleMeaInfo> SourceGridDataListLog = new List<OTSSampleMeaInfo>();                         //所有模块的SourceGrid使用记录
         public List<DataOperation.Model.Particle> SelectedParticles = new List<DataOperation.Model.Particle>();     //所有选择颗粒
+
+        
+        public DataTable OriginalPoint = new DataTable();//帧图位置point
         public string MoreSource = "";
 
         Hashtable table;                                                                                            //国际化表
@@ -171,6 +175,8 @@ namespace OTSIncAReportApp
             //配置文件管理窗体
             m_ReportSysConfigForm = new frmReportSysConfig(this);
 
+            
+
             SetTag();
 
             #region 国际化语言