Browse Source

修改编辑器框架

cxs 4 months ago
parent
commit
daa2788f63

+ 1 - 1
OTSPartA_STDEditor/BaseClass/STDGroups.cs

@@ -6,7 +6,7 @@ using System.Threading.Tasks;
 
 namespace OTSPartA_STDEditor
 {
-    class STDGroups
+    public class STDGroups
     {
         //int s_id = 0;
         string s_name = "";

+ 1 - 0
OTSPartA_STDEditor/OTSPartA_STDEditor.csproj

@@ -237,6 +237,7 @@
   </ItemGroup>
   <ItemGroup>
     <Compile Include="BaseClass\Periodic.cs" />
+    <Compile Include="BaseClass\STDInfo.cs" />
     <Compile Include="UI\Attributes.cs">
       <SubType>Form</SubType>
     </Compile>

+ 12 - 11
OTSPartA_STDEditor/UI/Attributes.cs

@@ -204,22 +204,23 @@ namespace OTSPartA_STDEditor
 
         public void SetDatatoGrid_Attributes(int STDId)
         {
+            STDdata sTDdata = m_MainForm._sTDEditor.STDDictionary[STDId];
             Grid_Attributes[1, 1].Value = STDId;
-            Grid_Attributes[2, 1].Value = m_MainForm.STDDictionary[STDId].StrName;
+            Grid_Attributes[2, 1].Value = sTDdata.StrName;
             SourceGrid.Cells.Views.Cell view = new SourceGrid.Cells.Views.Cell();
-            view.BackColor = colorHx16toRGB(m_MainForm.STDDictionary[STDId].Color);
+            view.BackColor = colorHx16toRGB(sTDdata.Color);
             Grid_Attributes[3, 1].View = view;
-            Grid_Attributes[4, 1].Value = Convert.ToBoolean(m_MainForm.STDDictionary[STDId].IfElementAnalysis);
-            Grid_Attributes[5, 1].Value = m_MainForm.STDDictionary[STDId].Hardness;
-            Grid_Attributes[6, 1].Value = m_MainForm.STDDictionary[STDId].Density;
-            Grid_Attributes[7, 1].Value = m_MainForm.STDDictionary[STDId].Electrical_conductivity;
+            Grid_Attributes[4, 1].Value = Convert.ToBoolean(sTDdata.IfElementAnalysis);
+            Grid_Attributes[5, 1].Value = sTDdata.Hardness;
+            Grid_Attributes[6, 1].Value = sTDdata.Density;
+            Grid_Attributes[7, 1].Value = sTDdata.Electrical_conductivity;
 
-            Grid_Attributes[8, 1].Value = int.Parse(m_MainForm.STDDictionary[STDId].BSE);
-            Grid_Attributes[9, 1].Value = m_MainForm.STDDictionary[STDId].Formula;
-            Grid_Attributes[10, 1].Value = m_MainForm.STDDictionary[STDId].Element;
+            Grid_Attributes[8, 1].Value = int.Parse(sTDdata.BSE);
+            Grid_Attributes[9, 1].Value = sTDdata.Formula;
+            Grid_Attributes[10, 1].Value = sTDdata.Element;
 
             //m_MainForm.AddSTDGroupsToAttribute();
-            Grid_Attributes[11, 1].Value = m_MainForm.GroupIdDictionaryFromId[int.Parse(m_MainForm.STDDictionary[STDId].GroupId)];
+            Grid_Attributes[11, 1].Value = m_MainForm._sTDEditor.GroupIdDictionaryFromId[int.Parse(sTDdata.GroupId)];
 
             //SourceGrid.Position po = new SourceGrid.Position(1, 0);
             //Grid_Attributes[1, 0].Grid.Select();
@@ -245,7 +246,7 @@ namespace OTSPartA_STDEditor
             Grid_Attributes[10, 1].Value = sTDdata.Element;
 
             //m_MainForm.AddSTDGroupsToAttribute();
-            Grid_Attributes[11, 1].Value = m_MainForm.GroupIdDictionaryFromId[int.Parse(sTDdata.GroupId)];
+            Grid_Attributes[11, 1].Value = m_MainForm._sTDEditor.GroupIdDictionaryFromId[int.Parse(sTDdata.GroupId)];
 
             //SourceGrid.Position po = new SourceGrid.Position(1, 0);
             //Grid_Attributes[1, 0].Grid.Select();

+ 1 - 1
OTSPartA_STDEditor/UI/Form_GroupId.cs

@@ -408,7 +408,7 @@ namespace OTSPartA_STDEditor
             if (x > 0 && (y == 0|| y == 1))
             {
                 bool bexist = false;
-                foreach (KeyValuePair<int, STDdata> kv in m_MainForm.STDDictionary)
+                foreach (KeyValuePair<int, STDdata> kv in m_MainForm._sTDEditor.STDDictionary)
                 {
                     if(kv.Value.GroupId.ToString()== Grid_FroupId[x, 0].Tag.ToString())
                     {

+ 86 - 640
OTSPartA_STDEditor/UI/Form_Main.cs

@@ -1,4 +1,5 @@
 using OTS.WinFormsUI.Docking;
+using OTSPartA_STDEditor.BaseClass;
 using SourceGrid;
 using System;
 using System.Collections;
@@ -17,32 +18,17 @@ namespace OTSPartA_STDEditor
         public STDRuleslist m_STDRuleslist = null;
         public Attributes m_Attributes = null;
         public SubMidWindow m_SubMidWindow = null;
-        /// <summary>
-        /// 实际存储的字典
-        /// </summary>
-        public Dictionary<int, STDdata> STDDictionary = new Dictionary<int, STDdata>();
-        /// <summary>
-        /// 原始数据字典用于在关闭时比较是否弹出保存提示
-        /// </summary>
-        private Dictionary<int, STDdata> STDDictionaryInitial = new Dictionary<int, STDdata>();
-        public Dictionary<int, string> GroupIdDictionaryFromId = new Dictionary<int, string>();
-        public Dictionary<string, int> GroupIdDictionaryFromName = new Dictionary<string, int>();
-        string STDDBAddress_backupDirectory = Application.StartupPath + "\\Config\\SysData\\LibBackup\\";
         public string STDDBAddress = "";
+        public STDInfo _sTDEditor=null;
         /// <summary>
         /// 0:正在打开的标准库路径;1:所增加标准的颗粒所在结果库位置;2:所增加标准的颗粒FieldId;3:所增加标准的颗粒ParticleId;4:所增加标准的颗粒XRayId
         /// </summary>
         List<string> ImportArgs = new List<string>();
-
         //国际化
         public Language lan;
         Hashtable table;
-
         //是否做出过更改
         public bool IsModified { set; get; }
-        public bool Isoldversion { set; get; }
-
-
         public static readonly string[] ColorGroup = { "#FFB6C1", "#FFC0CB", "#DC143C", "#FFF0F5", "#DB7093", "#FF69B4", "#FF1493", "#C71585", "#DA70D6", "#D8BFD8", "#DDA0DD", "#EE82EE", "#FF00FF", "#8B008B", "#800080", "#BA55D3", "#9400D3", "#9932CC", "#4B0082", "#8A2BE2", "#9370DB","#7B68EE", "#6A5ACD", "#483D8B", "#E6E6FA", "#F8F8FF", "#0000FF", "#0000CD", "#191970", "#00008B", "#000080", "#4169E1" , "#6495ED", "#B0C4DE", "#778899", "#708090", "#1E90FF", "#F0F8FF", "#00FFFF" };
         public Form_Main()
         {
@@ -63,7 +49,6 @@ namespace OTSPartA_STDEditor
                 ImportArgs.Add(it);
             }
         }
-
         private void Form_ConstantsEditor2_Load(object sender, EventArgs e)
         {
             lan = new Language(this);
@@ -80,116 +65,18 @@ namespace OTSPartA_STDEditor
                     var result = m_importStandardLibraryTypeSelection.ShowDialog();
                     if (m_importStandardLibraryTypeSelection.SelectEvent == "expression")
                     {
-                        int STDId = AddSTDDictionaryItem();
-                        m_STDRuleslist.AddNewRow(STDId, "NewClassify", Attributes.colorHx16toRGB(STDDictionary[STDId].Color));
+                        int STDId = _sTDEditor.AddSTDDictionaryItem();
+                        m_STDRuleslist.AddNewRow(STDId, "NewClassify", Attributes.colorHx16toRGB(_sTDEditor.STDDictionary[STDId].Color));
                     }
                 }
             }
         }
 
-        void LoadConstants(string STDDBAddress)
-        {
-            try
-            {
-                System.Data.SQLite.SQLiteConnection m_dbConnection = new System.Data.SQLite.SQLiteConnection("data source='" + STDDBAddress + "'");
-                m_dbConnection.Open();
-                System.Data.SQLite.SQLiteDataAdapter m_dataAdapter = new System.Data.SQLite.SQLiteDataAdapter("select * from Constants", m_dbConnection);
-                DataSet ds = new DataSet();
-                m_dataAdapter.Fill(ds);
-                DataTable dt = ds.Tables[0];
-                if (dt.Rows.Count > 0)
-                {
-                    string ConstantsStr = dt.Rows[0][0].ToString();
-                    ConstantsStr = ConstantsStr.Replace(" ", "");
-                    string[] ConstantsStr2 = ConstantsStr.Split(',');
-                    m_SubMidWindow.m_STDEditor.comboBox_Constants.Items.Clear();
-                    m_SubMidWindow.m_STDEditor.comboBox_Constants.Items.AddRange(ConstantsStr2);
-                }
-                m_dbConnection.Close();
-            }
-            catch (Exception ee)
-            {
-                MessageBox.Show(ee.ToString());
-            }
-        }
-
-        bool LoadClassifyToDictionary(string DBAddress, ref Dictionary<int, STDdata> STDDictionary)
-        {
-            try
-            {
-                //STDDictionaryInitial.Clear();
-
-                System.Data.SQLite.SQLiteConnection m_dbConnection = new System.Data.SQLite.SQLiteConnection("data source='" + DBAddress + "'");
-                m_dbConnection.Open();
-                System.Data.SQLite.SQLiteDataAdapter m_dataAdapter = new System.Data.SQLite.SQLiteDataAdapter("select * from ClassifySTD order by ListNum", m_dbConnection);
-                DataSet ds = new DataSet();
-                m_dataAdapter.Fill(ds);
-                DataTable dt = ds.Tables[0];
-
-                if (dt != null)
-                {
-
-                    if ((dt.Columns.Contains("IfElementAnalysis")))
-                    {
-                        rbSave.Enabled = true;
-                        Isoldversion = false;
-                    }
-                    else
-                    {
-                        MessageBox.Show("该标准库为旧版本,只能进行另存操作!", "注意");
-                        rbSave.Enabled = false;
-                        Isoldversion = true;
-                    }
-                    if (dt.Rows.Count > 0)
-                    {
-                        foreach (DataRow item in dt.Rows)
-                        {
-                            STDdata new_STDdata = new STDdata();
-
-                            new_STDdata.Hardness = item["Hardness"].ToString();
-                            new_STDdata.Density = item["Density"].ToString();
-                            new_STDdata.Electrical_conductivity = item["Electrical_conductivity"].ToString();
-                            new_STDdata.BSE = item["BSE"].ToString();
-                            new_STDdata.Formula = item["Formula"].ToString();
-                            new_STDdata.Element = item["Element"].ToString();
-                            new_STDdata.StrName = item["StrName"].ToString();
-                            new_STDdata.Expression = item["Expression"].ToString();
-                            new_STDdata.Color = item["Color"].ToString();
-                            new_STDdata.KeyElementList = item["KeyElementList"].ToString();
-                            new_STDdata.SubElementList = item["SubElementList"].ToString();
-                            new_STDdata.GroupId = item["GroupId"].ToString();
-                            new_STDdata.ListNum = item["ListNum"].ToString();
-                            new_STDdata.GroupId = item["GroupId"].ToString();
-                            if (dt.Columns.Contains("IfElementAnalysis"))
-                            {
-                                if (Convert.ToBoolean(item["IfElementAnalysis"]))
-                                {
-                                    new_STDdata.IfElementAnalysis = true;
-                                }
-                                else
-                                {
-                                    new_STDdata.IfElementAnalysis = false;
-                                }
-                            }
-                            STDDictionary.Add(int.Parse(item["STDId"].ToString()), new_STDdata);
-                        }
-                    }
-                }
-                return true;
-            }
-            catch /*(Exception ee)*/
-            {
-                MessageBox.Show("The selected standard library is formatted incorrectly, please open the correct standard library!", "Tip");
-                return false;
-            }
-        }
-
         public void ChangeSTDEditorAndGrid_Attributes(int STDId)
         {
             m_SubMidWindow.ChangeText_textbox_STDEditor(STDId);
             m_Attributes.SetDatatoGrid_Attributes(STDId);
         }
-
         private void rbBackup_Click(object sender, EventArgs e)
         {
             if (m_STDRuleslist.Grid_Minerals.Selection.ActivePosition.Row >= 0)
@@ -207,17 +94,16 @@ namespace OTSPartA_STDEditor
                 {
                     if (STDDBAddress == saveFile.FileName)
                     {
-                        MessageBox.Show("不能另存为同名文件!", "Tip");
+                        MessageBox.Show("Cannot save as same name!", "Tip");
                         return;
                     }
                     FormForWaiting forWaiting = new FormForWaiting();
                     forWaiting.Show();
                     System.IO.File.Copy(STDDBAddress, saveFile.FileName, true);
-                    bool result = SaveAsDictionaryToClassify(saveFile.FileName);
+                    bool result = _sTDEditor.SaveAsDictionaryToClassify(saveFile.FileName);
                     if (result)
                     {
-                        STDDictionaryInitial.Clear();
-                        STDDictionaryInitial = Clone(STDDictionary) as Dictionary<int, STDdata>;
+                        _sTDEditor.UpdateSTDDictionaryInitial();
                         STDDBAddress = saveFile.FileName;
                         this.Text = this.Text.Split(' ')[0] + "   " + saveFile.FileName;
                         IsModified = false;
@@ -240,38 +126,7 @@ namespace OTSPartA_STDEditor
                 MessageBox.Show(ex.Message);
             }
         }
-
-        public bool ClearDb(string DBAddress, string DBTableName)
-        {
-            try
-            {
-                System.Data.SQLite.SQLiteConnection m_dbConnection = new System.Data.SQLite.SQLiteConnection("data source='" + DBAddress + "'");
-                m_dbConnection.Open();
-
-                System.Data.SQLite.SQLiteCommand cmm = m_dbConnection.CreateCommand();
-                cmm.CommandText = "delete from " + DBTableName;
-                cmm.ExecuteNonQuery();
-                m_dbConnection.Close();
-                return true;
-            }
-            catch (Exception ex)
-            {
-                MessageBox.Show(ex.ToString());
-                return false;
-            }
-        }
-
-        object Clone(Dictionary<int, STDdata> STDDictionary)
-        {
-            Dictionary<int, STDdata> STDDictionaryInitial = new Dictionary<int, STDdata>();
-            foreach (var key in STDDictionary.Keys)
-            {
-                STDdata tDdata = new STDdata();
-                tDdata = tDdata.Clone(STDDictionary[key]) as STDdata;
-                STDDictionaryInitial.Add(key, tDdata);
-            }
-            return STDDictionaryInitial;
-        }
+        
 
         private void rbSave_Click(object sender, EventArgs e)
         {
@@ -279,15 +134,14 @@ namespace OTSPartA_STDEditor
             {
                 SaveDataOfSelRule(m_STDRuleslist.Grid_Minerals.Selection.ActivePosition.Row, 0);
             }
-            if (RuleformatcheckAndSave())
+            if (Ruleformatcheck())
             {
                 FormForWaiting forWaiting = new FormForWaiting();
                 forWaiting.Show();
-                bool result = SaveDictionaryToClassify(STDDBAddress);
+                bool result = _sTDEditor.SaveDictionaryToClassify();
                 if (result)
                 {
-                    STDDictionaryInitial.Clear();
-                    STDDictionaryInitial = Clone(STDDictionary) as Dictionary<int, STDdata>;
+                    _sTDEditor.UpdateSTDDictionaryInitial();
                     forWaiting.Close();
                     IsModified = false;
                     MessageBox.Show("Save successful!", "Tip");
@@ -305,9 +159,9 @@ namespace OTSPartA_STDEditor
         }
 
 
-        bool RuleformatcheckAndSave()
+        bool Ruleformatcheck()
         {
-            foreach (var ite in STDDictionary)
+            foreach (var ite in _sTDEditor.STDDictionary)
             {
                 if (CheckExpression(ite.Value.Expression))
                 {
@@ -338,6 +192,9 @@ namespace OTSPartA_STDEditor
         {
             return System.Drawing.ColorTranslator.ToHtml(System.Drawing.Color.FromArgb(R, G, B));
         }
+
+
+
         //表达式规则检查
         public bool CheckExpression(string Expression)
         {
@@ -541,44 +398,45 @@ namespace OTSPartA_STDEditor
             return true;
         }
 
+
         public void SaveDataOfSelRule(int PreRow, int PreColumn)
         {
-            STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].StrName = Convert.ToString(m_Attributes.Grid_Attributes[2, 1].Value);
-            STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].Color = colorRGBtoHx16(m_Attributes.Grid_Attributes[3, 1].View.BackColor.R, m_Attributes.Grid_Attributes[3, 1].View.BackColor.G, m_Attributes.Grid_Attributes[3, 1].View.BackColor.B);
-            STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].IfElementAnalysis = Convert.ToBoolean(m_Attributes.Grid_Attributes[4, 1].Value);
-            STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].Hardness = Convert.ToString(m_Attributes.Grid_Attributes[5, 1].Value);
-            STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].Density = Convert.ToString(m_Attributes.Grid_Attributes[6, 1].Value);
-            STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].Electrical_conductivity = Convert.ToString(m_Attributes.Grid_Attributes[7, 1].Value);
-            STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].BSE = Convert.ToString(m_Attributes.Grid_Attributes[8, 1].Value);
+            _sTDEditor.STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].StrName = Convert.ToString(m_Attributes.Grid_Attributes[2, 1].Value);
+            _sTDEditor.STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].Color = colorRGBtoHx16(m_Attributes.Grid_Attributes[3, 1].View.BackColor.R, m_Attributes.Grid_Attributes[3, 1].View.BackColor.G, m_Attributes.Grid_Attributes[3, 1].View.BackColor.B);
+            _sTDEditor.STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].IfElementAnalysis = Convert.ToBoolean(m_Attributes.Grid_Attributes[4, 1].Value);
+            _sTDEditor.STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].Hardness = Convert.ToString(m_Attributes.Grid_Attributes[5, 1].Value);
+            _sTDEditor.STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].Density = Convert.ToString(m_Attributes.Grid_Attributes[6, 1].Value);
+            _sTDEditor.STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].Electrical_conductivity = Convert.ToString(m_Attributes.Grid_Attributes[7, 1].Value);
+            _sTDEditor.STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].BSE = Convert.ToString(m_Attributes.Grid_Attributes[8, 1].Value);
 
 
             if (m_Attributes.Grid_Attributes[9, 1].Value != null)
             {
-                STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].Formula = Convert.ToString(m_Attributes.Grid_Attributes[9, 1].Value);
+                _sTDEditor.STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].Formula = Convert.ToString(m_Attributes.Grid_Attributes[9, 1].Value);
             }
             else
             {
-                STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].Formula = "";
+                _sTDEditor.STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].Formula = "";
             }
             if (m_Attributes.Grid_Attributes[10, 1].Value != null)
             {
-                STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].Element = Convert.ToString(m_Attributes.Grid_Attributes[10, 1].Value);
+                _sTDEditor.STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].Element = Convert.ToString(m_Attributes.Grid_Attributes[10, 1].Value);
             }
             else
             {
-                STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].Element = "";
+                _sTDEditor.STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].Element = "";
             }
 
             if (m_Attributes.Grid_Attributes[11, 1].Value != null)
             {
-                STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].GroupId = GroupIdDictionaryFromName[Convert.ToString(m_Attributes.Grid_Attributes[11, 1].Value)].ToString();
+                _sTDEditor.STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].GroupId = _sTDEditor.GroupIdDictionaryFromName[Convert.ToString(m_Attributes.Grid_Attributes[11, 1].Value)].ToString();
             }
             else
             {
-                STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].GroupId = "0";
+                _sTDEditor.STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].GroupId = "0";
             }
 
