Selaa lähdekoodia

补充合并dev分支

zhangjiaxin 3 vuotta sitten
vanhempi
commit
8ee0796cfa

+ 64 - 0
OTSIncAReportApp/2-CommonFunction/OTSDataMgrFunction/ResourceID.cs

@@ -0,0 +1,64 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OTSModelSharp.ResourceManage
+{
+    public class ResourceID
+    {
+
+        //测量结果数据
+        public const int Measurement_Result_Data_0 = 40000;
+        //测量图类型  bse,颗粒分类图
+        public const int Type_Of_Survey_Drawing_0 = 40001;
+        //测量图显示方式
+        public const int Display_mode_Of_Measurement_Diagram_0 = 40002;
+        //颗粒类型
+        public const int Particle_Type_0 = 40003;
+        //粒级表
+        public const int Particle_Size_Table_0 = 40004;
+        //粒级
+        public const int Particle_Size_0 = 40005;
+        //尺寸计算法
+        public const int Dimension_Calculation_Method_0 = 40009;
+        //最小颗粒
+        public const int Minimum_Particle_0 = 40006;
+        //最大颗粒
+        public const int Maximum_Particle_0 = 40007;
+        //测量数据
+        public const int measured_Data_0 = 40008;
+        //全部
+        public const int All_0 = 40010;
+        //自定义
+        public const int custom_0 = 40011;
+
+
+        //测量结果数据
+        public const int Measurement_Result_Data_1 = 40000;
+        //数据类型
+        public const int data_type_1 = 40001;
+        //数据表类型
+        public const int Data_Table_Type_1 = 40002;
+        //粒级表
+        public const int Particle_Size_Table_1 = 40003;
+        //尺寸计算法
+        public const int Dimension_Calculation_Method_1= 40004;
+
+
+
+        //测量结果数据
+        public const int Measurement_Result_Data_2 = 40000;
+        //数据类型
+        public const int data_type_2 = 40001;
+        //数据表类型
+        public const int Data_Table_Type_2 = 40002;
+        //三元相图
+        public const int Ternary_Phase_Diagram_2 = 40003;
+        //粒级表
+        public const int Particle_Size_Table_2 = 40004;
+        //尺寸计算法
+        public const int Dimension_Calculation_Method_2 = 40005;
+    }
+}

+ 165 - 0
OTSIncAReportApp/2-CommonFunction/OTSDataMgrFunction/XmlResourceData.cs

@@ -0,0 +1,165 @@
+using System.Collections.Generic;
+using System.Xml;
+
+namespace OTSDataType
+{
+    public struct StringRes
+    {
+        public int key;
+        public string text;
+        public string Description;
+        public string DownList;
+
+    }
+    public class ResGroup
+    {
+        public int key;
+        public string text = "";
+        public string Description = "";
+        public string DownList = "";
+        public SortedDictionary<int, StringRes> mapRes = new SortedDictionary<int, StringRes>();
+    }
+   public  class XmlResourceData
+    {
+        static XmlResourceData instance =new XmlResourceData();
+        private SortedDictionary<int, ResGroup> resGroup = new SortedDictionary<int, ResGroup>();
+        public XmlResourceData()
+        {
+            LoadStringFromXml();
+        }
+        public void GetStringByKey(int grpKey, int itmKey, ref string text, ref string des,ref string downlist)
+        {
+            text = resGroup[grpKey].mapRes[itmKey].text;
+            des = resGroup[grpKey].mapRes[itmKey].Description;
+            downlist = resGroup[grpKey].mapRes[itmKey].DownList;
+        }
+        public string GetStringByKey(int grpKey, int itmKey)
+        {
+            return resGroup[grpKey].mapRes[itmKey].text;
+        }
+
+        public string GetStringByKey(int itmKey)
+        {
+            return resGroup[0].mapRes[itmKey].text;
+        }
+        public string GetGroupTextByKey(int grpKey)
+        {
+            return resGroup[grpKey].text;
+        }
+
+        public void GetGroupTextByKey(int grpKey, ref string text, ref string des)
+        {
+            text = resGroup[grpKey].text;
+            des = resGroup[grpKey].Description;
+        }
+
+        public void SetStringByKey(int grpkey, int itmkey, string value, string des)
+        {
+            StringRes sr = new StringRes();
+            sr.text = value;
+            sr.Description = des;
+            resGroup[grpkey].mapRes[itmkey] = sr;
+        }
+
+        public bool LoadStringFromXml()
+        {
+            XmlDocument xml = new XmlDocument();
+            xml.Load(".\\Resources\\XMLData\\LanguageDefine.xml");
+            XmlNode root = xml.SelectSingleNode("Language");
+            XmlNode root2 = root.SelectSingleNode("DefaultLanguage");
+            string ss = root2.InnerText;
+
+            XmlDocument doc1 = new XmlDocument();
+            if (ss == "EN")
+            {
+                doc1.Load(".\\Resources\\XMLData\\ResourceForCpp\\ResourceForReport-EN.xml");//载入xml文件
+            }
+            else if (ss == "ZH")
+            {
+                doc1.Load(".\\Resources\\XMLData\\ResourceForCpp\\ResourceForReport-ZH.xml");//载入xml文件
+            }
+
+            root = doc1.SelectSingleNode("XMLData");
+            root2 = root.SelectSingleNode("collection");
+
+           
+            XmlNodeList childlist = root2.ChildNodes;
+            for (int i = 0; i < childlist.Count; i++)
+            {
+                int colkey = -1;
+                if (childlist[i].Attributes["grpKey"] != null)
+                {
+
+                    colkey = int.Parse(childlist[i].Attributes["grpKey"].Value);
+                }
+                string colText = "";
+                if (childlist[i].Attributes["text"] != null)
+                {
+
+                    colText = childlist[i].Attributes["text"].Value;
+                }
+                string colDes = "";
+                if (childlist[i].Attributes["description"] != null)
+                {
+
+                    colDes = childlist[i].Attributes["description"].Value;
+                }
+                ResGroup rg = new ResGroup();
+                rg.key = colkey;
+                rg.text = colText;
+                rg.Description = colDes;
+                
+
+                XmlNodeList childlist2 = childlist[i].ChildNodes;
+                for (int j = 0; j < childlist2.Count; j++)
+                {
+                    StringRes sr = new StringRes();
+                    int key = int.Parse(childlist2[j].Attributes["itemKey"].Value);
+                    sr.key = key;
+                    sr.text = childlist2[j].Attributes["itemText"].Value;
+
+                    if (childlist2[j].Attributes["boDownList"] != null)
+                    {
+                        sr.DownList = childlist2[j].Attributes["boDownList"].Value;
+                    }
+                    else
+                    {
+                        sr.DownList = "空";
+                    }
+
+
+                    if (childlist2[j].Attributes["description"] != null)
+                    {
+                        sr.Description = childlist2[j].Attributes["description"].Value;
+                    }
+                    else
+                    {
+                        sr.Description = "空";
+                    }
+                    try
+                    {
+                        rg.mapRes[key] = sr;
+                    }
+                    catch (System.Exception ex)
+                    {
+                       // MessageBox.Show(ex.ToString());
+                    }
+                }
+                resGroup[colkey] = rg;
+            }
+            return true;
+        }
+       
+        public static XmlResourceData GetInstance()
+        {
+            //static MultiLang instance;
+            if (instance == null)
+            {
+                instance.LoadStringFromXml();
+            }
+           
+            return instance;
+        }
+
+    }
+}