瀏覽代碼

编辑器添加默认库 临时提交

CXS 3 年之前
父節點
當前提交
8e721c95c0
共有 2 個文件被更改,包括 41 次插入17 次删除
  1. 7 4
      OTSPartA_STDEditor/Form_ConstantsEditor2.cs
  2. 34 13
      OTSPartA_STDEditor/Form_GroupId.cs

+ 7 - 4
OTSPartA_STDEditor/Form_ConstantsEditor2.cs

@@ -1291,8 +1291,11 @@ namespace OTSPartA_STDEditor
                     {
                         GroupIdDictionaryFromId.Clear();
                         GroupIdDictionaryFromName.Clear();
-                        GroupIdDictionaryFromId.Add(0, "");
-                        GroupIdDictionaryFromName.Add("", 0);
+                        if (dt.Select("id='0'").Length==0)
+                        {
+                            GroupIdDictionaryFromId.Add(0, "Default");
+                            GroupIdDictionaryFromName.Add("Default", 0);
+                        }
 
                         List<string> ss = new List<string>();
                         foreach (DataRow item in dt.Rows)
@@ -1304,7 +1307,7 @@ namespace OTSPartA_STDEditor
                         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[10, 1] = new SourceGrid.Cells.Cell("", GroupIdCBBox);
+                        m_Attributes.Grid_Attributes[10, 1] = new SourceGrid.Cells.Cell("Default", GroupIdCBBox);
                     }
                 }
                 //string ConstantsStr = dt.Rows[0][0].ToString();
@@ -1623,7 +1626,7 @@ namespace OTSPartA_STDEditor
                     this.Text = this.Text.Split(' ')[0] + "   " + STDDBAddress;
                     IsModified = false;
                 }
-                catch/*(Exception ex)*/
+                catch (Exception ex)
                 {
                     MessageBox.Show(table["message6"].ToString(), table["message32"].ToString());
                 }

+ 34 - 13
OTSPartA_STDEditor/Form_GroupId.cs

@@ -43,17 +43,27 @@ namespace OTSPartA_STDEditor
 
                 if (dt != null)
                 {
+                    STDGroups new_data = new STDGroups();
+                    new_data.name = "Default";
+                    new_data.color = "#FFFFFF";
+                    new_data.iorder = 999;
+                    MineralGroupDictionary.Add(0, new_data);
+                    
                     if (dt.Rows.Count > 0)
                     {
                         foreach (DataRow item in dt.Rows)
                         {
-                            STDGroups new_STDdata = new STDGroups();
-                            new_STDdata.name = item["name"].ToString();
-                            new_STDdata.color = item["color"].ToString();
-                            new_STDdata.iorder = int.Parse(item["iorder"].ToString());
-                            MineralGroupDictionary.Add(int.Parse(item["id"].ToString()), new_STDdata);
+                            if (item["name"].ToString() != "Default")
+                            {
+                                STDGroups new_STDdata = new STDGroups();
+                                new_STDdata.name = item["name"].ToString();
+                                new_STDdata.color = item["color"].ToString();
+                                new_STDdata.iorder = int.Parse(item["iorder"].ToString());
+                                MineralGroupDictionary.Add(int.Parse(item["id"].ToString()), new_STDdata);
+                            }
                         }
                     }
+                    
                 }
 
                 m_dbConnection.Close();
@@ -172,7 +182,10 @@ namespace OTSPartA_STDEditor
         {
             for (int i = 1; i < Grid_FroupId.RowsCount; i++)
             {
-                MineralGroupDictionary[(int)Grid_FroupId[i, 0].Tag].iorder = i;
+                if(MineralGroupDictionary[(int)Grid_FroupId[i, 0].Tag].iorder!=999)
+                {
+                    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();
@@ -220,7 +233,7 @@ namespace OTSPartA_STDEditor
             lan = new Language(this);
             table_GroupId = lan.GetNameTable("Form_GroupId");
 
-            bool result = LoadDataFromDb(MineralGroupDBAddress);
+            bool result = LoadDataFromDb(MineralGroupDBAddress); 
             if(result)
             {
                 Grid_FroupId.Redim(MineralGroupDictionary.Count + 1, 2);
@@ -371,6 +384,11 @@ namespace OTSPartA_STDEditor
             int y = Grid_FroupId.Selection.ActivePosition.Column;
             if (x > 0 && (y == 0|| y == 1))
             {
+                if(x==1)
+                {
+                    MessageBox.Show("Group by default,can not be deleted!");
+                    return;
+                }
                 RemoveMineralGroupDictionaryItem((int)Grid_FroupId[x, 0].Tag);
                 Grid_FroupId.Rows.Remove(x);
                 Grid_FroupId.Refresh();
@@ -477,22 +495,25 @@ namespace OTSPartA_STDEditor
             /// 保证鼠标点击的GRID行和列是有效的
             if (i >= 0 && j >= 0)
             {
-                if (i == 1)
+                if (i == ls_gd.RowsCount - 1)
                 {
-                    button_up.Enabled = false;
+                    button_down.Enabled = false;
                 }
                 else
                 {
-                    button_up.Enabled = true;
+                    button_down.Enabled = true;
                 }
-                if (i == ls_gd.RowsCount - 1)
+                if (i == 1)
                 {
-                    button_down.Enabled = false;
+                    button_up.Enabled = false;
+                    MessageBox.Show("Group by default, not editable!");
+                    return;
                 }
                 else
                 {
-                    button_down.Enabled = true;
+                    button_up.Enabled = true;
                 }
+                
             }
         }
     }