-            STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].Expression = m_SubMidWindow.m_STDEditor.textbox_STDEditor.Text.ToString();
+            _sTDEditor.STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].Expression = m_SubMidWindow.m_STDEditor.textbox_STDEditor.Text.ToString();
 
             string sKeyElements = "";
             for (int i = 0; i < m_SubMidWindow.m_STDEditor.dataGridView_KeyElements.Columns.Count; i++)
@@ -600,368 +458,20 @@ namespace OTSPartA_STDEditor
                 sSubElements = sSubElements.Substring(0, sSubElements.Length - 1);
             }
 
-            STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].KeyElementList = sKeyElements;
-            STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].SubElementList = sSubElements;
-
-            STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].ListNum = PreRow.ToString();
-        }
-
-        /// <summary>
-        /// 保存ClassifySTD库和MineralElements库
-        /// </summary>
-        /// <param name="DBAddress"></param>
-        /// <returns></returns>
-        bool SaveDictionaryToClassify(string DBAddress)
-        {
-            //保存列表顺序
-            for (int i = 1; i < m_STDRuleslist.Grid_Minerals.RowsCount; i++)
-            {
-                STDDictionary[(int)m_STDRuleslist.Grid_Minerals[i, 0].Tag].ListNum = i.ToString();
-            }
-            try
-            {
-                System.Data.SQLite.SQLiteConnection m_dbConnection = new System.Data.SQLite.SQLiteConnection("data source='" + DBAddress + "'");
-                m_dbConnection.Open();
-
-                System.Data.SQLite.SQLiteCommand cmm = m_dbConnection.CreateCommand();
-                cmm.CommandText = "delete from ClassifySTD";
-                //cmm.CommandText = "delete from ClassifySTD_Backup";
-                try
-                {
-                    cmm.ExecuteNonQuery();
-                }
-                catch (Exception ex)
-                {
-                    MessageBox.Show(ex.ToString());
-                    return false;
-                }
-
-
-                System.Data.SQLite.SQLiteDataAdapter m_dataAdapter = new System.Data.SQLite.SQLiteDataAdapter("select * from ClassifySTD", m_dbConnection);
-                //System.Data.SQLite.SQLiteDataAdapter m_dataAdapter = new System.Data.SQLite.SQLiteDataAdapter("select * from ClassifySTD_Backup", m_dbConnection);
-                System.Data.SQLite.SQLiteCommandBuilder qLiteCommandBuilder = new System.Data.SQLite.SQLiteCommandBuilder(m_dataAdapter);
-
-                DataSet ds = new DataSet();
-                m_dataAdapter.Fill(ds, "ClassifySTD");
-                DataTable dt = ds.Tables["ClassifySTD"];
-
-                //m_dataAdapter.Fill(ds, "ClassifySTD_Backup");
-                //DataTable dt = ds.Tables["ClassifySTD_Backup"];
-
-                dt.Clear();
-                foreach (KeyValuePair<int, STDdata> kv in STDDictionary)
-                {
-                    string UsingElementList = "";
-                    string UsingImgPropertyList = "";
-                    string UsingOtherPropertyList = "";
-                    List<string> UsingElementL = new List<string>();
-                    List<string> UsingImgPropertyL = new List<string>();
-                    List<string> UsingOtherPropertyL = new List<string>();
-
-                    string str_RemoveBlank = kv.Value.Expression;
-                    ////forth_elem干扰or分隔符,故先行去掉
-                    //if (str_RemoveBlank.Contains("fourth_elem"))
-                    //{
-                    //    str_RemoveBlank = str_RemoveBlank.Replace("fourth_elem", "");
-                    //    UsingOtherPropertyList = "fourth_elem";
-                    //}
-
-                    str_RemoveBlank = str_RemoveBlank.Replace(" ", "");
-                    string[] str_Removeand = System.Text.RegularExpressions.Regex.Split(str_RemoveBlank, "and", System.Text.RegularExpressions.RegexOptions.None);
-                    List<string> str_Removeandor = new List<string>();
-                    for (int i = 0; i < str_Removeand.Length; i++)
-                    {
-                        str_Removeandor.AddRange(System.Text.RegularExpressions.Regex.Split(str_Removeand[i], "or", System.Text.RegularExpressions.RegexOptions.None));
-                    }
-                    List<string> list_all = new List<string>();
-                    for (int i = 0; i < str_Removeandor.Count; i++)
-                    {
-                        list_all.AddRange(str_Removeandor[i].Split(new char[] { '+', '-', '*', '/', '=', '>', '<', '(', ')' }));
-                    }
-                    for (int i = 0; i < list_all.Count; i++)
-                    {
-                        //周期元素?
-                        if (m_SubMidWindow.m_STDEditor.comboBox_PeriodicTable.Items.Contains(list_all[i]))
-                        {
-                            if (!UsingElementL.Contains(list_all[i]))
-                            {
-                                UsingElementL.Add(list_all[i]);
-                            }
-                        }
-                        //first_elem?
-                        if (m_SubMidWindow.m_STDEditor.comboBox_Elem1.Items.Contains(list_all[i]))
-                        {
-                            if (!UsingOtherPropertyL.Contains(list_all[i]))
-                            {
-                                UsingOtherPropertyL.Add(list_all[i]);
-                            }
-                        }
-                        //Element1?
-                        if (m_SubMidWindow.m_STDEditor.comboBox_Elem.Items.Contains(list_all[i]))
-                        {
-                            if (!UsingOtherPropertyL.Contains(list_all[i]))
-                            {
-                                UsingOtherPropertyL.Add(list_all[i]);
-                            }
-                        }
-                        //其它元素?
-                        if (m_SubMidWindow.m_STDEditor.comboBox_ImgProperty.Items.Contains(list_all[i]))
-                        {
-                            if (!UsingImgPropertyL.Contains(list_all[i]))
-                            {
-                                UsingImgPropertyL.Add(list_all[i]);
-                            }
-                        }
-                    }
-                    if (UsingElementL.Count > 0)
-                    {
-                        for (int i = 0; i < UsingElementL.Count - 1; i++)
-                        {
-                            UsingElementList += UsingElementL[i] + ",";
-                        }
-                        UsingElementList += UsingElementL[UsingElementL.Count - 1];
-                    }
-
-                    if (UsingImgPropertyL.Count > 0)
-                    {
-                        for (int i = 0; i < UsingImgPropertyL.Count - 1; i++)
-                        {
-                            UsingImgPropertyList += UsingImgPropertyL[i] + ",";
-                        }
-                        UsingImgPropertyList += UsingImgPropertyL[UsingImgPropertyL.Count - 1];
-                    }
-
-                    if (UsingOtherPropertyL.Count > 0)
-                    {
-                        for (int i = 0; i < UsingOtherPropertyL.Count - 1; i++)
-                        {
-                            UsingOtherPropertyList += UsingOtherPropertyL[i] + ",";
-                        }
-                        UsingOtherPropertyList += UsingOtherPropertyL[UsingOtherPropertyL.Count - 1];
-                    }
-
-                    DataRow newRow = dt.NewRow();
-                    newRow["STDId"] = kv.Key;
-                    newRow["StrName"] = kv.Value.StrName;
-                    newRow["Color"] = kv.Value.Color;
-                    newRow["KeyElementList"] = kv.Value.KeyElementList;
-                    newRow["SubElementList"] = kv.Value.SubElementList;
-                    newRow["UsingImgPropertyList"] = UsingImgPropertyList;
-                    newRow["UsingOtherPropertyList"] = UsingOtherPropertyList;
-                    newRow["Expression"] = kv.Value.Expression;
-                    newRow["Hardness"] = kv.Value.Hardness;
-                    newRow["Density"] = kv.Value.Density;
-                    newRow["Electrical_conductivity"] = kv.Value.Electrical_conductivity;
-                    newRow["BSE"] = int.Parse(kv.Value.BSE);
-                    newRow["Formula"] = kv.Value.Formula;
-                    newRow["Element"] = kv.Value.Element;
-                    newRow["IfElementAnalysis"] = kv.Value.IfElementAnalysis;
-                    newRow["GroupId"] = int.Parse(kv.Value.GroupId);
-                    newRow["ListNum"] = kv.Value.ListNum;
-                    dt.Rows.Add(newRow);
-                }
-                m_dataAdapter.Update(ds, "ClassifySTD");
-                m_dbConnection.Close();
-            }
-            catch (Exception ex)
-            {
-                MessageBox.Show(ex.ToString());
-                return false;
-            }
-            return true;
-        }
-
-        bool SaveAsDictionaryToClassify(string DBAddress)
-        {
-            ////保存列表顺序
-            //for (int i = 1; i < m_STDRuleslist.Grid_Minerals.RowsCount; i++)
-            //{
-            //    STDDictionary[(int)m_STDRuleslist.Grid_Minerals[i, 0].Tag].ListNum = i.ToString();
-            //}
-            try
-            {
-                System.Data.SQLite.SQLiteConnection m_dbConnection = new System.Data.SQLite.SQLiteConnection("data source='" + DBAddress + "'");
-                m_dbConnection.Open();
-
-                System.Data.SQLite.SQLiteCommand cmm = m_dbConnection.CreateCommand();
-                cmm.CommandText = "drop table ClassifySTD";
-                cmm.ExecuteNonQuery();
-
-                cmm.CommandText = "CREATE TABLE ClassifySTD (STDId INTEGER,StrName TEXT, Color TEXT,KeyElementList TEXT,SubElementList TEXT,UsingImgPropertyList TEXT,UsingOtherPropertyList TEXT,Expression TEXT,Hardness TEXT,Density TEXT,Electrical_conductivity TEXT,BSE INTEGER,Formula TEXT,Element TEXT,IfElementAnalysis BOOLEAN,ListNum INT,GroupId INT)";
-                cmm.ExecuteNonQuery();
-
-                System.Data.Common.DbTransaction trans = m_dbConnection.BeginTransaction();
-                trans.Commit();
-
-                System.Data.SQLite.SQLiteDataAdapter m_dataAdapter = new System.Data.SQLite.SQLiteDataAdapter("select * from ClassifySTD", m_dbConnection);
-                System.Data.SQLite.SQLiteCommandBuilder qLiteCommandBuilder = new System.Data.SQLite.SQLiteCommandBuilder(m_dataAdapter);
-
-                DataSet ds = new DataSet();
-                m_dataAdapter.Fill(ds, "ClassifySTD");
-                DataTable dt = ds.Tables["ClassifySTD"];
-
-                foreach (KeyValuePair<int, STDdata> kv in STDDictionary)
-                {
-                    string UsingElementList = "";
-                    string UsingImgPropertyList = "";
-                    string UsingOtherPropertyList = "";
-                    List<string> UsingElementL = new List<string>();
-                    List<string> UsingImgPropertyL = new List<string>();
-                    List<string> UsingOtherPropertyL = new List<string>();
-
-                    string str_RemoveBlank = kv.Value.Expression;
-                    ////forth_elem干扰or分隔符,故先行去掉
-                    //if (str_RemoveBlank.Contains("fourth_elem"))
-                    //{
-                    //    str_RemoveBlank = str_RemoveBlank.Replace("fourth_elem", "");
-                    //    UsingOtherPropertyList = "fourth_elem,";
-                    //}
-
-                    str_RemoveBlank = str_RemoveBlank.Replace(" ", "");
-                    string[] str_Removeand = System.Text.RegularExpressions.Regex.Split(str_RemoveBlank, "and", System.Text.RegularExpressions.RegexOptions.None);
-                    List<string> str_Removeandor = new List<string>();
-                    for (int i = 0; i < str_Removeand.Length; i++)
-                    {
-                        str_Removeandor.AddRange(System.Text.RegularExpressions.Regex.Split(str_Removeand[i], "or", System.Text.RegularExpressions.RegexOptions.None));
-                    }
-                    List<string> list_all = new List<string>();
-                    for (int i = 0; i < str_Removeandor.Count; i++)
-                    {
-                        list_all.AddRange(str_Removeandor[i].Split(new char[] { '+', '-', '*', '/', '=', '>', '<', '(', ')' }));
-                    }
-                    for (int i = 0; i < list_all.Count; i++)
-                    {
-                        //周期元素?
-                        if (m_SubMidWindow.m_STDEditor.comboBox_PeriodicTable.Items.Contains(list_all[i]))
-                        {
-                            if (!UsingElementL.Contains(list_all[i]))
-                            {
-                                UsingElementL.Add(list_all[i]);
-                            }
-                        }
-                        //first_elem?
-                        if (m_SubMidWindow.m_STDEditor.comboBox_Elem1.Items.Contains(list_all[i]))
-                        {
-                            if (!UsingOtherPropertyL.Contains(list_all[i]))
-                            {
-                                UsingOtherPropertyL.Add(list_all[i]);
-                            }
-                        }
-                        //Element1?
-                        if (m_SubMidWindow.m_STDEditor.comboBox_Elem.Items.Contains(list_all[i]))
-                        {
-                            if (!UsingOtherPropertyL.Contains(list_all[i]))
-                            {
-                                UsingOtherPropertyL.Add(list_all[i]);
-                            }
-                        }
-                        //其它元素?
-                        if (m_SubMidWindow.m_STDEditor.comboBox_ImgProperty.Items.Contains(list_all[i]))
-                        {
-                            if (!UsingImgPropertyL.Contains(list_all[i]))
-                            {
-                                UsingImgPropertyL.Add(list_all[i]);
-                            }
-                        }
-                    }
-                    if (UsingElementL.Count > 0)
-                    {
-                        for (int i = 0; i < UsingElementL.Count - 1; i++)
-                        {
-                            UsingElementList += UsingElementL[i] + ",";
-                        }
-                        UsingElementList += UsingElementL[UsingElementL.Count - 1];
-                    }
-
-                    if (UsingImgPropertyL.Count > 0)
-                    {
-                        for (int i = 0; i < UsingImgPropertyL.Count - 1; i++)
-                        {
-                            UsingImgPropertyList += UsingImgPropertyL[i] + ",";
-                        }
-                        UsingImgPropertyList += UsingImgPropertyL[UsingImgPropertyL.Count - 1];
-                    }
-
-                    if (UsingOtherPropertyL.Count > 0)
-                    {
-                        for (int i = 0; i < UsingOtherPropertyL.Count - 1; i++)
-                        {
-                            UsingOtherPropertyList += UsingOtherPropertyL[i] + ",";
-                        }
-                        UsingOtherPropertyList += UsingOtherPropertyL[UsingOtherPropertyL.Count - 1];
-                    }
-
-                    DataRow newRow = dt.NewRow();
-                    newRow["STDId"] = kv.Key;
-                    newRow["StrName"] = kv.Value.StrName;
-                    newRow["Color"] = kv.Value.Color;
-                    newRow["KeyElementList"] = kv.Value.KeyElementList;
-                    newRow["SubElementList"] = kv.Value.SubElementList;
-                    newRow["UsingImgPropertyList"] = UsingImgPropertyList;
-                    newRow["UsingOtherPropertyList"] = UsingOtherPropertyList;
-                    newRow["Expression"] = kv.Value.Expression;
-                    newRow["Hardness"] = kv.Value.Hardness;
-                    newRow["Density"] = kv.Value.Density;
-                    newRow["Electrical_conductivity"] = kv.Value.Electrical_conductivity;
-                    newRow["BSE"] = int.Parse(kv.Value.BSE);
-                    newRow["Formula"] = kv.Value.Formula;
-                    newRow["Element"] = kv.Value.Element;
-                    newRow["IfElementAnalysis"] = kv.Value.IfElementAnalysis;
-                    newRow["GroupId"] = int.Parse(kv.Value.GroupId);
-                    newRow["ListNum"] = kv.Value.ListNum;
-                    dt.Rows.Add(newRow);
-                }
-                m_dataAdapter.Update(ds, "ClassifySTD");
-                m_dbConnection.Close();
-            }
-            catch (Exception ex)
-            {
-                MessageBox.Show(ex.ToString());
-                return false;
-            }
-            return true;
-        }
-
-        public int AddSTDDictionaryItem()
-        {
-            STDdata new_STDdata = new STDdata();//定义一个TreeNode节点对象
-            new_STDdata.Hardness = "1";
-            new_STDdata.Density = "1";
-            new_STDdata.Electrical_conductivity = "1";
-            new_STDdata.BSE = "1";
-            new_STDdata.Formula = "1";
-            new_STDdata.Element = "1";
-            new_STDdata.StrName = "NewRuleName";
-            //new_STDdata.Expression = "NewRules";
-            new_STDdata.Expression = "false";
-            new_STDdata.KeyElementList = "";
-            new_STDdata.SubElementList = "";
-            Random random = new Random();
-            new_STDdata.Color = ColorGroup[random.Next(ColorGroup.Length)];
-
-            int STDId = 40000;
-
-            foreach (KeyValuePair<int, STDdata> kv in STDDictionary)
-            {
-                if (STDId < kv.Key)
-                {
-                    STDId = kv.Key;
-                }
-            }
+            _sTDEditor.STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].KeyElementList = sKeyElements;
+            _sTDEditor.STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].SubElementList = sSubElements;
 
