ソースを参照

编辑器推送

CXS 3 年 前
コミット
ba406e4457

+ 24 - 0
OTSPartA_STDEditor/Form_ConstantsEditor2.cs

@@ -1319,6 +1319,17 @@ namespace OTSPartA_STDEditor
             }
         }
 
+        void SetNonexistentGroupsToDefault()
+        {
+            foreach (KeyValuePair<int, STDdata> kv in STDDictionary)
+            {
+                if(!GroupIdDictionaryFromId.Keys.Contains(int.Parse(kv.Value.GroupId)))
+                {
+                    kv.Value.GroupId = "0";
+                }
+            }
+            m_Attributes.Grid_Attributes.Refresh();
+        }
         private void ribbon_GroupNameMaintenance_Click(object sender, EventArgs e)
         {
             Form_GroupId form_GroupId = new Form_GroupId(STDDBAddress);
@@ -1326,6 +1337,7 @@ namespace OTSPartA_STDEditor
             if (dialogResult == DialogResult.Yes)
             {
                 AddSTDGroupsToAttribute();
+                SetNonexistentGroupsToDefault();
             }
         }
 
@@ -1849,6 +1861,18 @@ namespace OTSPartA_STDEditor
                             MessageBox.Show(table["message2"].ToString(), table["message32"].ToString());
                         }
                     }
+                    else
+                    {
+                        foreach (KeyValuePair<int, STDdata> kv in STDDictionary)
+                        {
+                            if (!GroupIdDictionaryFromId.Keys.Contains(int.Parse(kv.Value.GroupId)))
+                            {
+                                MessageBox.Show("There is non-existent grouping informations in the classification, please adjust!");
+                                e.Cancel = true;
+                                return;
+                            }
+                        }
+                    }
                 }
             }
                                 

+ 45 - 25
OTSPartA_STDEditor/Form_GroupId.cs

@@ -19,7 +19,7 @@ namespace OTSPartA_STDEditor
 
         string MineralGroupDBAddress = Application.StartupPath + "\\Config\\SysData\\" + "OTSCleanlinesSTD.db";
         Dictionary<int,STDGroups> MineralGroupDictionary = new Dictionary<int, STDGroups>();
-
+        //Dictionary<int, STDGroups> MineralGroupDictionaryInitial = new Dictionary<int, STDGroups>();
         /// <summary>
         ///数据库修改状态
         /// </summary>
@@ -29,7 +29,17 @@ namespace OTSPartA_STDEditor
             Modify = 1,
             Delete = 2
         }