-            STDDictionary.Add(STDId + 1, new_STDdata);
-
-            return STDId + 1;
+            _sTDEditor.STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].ListNum = PreRow.ToString();
         }
 
         public void RemoveSTDDictionaryItem(int STDId)
         {
-            STDDictionary.Remove(STDId);
+            _sTDEditor.STDDictionary.Remove(STDId);
         }
 
         public void ChangeStrName(int RowNum, string NewStrName)
         {
-            STDDictionary[(int)m_STDRuleslist.Grid_Minerals[RowNum, 0].Tag].StrName = NewStrName;
+            _sTDEditor.STDDictionary[(int)m_STDRuleslist.Grid_Minerals[RowNum, 0].Tag].StrName = NewStrName;
             m_Attributes.Grid_Attributes[2, 1].Value = NewStrName;
         }
 
@@ -974,6 +484,8 @@ namespace OTSPartA_STDEditor
             m_STDRuleslist.Grid_Minerals[m_STDRuleslist.Grid_Minerals.Selection.ActivePosition.Row, 0].Value = RuleName;
         }
 
+
+        
         public void SetNull()
         {
             m_SubMidWindow.m_STDEditor.textbox_STDEditor.Text = "";
@@ -1022,18 +534,10 @@ namespace OTSPartA_STDEditor
             {
                 try
                 {
-                    System.Data.SQLite.SQLiteConnection m_dbConnection = new System.Data.SQLite.SQLiteConnection("data source='" + STDDBAddress + "'");
-                    m_dbConnection.Open();
-                    System.Data.SQLite.SQLiteDataAdapter m_dataAdapter = new System.Data.SQLite.SQLiteDataAdapter("select value from Constants", m_dbConnection);
-                    DataSet ds = new DataSet();
-                    m_dataAdapter.Fill(ds);
-                    DataTable dt = ds.Tables[0];
-                    string ConstantsStr = dt.Rows[0][0].ToString();
-                    ConstantsStr = ConstantsStr.Replace(" ", "");
-                    string[] ConstantsStr2 = ConstantsStr.Split(',');
+                    _sTDEditor.LoadConstants();
+                    string[] ConstantsStr2 = _sTDEditor.ConstantsStr;
                     m_SubMidWindow.m_STDEditor.comboBox_Constants.Items.Clear();
                     m_SubMidWindow.m_STDEditor.comboBox_Constants.Items.AddRange(ConstantsStr2);
-                    m_dbConnection.Close();
                 }
                 catch (Exception ee)
                 {
@@ -1045,72 +549,36 @@ namespace OTSPartA_STDEditor
 
         public void AddSTDGroupsToAttribute()
         {
-            try
-            {
-                System.Data.SQLite.SQLiteConnection m_dbConnection = new System.Data.SQLite.SQLiteConnection("data source='" + STDDBAddress + "'");
-                m_dbConnection.Open();
-                System.Data.SQLite.SQLiteDataAdapter m_dataAdapter = new System.Data.SQLite.SQLiteDataAdapter("select name,id from STDGroups order by iorder", m_dbConnection);
-                DataSet ds = new DataSet();
-                m_dataAdapter.Fill(ds);
-                DataTable dt = ds.Tables[0];
-                if (dt != null)
-                {
-                    if (dt.Rows.Count >= 0)
-                    {
-                        GroupIdDictionaryFromId.Clear();
-                        GroupIdDictionaryFromName.Clear();
-
-                        List<string> ss = new List<string>();
-                        if (dt.Select("id='0'").Length == 0)
-                        {
-                            GroupIdDictionaryFromId.Add(0, "Default");
-                            GroupIdDictionaryFromName.Add("Default", 0);
-                            ss.Add("Default");
-                        }
-                        foreach (DataRow item in dt.Rows)
-                        {
-                            ss.Add(item["name"].ToString());
-                            GroupIdDictionaryFromName.Add(item["name"].ToString(), int.Parse(item["id"].ToString()));
-                            GroupIdDictionaryFromId.Add(int.Parse(item["id"].ToString()), item["name"].ToString());
-                        }
-                        SourceGrid.Cells.Editors.ComboBox GroupIdCBBox = new SourceGrid.Cells.Editors.ComboBox(typeof(string));
-                        GroupIdCBBox.StandardValues = ss;
-                        GroupIdCBBox.EditableMode = SourceGrid.EditableMode.SingleClick | SourceGrid.EditableMode.Focus;
-                        m_Attributes.Grid_Attributes[11, 1] = new SourceGrid.Cells.Cell("Default", GroupIdCBBox);
-                        GroupIdCBBox.Control.DropDownStyle = ComboBoxStyle.DropDownList;        //设置下拉框为不可以编辑的状态
-                    }
-                }
-                //string ConstantsStr = dt.Rows[0][0].ToString();
-                m_dbConnection.Close();
-            }
-            catch (Exception ee)
+            List<string> ss = new List<string>();
+            ss.Add("Default");
+            foreach (var item in _sTDEditor.GroupDictionary)
             {
-                MessageBox.Show(ee.ToString());
+                ss.Add(item.Value.name.ToString());
             }
+            SourceGrid.Cells.Editors.ComboBox GroupIdCBBox = new SourceGrid.Cells.Editors.ComboBox(typeof(string));
+            GroupIdCBBox.StandardValues = ss;
+            GroupIdCBBox.EditableMode = SourceGrid.EditableMode.SingleClick | SourceGrid.EditableMode.Focus;
+            m_Attributes.Grid_Attributes[11, 1] = new SourceGrid.Cells.Cell("Default", GroupIdCBBox);
+            GroupIdCBBox.Control.DropDownStyle = ComboBoxStyle.DropDownList;        //设置下拉框为不可以编辑的状态
         }
 
         void SetNonexistentGroupsToDefault()
         {
-            foreach (KeyValuePair<int, STDdata> kv in STDDictionary)
-            {
-                if (!GroupIdDictionaryFromId.Keys.Contains(int.Parse(kv.Value.GroupId)))
-                {
-                    kv.Value.GroupId = "0";
-                }
-            }
+            _sTDEditor.SetNonexistentGroupsToDefault(); ;
             m_Attributes.Grid_Attributes.Refresh();
         }
+        
         private void ribbon_GroupNameMaintenance_Click(object sender, EventArgs e)
         {
             //STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[m_STDRuleslist.Grid_Minerals.Selection.ActivePosition.Row, 0].Tag.ToString())].GroupId = GroupIdDictionaryFromName[m_Attributes.Grid_Attributes[10, 1].Value.ToString()].ToString();
-            int selGroupId = GroupIdDictionaryFromName[m_Attributes.Grid_Attributes[11, 1].Value.ToString()];
+            int selGroupId = _sTDEditor.GroupIdDictionaryFromName[m_Attributes.Grid_Attributes[11, 1].Value.ToString()];
             Form_GroupId form_GroupId = new Form_GroupId(STDDBAddress, this);
             DialogResult dialogResult = form_GroupId.ShowDialog();
             if (dialogResult == DialogResult.Yes)
             {
                 AddSTDGroupsToAttribute();
                 //SetNonexistentGroupsToDefault();
-                m_Attributes.Grid_Attributes[11, 1].Value = GroupIdDictionaryFromId[selGroupId];
+                m_Attributes.Grid_Attributes[11, 1].Value = _sTDEditor.GroupIdDictionaryFromId[selGroupId];
             }
         }
 
@@ -1121,9 +589,9 @@ namespace OTSPartA_STDEditor
 
         private void rbClose_Click(object sender, EventArgs e)
         {
-            if (!Isoldversion)
+            if (!_sTDEditor.Isoldversion)
             {
-                if (!EqualsBetweenDictionary(STDDictionaryInitial, STDDictionary) || IsModified)
+                if (!EqualsBetweenDictionary() || IsModified)
                 {
                     DialogResult dr = MessageBox.Show("Whether to save the current modification?", "Tip", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                     if (dr == DialogResult.Yes)
@@ -1140,13 +608,13 @@ namespace OTSPartA_STDEditor
                             }
 
                         }
-                        else
-                        {
-                            STDDictionaryInitial.Clear();
-                        }
+                        //else
+                        //{
+                        //    STDDictionaryInitial.Clear();
+                        //}
                         FormForWaiting forWaiting = new FormForWaiting();
                         forWaiting.Show();
-                        bool result = SaveDictionaryToClassify(STDDBAddress);
+                        bool result = _sTDEditor.SaveDictionaryToClassify();
                         if (result)
                         {
                             forWaiting.Close();
@@ -1226,11 +694,10 @@ namespace OTSPartA_STDEditor
 
         void InitForms(string DBAddress)
         {
-            STDDictionary.Clear();
             ButtonStatusOpen();
-            bool ret = LoadClassifyToDictionary(DBAddress, ref STDDictionary);
-            STDDictionaryInitial = Clone(STDDictionary) as Dictionary<int, STDdata>;
-            if (!ret)
+
+            _sTDEditor = new STDInfo(DBAddress);
+            if (_sTDEditor.STDDictionary == null|| _sTDEditor.GroupDictionary==null)
             {
                 return;
             }
@@ -1244,18 +711,13 @@ namespace OTSPartA_STDEditor
             m_SubMidWindow.Show(dockPanel1, DockState.Document);
             dockPanel1.DockLeftPortion = 360;
             dockPanel1.DockRightPortion = 381;
-
-            if (m_SubMidWindow.m_STDEditor.m_sc != null)
-            {
-                m_SubMidWindow.m_STDEditor.m_sc.CloseDB();
-            }
-
-            m_SubMidWindow.m_STDEditor.m_sc = new SqlLiteClass(DBAddress);
-
-            LoadConstants(DBAddress);
             AddSTDGroupsToAttribute();
+            m_SubMidWindow.m_STDEditor.comboBox_Constants.Items.Clear();
+            if(_sTDEditor.ConstantsStr != null)
+            { 
+               m_SubMidWindow.m_STDEditor.comboBox_Constants.Items.AddRange(_sTDEditor.ConstantsStr);
+            }
             m_SubMidWindow.m_STDEditor.textbox_STDEditor.Text = "";
-
             if (m_STDRuleslist.Grid_Minerals.RowsCount > 1)
             {
                 m_STDRuleslist.button_UpOrder.Enabled = false;
@@ -1270,40 +732,21 @@ namespace OTSPartA_STDEditor
             }
         }
 
-        bool EqualsBetweenDictionary(Dictionary<int, STDdata> STDDictionaryInitial, Dictionary<int, STDdata> STDDictionary)
-        {
-            if (STDDictionaryInitial.Count != STDDictionary.Count)
-            {
-                return false;
-            }
-
-            foreach (var key in STDDictionaryInitial.Keys)
-            {
-                if (STDDictionary.Keys.Contains(key))
-                {
-                    if (!STDDictionaryInitial[key].Equals(STDDictionary[key]))
-                    {
-                        return false;
-                    }
-                }
-                else
-                {
-                    return false;
-                }
-            }
-
-            return true;
-        }
+        
 
         private void Form_ConstantsEditor2_FormClosing(object sender, FormClosingEventArgs e)
         {
-            if (Isoldversion)
+            if(_sTDEditor==null)
+            {
+                return;
+            }
+            if (_sTDEditor.Isoldversion)
             {
                 return;
             }
             if (m_STDRuleslist.Text != "")
             {
-                if (!EqualsBetweenDictionary(STDDictionaryInitial, STDDictionary) || IsModified)
+                if (!EqualsBetweenDictionary() || IsModified)
                 {
                     DialogResult dr = MessageBox.Show("Whether to save the current modification", "Tip", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                     if (dr == DialogResult.Yes)
@@ -1321,13 +764,13 @@ namespace OTSPartA_STDEditor
                             }
 
                         }
-                        else
-                        {
-                            STDDictionaryInitial.Clear();
-                        }
+                        //else
+                        //{
+                        //    STDDictionaryInitial.Clear();
+                        //}
                         FormForWaiting forWaiting = new FormForWaiting();
                         forWaiting.Show();
-                        bool result = SaveDictionaryToClassify(STDDBAddress);
+                        bool result = _sTDEditor.SaveDictionaryToClassify();
                         if (result)
                         {
                             forWaiting.Close();
@@ -1340,9 +783,9 @@ namespace OTSPartA_STDEditor
                     }
                     else
                     {
-                        foreach (KeyValuePair<int, STDdata> kv in STDDictionary)
+                        foreach (KeyValuePair<int, STDdata> kv in _sTDEditor.STDDictionary)
                         {
-                            if (!GroupIdDictionaryFromId.Keys.Contains(int.Parse(kv.Value.GroupId)))
+                            if (!_sTDEditor.GroupIdDictionaryFromId.Keys.Contains(int.Parse(kv.Value.GroupId)))
                             {
                                 MessageBox.Show("There is non-existent grouping informations in the classification, please adjust!");
                                 e.Cancel = true;
@@ -1353,7 +796,10 @@ namespace OTSPartA_STDEditor
                 }
             }
         }
-
+        bool EqualsBetweenDictionary()
+        {
+            return _sTDEditor.EqualsBetweenDictionary();
+        }
         private void rbNew_Click(object sender, EventArgs e)
         {
             SaveFileDialog saveFile = new SaveFileDialog();

+ 5 - 5
OTSPartA_STDEditor/UI/ReferenceLibrary.cs

@@ -364,7 +364,7 @@ namespace OTSPartA_STDEditor
                             int selrow = PropGrid.Selection.ActivePosition.Row;
                             int STDnum = (int)PropGrid[selrow, 1].Tag;
                             int STDId = 1;
-                            foreach (KeyValuePair<int, STDdata> kv in m_SubMidWindow.m_MainForm.STDDictionary)
+                            foreach (KeyValuePair<int, STDdata> kv in m_SubMidWindow.m_MainForm._sTDEditor.STDDictionary)
                             {
                                 if (STDId < kv.Key)
                                 {
@@ -386,7 +386,7 @@ namespace OTSPartA_STDEditor
                             sT.Electrical_conductivity = ReferenceDictionary[STDnum].Electrical_conductivity;
                             sT.Element = ReferenceDictionary[STDnum].Element;
                             sT.GroupId = ReferenceDictionary[STDnum].GroupId;
-                            m_SubMidWindow.m_MainForm.STDDictionary.Add(STDId + 1, sT);
+                            m_SubMidWindow.m_MainForm._sTDEditor.STDDictionary.Add(STDId + 1, sT);
                             
                             m_SubMidWindow.m_MainForm.m_STDRuleslist.InsertNewRow(STDId + 1, sT.StrName, STDRuleslist.colorHx16toRGB(sT.Color));
                             m_SubMidWindow.m_MainForm.m_STDRuleslist.Refresh();
@@ -448,7 +448,7 @@ namespace OTSPartA_STDEditor
             int STDnum = (int)PropGrid[selrow, 1].Tag;
 
             int STDId = 1;
-            foreach (KeyValuePair<int, STDdata> kv in m_SubMidWindow.m_MainForm.STDDictionary)
+            foreach (KeyValuePair<int, STDdata> kv in m_SubMidWindow.m_MainForm._sTDEditor.STDDictionary)
             {
                 if (STDId < kv.Key)
                 {
@@ -469,14 +469,14 @@ namespace OTSPartA_STDEditor
             sT.SubElementList = ReferenceDictionary[STDnum].SubElementList;
             sT.Electrical_conductivity = ReferenceDictionary[STDnum].Electrical_conductivity;
             sT.Element = ReferenceDictionary[STDnum].Element;
-            if (m_SubMidWindow.m_MainForm.GroupIdDictionaryFromId.ContainsKey(int.Parse(ReferenceDictionary[STDnum].GroupId)))
+            if (m_SubMidWindow.m_MainForm._sTDEditor.GroupIdDictionaryFromId.ContainsKey(int.Parse(ReferenceDictionary[STDnum].GroupId)))
             { sT.GroupId = ReferenceDictionary[STDnum].GroupId; }
             else
             {
                 MessageBox.Show("As this classification group is not defined, it has been adjusted to the default grouping!");
             }
 
-            m_SubMidWindow.m_MainForm.STDDictionary.Add(STDId + 1, sT);
+            m_SubMidWindow.m_MainForm._sTDEditor.STDDictionary.Add(STDId + 1, sT);
 
             m_SubMidWindow.m_MainForm.m_STDRuleslist.AddNewRow(STDId + 1, sT.StrName, STDRuleslist.colorHx16toRGB(sT.Color));
             m_SubMidWindow.m_MainForm.m_STDRuleslist.Refresh();

+ 7 - 47
OTSPartA_STDEditor/UI/STDEditor.cs

@@ -6,6 +6,7 @@ using System.Linq;
 using System.Windows.Forms;
 using System.Collections;
 using System.Text.RegularExpressions;
+using OTSPartA_STDEditor.BaseClass;
 
 namespace OTSPartA_STDEditor
 {
@@ -15,8 +16,6 @@ namespace OTSPartA_STDEditor
         public SubMidWindow m_SubMidWindow = null;
         public int STDId = -1;
         Hashtable table_STDEditor;
-        //数据库操作对象
-        public SqlLiteClass m_sc = null;
         #endregion
 
         public enum Result
@@ -29,7 +28,6 @@ namespace OTSPartA_STDEditor
         public STDEditor(SubMidWindow SubMidWindow)
         {
             InitializeComponent();
-            m_sc = new SqlLiteClass();
             m_SubMidWindow = SubMidWindow;
 
             X = this.Width;
@@ -39,7 +37,6 @@ namespace OTSPartA_STDEditor
         public STDEditor(SubMidWindow SubMidWindow, string STDDBaddress)
         {
             InitializeComponent();
-            m_sc = new SqlLiteClass(STDDBaddress);
             m_SubMidWindow = SubMidWindow;
 
             X = this.Width;
@@ -51,54 +48,17 @@ namespace OTSPartA_STDEditor
         {
             m_SubMidWindow.m_MainForm.lan = new Language(this);
             table_STDEditor = m_SubMidWindow.m_MainForm.lan.GetNameTable("STDEditor");
-            //初始化comboBox
-            this.comboBox_Elem1.Items.Add("first_elem");
-            this.comboBox_Elem1.Items.Add("second_elem");
-            this.comboBox_Elem1.Items.Add("third_elem");
-            this.comboBox_Elem1.Items.Add("fourth_elem");
-            this.comboBox_Elem1.Items.Add("fifth_elem");
-            this.comboBox_Elem1.Items.Add("sixth_elem");
-            this.comboBox_Elem1.Items.Add("seventh_elem");
-            this.comboBox_Elem1.Items.Add("eighth_elem");
-            this.comboBox_Elem1.Items.Add("ninth_elem");
-            this.comboBox_Elem1.Items.Add("tenth_elem");
+            comboBox_Elem1.Items.AddRange(STDInfo.Elem1);
             comboBox_Elem1.SelectedIndex = comboBox_Elem1.Items.IndexOf("first_elem");
-
-            this.comboBox_Elem.Items.Add("Element#1");
-            this.comboBox_Elem.Items.Add("Element#2");
-            this.comboBox_Elem.Items.Add("Element#3");
-            this.comboBox_Elem.Items.Add("Element#4");
-            this.comboBox_Elem.Items.Add("Element#5");
-            this.comboBox_Elem.Items.Add("Element#6");
-            this.comboBox_Elem.Items.Add("Element#7");
-            this.comboBox_Elem.Items.Add("Element#8");
-            this.comboBox_Elem.Items.Add("Element#9");
-            this.comboBox_Elem.Items.Add("Element#10");
+            this.comboBox_Elem.Items.AddRange(STDInfo.Elem2);
             comboBox_Elem.SelectedIndex = comboBox_Elem.Items.IndexOf("Element#1");
-
-            this.comboBox_ImgProperty.Items.Add("Dmax");              //颗粒最大直径;
-            this.comboBox_ImgProperty.Items.Add("Dmin");              //颗粒最小直径;
-            this.comboBox_ImgProperty.Items.Add("Aspect");            //长宽比;
-            this.comboBox_ImgProperty.Items.Add("Dperp");             //与Dmax垂直直径;
-            this.comboBox_ImgProperty.Items.Add("Dmean");             //平均内接圆直径;
-            this.comboBox_ImgProperty.Items.Add("Area");              //面积;
-            this.comboBox_ImgProperty.Items.Add("Dferet");            //费雷特直径;
-            this.comboBox_ImgProperty.Items.Add("Width");             //宽度(直上直下那种);
-            this.comboBox_ImgProperty.Items.Add("Height");            //高度(直上直下那种)
-            this.comboBox_ImgProperty.Items.Add("Perimeter");         //周长
-            this.comboBox_ImgProperty.Items.Add("Dinscr");            //最大内接圆直径
-            this.comboBox_ImgProperty.Items.Add("Orientation");       //朝向
-            this.comboBox_ImgProperty.Items.Add("Delong");            //展开长度
-            this.comboBox_ImgProperty.Items.Add("Aspectelong");       //展开后长宽比
-            this.comboBox_ImgProperty.Items.Add("Dequalcircle");      //等效圆直径
-            this.comboBox_ImgProperty.Items.Add("Vedio");             //BSE灰度平均值
-
+            this.comboBox_ImgProperty.Items.AddRange(STDInfo.ImgProperty);
             comboBox_ImgProperty.SelectedIndex = comboBox_ImgProperty.Items.IndexOf("Dmax");
 
-            string[] PeriodicTable = { "H", "He", "Li", "Be", "B", "C", "N", "O", "F", "Ne", "Na", "Mg", "Al", "Si", "P", "S", "Cl", "Ar", "K", "Ca", "Sc", "Ti", "V", "Cr", "Mn", "Fe", "Co", "Ni", "Cu", "Zn", "Ga", "Ge", "As", "Se", "Br", "Kr", "Rb", "Sr", "Y", "Zr", "Nb", "Mo", "Tc", "Ru", "Rh", "Pd", "Ag", "Cd", "In", "Sn", "Sb", "Te", "I", "Xe", "Cs", "Ba", "La", "Ce", "Pr", "Nd", "Pm", "Sm", "Eu", "Gd", "Tb", "Dy", "Ho", "Er", "Tm", "Yb", "Lu", "Hf", "Ta", "W", "Re", "Os", "Ir", "Pt", "Au", "Hg", "Tl", "Pb", "Bi", "Po", "At", "Rn", "Fr", "Ra", "Ac", "Th", "Pa", "U", "Np", "Pu", "Am", "Cm", "Bk", "Cf", "Es", "Fm", "Md", "No", "Lr", "Rf", "Db", "Sg", "Bh", "Hs", "Mt", "Ds", "Rg", "Unb" };
-            comboBox_PeriodicTable.Items.AddRange(PeriodicTable);
+            
+            comboBox_PeriodicTable.Items.AddRange(STDInfo.PeriodicTable);
             AutoCompleteStringCollection sc = new AutoCompleteStringCollection();
-            sc.AddRange(PeriodicTable);
+            sc.AddRange(STDInfo.PeriodicTable);
             this.comboBox_PeriodicTable.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend;
             this.comboBox_PeriodicTable.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.CustomSource;
             this.comboBox_PeriodicTable.AutoCompleteCustomSource = sc;

+ 19 - 19
OTSPartA_STDEditor/UI/STDRuleslist.cs

@@ -30,7 +30,7 @@ namespace OTSPartA_STDEditor
         {
             m_MainForm.lan = new Language(this);
             table_STDRuleslist = m_MainForm.lan.GetNameTable("Attributes");
-            Grid_Minerals.Redim(m_MainForm.STDDictionary.Count + 1, 2);
+            Grid_Minerals.Redim(m_MainForm._sTDEditor.STDDictionary.Count + 1, 2);
             SourceGrid.Cells.ColumnHeader head1 = null;
             if (m_MainForm.lan.GetNameTable("Form_Main")["language"].ToString() == "EN")
             {
@@ -70,7 +70,7 @@ namespace OTSPartA_STDEditor
 
 
             int i = 1;
-            foreach (KeyValuePair<int, STDdata> kv in m_MainForm.STDDictionary)
+            foreach (KeyValuePair<int, STDdata> kv in m_MainForm._sTDEditor.STDDictionary)
             {
                 Grid_Minerals[i, 0] = new SourceGrid.Cells.Cell(kv.Value.StrName, typeof(string));
                 Grid_Minerals.Rows[i].Height = 25;
@@ -144,8 +144,8 @@ namespace OTSPartA_STDEditor
                 //        {
                             m_MainForm.SaveDataOfSelRule(i, j);
 
-                            int STDId = m_MainForm.AddSTDDictionaryItem();
-                            AddNewRow(STDId, "NewRuleName", Attributes.colorHx16toRGB(m_MainForm.STDDictionary[STDId].Color));
+                            int STDId = m_MainForm._sTDEditor.AddSTDDictionaryItem();
+                            AddNewRow(STDId, "NewRuleName", Attributes.colorHx16toRGB(m_MainForm._sTDEditor.STDDictionary[STDId].Color));
                             m_MainForm.m_SubMidWindow.m_ComparativeLibrary.MakeCheckboxUnchecked();
                 //        }
                 //    }
@@ -153,8 +153,8 @@ namespace OTSPartA_STDEditor
             }
             else
             {
-                int STDId = m_MainForm.AddSTDDictionaryItem();
-                AddNewRow(STDId, "NewRuleName", Attributes.colorHx16toRGB(m_MainForm.STDDictionary[STDId].Color));
+                int STDId = m_MainForm._sTDEditor.AddSTDDictionaryItem();
+                AddNewRow(STDId, "NewRuleName", Attributes.colorHx16toRGB(m_MainForm._sTDEditor.STDDictionary[STDId].Color));
                 m_MainForm.m_SubMidWindow.m_ComparativeLibrary.MakeCheckboxUnchecked();
             }
             //SetOrderButtonsStatus();
@@ -169,7 +169,7 @@ namespace OTSPartA_STDEditor
 
             Grid_Minerals[Grid_Minerals.Rows.Count - 1, 1] = new SourceGrid.Cells.Cell();
             //Grid_Minerals[Grid_Minerals.Rows.Count - 1, 1].AddController(SourceGrid.Cells.Controllers.Unselectable.Default);
-            m_MainForm.STDDictionary[STDId].StrName = RuleName;
+            m_MainForm._sTDEditor.STDDictionary[STDId].StrName = RuleName;
             m_MainForm.ChangeSTDEditorAndGrid_Attributes(STDId);
 
             SourceGrid.Cells.Views.Cell view = new SourceGrid.Cells.Views.Cell();
@@ -344,7 +344,7 @@ namespace OTSPartA_STDEditor
                 Grid_Minerals[1, 0].Grid.Select();
 
                 Grid_Minerals[Grid_Minerals.Selection.ActivePosition.Row, 1].View.BackColor = m_MainForm.m_Attributes.Grid_Attributes[3, 1].View.BackColor;
-                m_MainForm.STDDictionary[(int)Grid_Minerals[Grid_Minerals.Selection.ActivePosition.Row, 0].Tag].Color= Attributes.colorRGBtoHx16(m_MainForm.m_Attributes.Grid_Attributes[3, 1].View.BackColor.R, m_MainForm.m_Attributes.Grid_Attributes[3, 1].View.BackColor.G, m_MainForm.m_Attributes.Grid_Attributes[3, 1].View.BackColor.B);
+                m_MainForm._sTDEditor.STDDictionary[(int)Grid_Minerals[Grid_Minerals.Selection.ActivePosition.Row, 0].Tag].Color= Attributes.colorRGBtoHx16(m_MainForm.m_Attributes.Grid_Attributes[3, 1].View.BackColor.R, m_MainForm.m_Attributes.Grid_Attributes[3, 1].View.BackColor.G, m_MainForm.m_Attributes.Grid_Attributes[3, 1].View.BackColor.B);
                 Grid_Minerals.Refresh();
                 return (int)Grid_Minerals[Grid_Minerals.Selection.ActivePosition.Row, 0].Tag;
             }
@@ -370,17 +370,17 @@ namespace OTSPartA_STDEditor
             Grid_Minerals[selrow, 0].Value = Grid_Minerals[selrow - 1, 0].Value;
             Grid_Minerals[selrow, 0].Tag = id2;
             SourceGrid.Cells.Views.Cell view = new SourceGrid.Cells.Views.Cell();
-            view.BackColor = colorHx16toRGB(m_MainForm.STDDictionary[id2].Color);
+            view.BackColor = colorHx16toRGB(m_MainForm._sTDEditor.STDDictionary[id2].Color);
             Grid_Minerals[selrow, 1].View = view;
 
             Grid_Minerals[selrow - 1, 0].Value = sname;
             Grid_Minerals[selrow - 1, 0].Tag = id;
             SourceGrid.Cells.Views.Cell view2 = new SourceGrid.Cells.Views.Cell();
-            view2.BackColor = colorHx16toRGB(m_MainForm.STDDictionary[id].Color);
+            view2.BackColor = colorHx16toRGB(m_MainForm._sTDEditor.STDDictionary[id].Color);
             Grid_Minerals[selrow - 1, 1].View = view2;
 
-            m_MainForm.STDDictionary[id].StrName = Grid_Minerals[selrow - 1, 0].Value.ToString();
-            m_MainForm.STDDictionary[id2].StrName = Grid_Minerals[selrow, 0].Value.ToString();
+            m_MainForm._sTDEditor.STDDictionary[id].StrName = Grid_Minerals[selrow - 1, 0].Value.ToString();
+            m_MainForm._sTDEditor.STDDictionary[id2].StrName = Grid_Minerals[selrow, 0].Value.ToString();
 
             Position pos = new Position(selrow - 1, 1);
             Grid_Minerals[selrow - 1, 0].Grid.Select();
@@ -409,17 +409,17 @@ namespace OTSPartA_STDEditor
             Grid_Minerals[selrow, 0].Value = Grid_Minerals[selrow + 1, 0].Value;
             Grid_Minerals[selrow, 0].Tag = id2;
             SourceGrid.Cells.Views.Cell view = new SourceGrid.Cells.Views.Cell();
-            view.BackColor = colorHx16toRGB(m_MainForm.STDDictionary[id2].Color);
+            view.BackColor = colorHx16toRGB(m_MainForm._sTDEditor.STDDictionary[id2].Color);
             Grid_Minerals[selrow, 1].View = view;
 
             Grid_Minerals[selrow + 1, 0].Value = sname;
             Grid_Minerals[selrow + 1, 0].Tag = id;
             SourceGrid.Cells.Views.Cell view2 = new SourceGrid.Cells.Views.Cell();
-            view2.BackColor = colorHx16toRGB(m_MainForm.STDDictionary[id].Color);
+            view2.BackColor = colorHx16toRGB(m_MainForm._sTDEditor.STDDictionary[id].Color);
             Grid_Minerals[selrow + 1, 1].View = view2;
 
-            m_MainForm.STDDictionary[id].StrName = Grid_Minerals[selrow + 1, 0].Value.ToString();
-            m_MainForm.STDDictionary[id2].StrName = Grid_Minerals[selrow, 0].Value.ToString();
+            m_MainForm._sTDEditor.STDDictionary[id].StrName = Grid_Minerals[selrow + 1, 0].Value.ToString();
+            m_MainForm._sTDEditor.STDDictionary[id2].StrName = Grid_Minerals[selrow, 0].Value.ToString();
 
             Position pos = new Position(selrow + 1, 0);
             Grid_Minerals[selrow + 1, 0].Grid.Select();
@@ -445,11 +445,11 @@ namespace OTSPartA_STDEditor
             //            Dictionary<int, STDdata> STDDictionaryCopy = new Dictionary<int, STDdata>();
             //            for (int i = 0; i < Grid_Minerals.RowsCount-1; i++)
             //            {
-            //                STDdata dataCopy = m_MainForm.STDDictionary[(int)Grid_Minerals[i+1, 0].Tag];
+            //                STDdata dataCopy = m_MainForm._sTDEditor.STDDictionary[(int)Grid_Minerals[i+1, 0].Tag];
             //                STDDictionaryCopy.Add(StartId + i, dataCopy);
             //            }
-            //            m_MainForm.STDDictionary.Clear();
-            //            m_MainForm.STDDictionary = STDDictionaryCopy;
+            //            m_MainForm._sTDEditor.STDDictionary.Clear();
+            //            m_MainForm._sTDEditor.STDDictionary = STDDictionaryCopy;
             //        }
             //    }
             //}

+ 3 - 3
OTSPartA_STDEditor/UI/SubMidWindow.cs

@@ -51,13 +51,13 @@ namespace OTSPartA_STDEditor
 
         public void ChangeText_textbox_STDEditor(int STDId)
         {
-            m_STDEditor.textbox_STDEditor.Text = m_MainForm.STDDictionary[STDId].Expression;
+            m_STDEditor.textbox_STDEditor.Text = m_MainForm._sTDEditor.STDDictionary[STDId].Expression;
             m_STDEditor.STDId = STDId;
 
             m_STDEditor.dataGridView_KeyElements.Rows.Clear();
             m_STDEditor.dataGridView_KeyElements.Columns.Clear();
 
-            string[] KeyElement = m_MainForm.STDDictionary[STDId].KeyElementList.Trim().Split(',');
+            string[] KeyElement = m_MainForm._sTDEditor.STDDictionary[STDId].KeyElementList.Trim().Split(',');
             for (int i = 0; i < KeyElement.Length; i++)
             {
                 if (KeyElement[0] != "")
@@ -77,7 +77,7 @@ namespace OTSPartA_STDEditor
             m_STDEditor.dataGridView_SubElements.Rows.Clear();
             m_STDEditor.dataGridView_SubElements.Columns.Clear();
 
-            string[] SubElement = m_MainForm.STDDictionary[STDId].SubElementList.Trim().Split(',');
+            string[] SubElement = m_MainForm._sTDEditor.STDDictionary[STDId].SubElementList.Trim().Split(',');
             for (int i = 0; i < SubElement.Length; i++)
             {
                 if (SubElement[i] != "")