-
+        object Clone(Dictionary<int, STDGroups> Dictionary)
+        {
+            Dictionary<int, STDGroups> DictionaryInitial = new Dictionary<int, STDGroups>();
+            foreach (var key in Dictionary.Keys)
+            {
+                STDGroups DGroups = new STDGroups();
+                DGroups = DGroups.Clone(Dictionary[key]) as STDGroups;
+                DictionaryInitial.Add(key,DGroups);
+            }
+            return DictionaryInitial;
+        }
         bool LoadDataFromDb(string DBaddress)
         {
             try
@@ -45,7 +55,7 @@ namespace OTSPartA_STDEditor
                 {
                     STDGroups new_data = new STDGroups();
                     new_data.name = "Default";
-                    new_data.color = "#FFFFFF";
+                    new_data.color = "#C9C9C9";
                     new_data.iorder = 999;
                     MineralGroupDictionary.Add(0, new_data);
                     
@@ -180,12 +190,9 @@ namespace OTSPartA_STDEditor
 
         void SaveDataIntoDB(string DBAddress)
         {
-            for (int i = 1; i < Grid_FroupId.RowsCount; i++)
+            for (int i = 2; i < Grid_FroupId.RowsCount; i++)
             {
-                if(MineralGroupDictionary[(int)Grid_FroupId[i, 0].Tag].iorder!=999)
-                {
-                    MineralGroupDictionary[(int)Grid_FroupId[i, 0].Tag].iorder = i-1;
-                }
+                MineralGroupDictionary[(int)Grid_FroupId[i, 0].Tag].iorder = i-1;
             }
             System.Data.SQLite.SQLiteConnection m_dbConnection = new System.Data.SQLite.SQLiteConnection("data source='" + DBAddress + "'");
             m_dbConnection.Open();
@@ -264,28 +271,41 @@ namespace OTSPartA_STDEditor
                 Grid_FroupId[0, 0].AddController(SourceGrid.Cells.Controllers.Unselectable.Default);
                 Grid_FroupId[0, 1].AddController(SourceGrid.Cells.Controllers.Unselectable.Default);
 
+                Grid_FroupId[1, 0] = new SourceGrid.Cells.Cell("Default", typeof(string));
+                Grid_FroupId[1, 1] = new SourceGrid.Cells.Cell("", typeof(string));
+                Grid_FroupId.Rows[1].Height = 25;
+                Grid_FroupId[1, 0].Tag = 0;
+
+                SourceGrid.Cells.Views.Cell vw = new SourceGrid.Cells.Views.Cell();
+                vw.BackColor = Attributes.colorHx16toRGB("#C9C9C9");
+                Grid_FroupId[1, 1].View = vw;
+                Grid_FroupId[1, 0].AddController(SourceGrid.Cells.Controllers.Unselectable.Default);
+                Grid_FroupId[1, 1].AddController(SourceGrid.Cells.Controllers.Unselectable.Default);
 
-                int i = 1;
+                int i = 2;
                 foreach (KeyValuePair<int, STDGroups> kv in MineralGroupDictionary)
                 {
-                    Grid_FroupId[i, 0] = new SourceGrid.Cells.Cell(kv.Value.name, typeof(string));
-                    Grid_FroupId[i, 1] = new SourceGrid.Cells.Cell("", typeof(string));
-                    Grid_FroupId.Rows[i].Height = 25;
-                    Grid_FroupId[i, 0].Tag = kv.Key;
+                    if (kv.Key != 0)
+                    {
+                        Grid_FroupId[i, 0] = new SourceGrid.Cells.Cell(kv.Value.name, typeof(string));
+                        Grid_FroupId[i, 1] = new SourceGrid.Cells.Cell("", typeof(string));
+                        Grid_FroupId.Rows[i].Height = 25;
+                        Grid_FroupId[i, 0].Tag = kv.Key;
 
-                    SourceGrid.Cells.Views.Cell vew = new SourceGrid.Cells.Views.Cell();
-                    vew.BackColor = Attributes.colorHx16toRGB(kv.Value.color);
-                    Grid_FroupId[i, 1].View = vew;
+                        SourceGrid.Cells.Views.Cell vew = new SourceGrid.Cells.Views.Cell();
+                        vew.BackColor = Attributes.colorHx16toRGB(kv.Value.color);
+                        Grid_FroupId[i, 1].View = vew;
 
-                    SourceGrid.Cells.Controllers.CustomEvents clickEvent = new SourceGrid.Cells.Controllers.CustomEvents();
-                    clickEvent.ValueChanged += new EventHandler(clickEvent_ValueChanged);
-                    Grid_FroupId[i, 0].AddController(clickEvent);
+                        SourceGrid.Cells.Controllers.CustomEvents clickEvent = new SourceGrid.Cells.Controllers.CustomEvents();
+                        clickEvent.ValueChanged += new EventHandler(clickEvent_ValueChanged);
+                        Grid_FroupId[i, 0].AddController(clickEvent);
 
-                    SourceGrid.Cells.Controllers.CustomEvents clickEvent2 = new SourceGrid.Cells.Controllers.CustomEvents();
-                    clickEvent2.Click+= new EventHandler(clickEvent_Click);
-                    Grid_FroupId[i, 1].AddController(clickEvent2);
+                        SourceGrid.Cells.Controllers.CustomEvents clickEvent2 = new SourceGrid.Cells.Controllers.CustomEvents();
+                        clickEvent2.Click += new EventHandler(clickEvent_Click);
+                        Grid_FroupId[i, 1].AddController(clickEvent2);
 
-                    i++;
+                        i++;
+                    }
                 }
             }
             else
@@ -506,8 +526,8 @@ namespace OTSPartA_STDEditor
                 if (i == 1)
                 {
                     button_up.Enabled = false;
-                    MessageBox.Show("Group by default, not editable!");
-                    return;
+                    //MessageBox.Show("Group by default, not editable!");
+                    //return;
                 }
                 else
                 {

+ 9 - 0
OTSPartA_STDEditor/STDGroups.cs

@@ -39,5 +39,14 @@ namespace OTSPartA_STDEditor
             set { i_InfoState = value; }
             get { return i_InfoState; }
         }
+        public object Clone(STDGroups a_oSource)
+        {
+            STDGroups MySTDGroups = new STDGroups();
+            MySTDGroups.name = a_oSource.name;
+            MySTDGroups.color = a_oSource.color;
+            MySTDGroups.iorder = a_oSource.iorder;
+            MySTDGroups.InfoState = a_oSource.InfoState;
+            return MySTDGroups;
+        }
     }
 }