cxs 4 месяцев назад
Родитель
Сommit
c163c8c48a

+ 14 - 6
OTSPartA_STDEditor/BaseClass/STDGroups.cs

@@ -8,17 +8,19 @@ namespace OTSPartA_STDEditor
 {
     public class STDGroups
     {
-        //int s_id = 0;
+        int s_id = 0;
         string s_name = "";
         string s_color = "#FFFFFF";
         int i_iorder = 0;
         int i_InfoState = 1;
+        List<STDdata> _ContainSTD=new List<STDdata>();
 
-        //public int id
-        //{
-        //    set { s_id = value; }
-        //    get { return s_id; }
-        //}
+
+        public int id
+        {
+            set { s_id = value; }
+            get { return s_id; }
+        }
         public string name
         {
             set { s_name = value; }
@@ -39,9 +41,15 @@ namespace OTSPartA_STDEditor
             set { i_InfoState = value; }
             get { return i_InfoState; }
         }
+        public List<STDdata> ContainSTD
+        {
+            set { _ContainSTD = value;}
+            get { return _ContainSTD;}
+        }
         public object Clone(STDGroups a_oSource)
         {
             STDGroups MySTDGroups = new STDGroups();
+            MySTDGroups.id=a_oSource.id;
             MySTDGroups.name = a_oSource.name;
             MySTDGroups.color = a_oSource.color;
             MySTDGroups.iorder = a_oSource.iorder;

+ 6 - 6
OTSPartA_STDEditor/BaseClass/STDdata.cs

@@ -8,7 +8,7 @@ namespace OTSPartA_STDEditor
 {
     public class STDdata
     {
-        //string s_STDId = "";
+        string s_STDId = "";
         string s_StrName = "";
         string s_Color = "#FFFFFF";
         string s_KeyElementList = "";
@@ -27,11 +27,11 @@ namespace OTSPartA_STDEditor
         bool b_IfElementAnalysis = true;
 
 
-        //public string STDId
-        //{
-        //    set { s_STDId = value; }
-        //    get { return s_STDId; }
-        //}
+        public string STDId
+        {
+            set { s_STDId = value; }
+            get { return s_STDId; }
+        }
 
         public string Hardness
         {

+ 10 - 3
OTSPartA_STDEditor/UI/Form_Main.cs

@@ -169,8 +169,16 @@ namespace OTSPartA_STDEditor
                 }
                 else
                 {
-                    Position pos = new Position(Convert.ToInt32(ite.Value.ListNum), 0);
-                    m_STDRuleslist.Grid_Minerals[Convert.ToInt32(ite.Value.ListNum), 0].Grid.Select();
+                    int Id = 0;
+                    for (int i = 1; i < m_STDRuleslist.Grid_Minerals.RowsCount; i++)
+                    {
+                        if((int)m_STDRuleslist.Grid_Minerals[i, 0].Tag == ite.Key)
+                        {
+                            Id = i;break;
+                        }
+                    }
+                    Position pos = new Position(Id, 0);
+                    m_STDRuleslist.Grid_Minerals[Id, 0].Grid.Select();
                     m_STDRuleslist.Grid_Minerals.Selection.Focus(pos, true);
                     m_STDRuleslist.Grid_Minerals.Refresh();
                     ChangeSTDEditorAndGrid_Attributes(ite.Key);
@@ -550,7 +558,6 @@ namespace OTSPartA_STDEditor
         public void AddSTDGroupsToAttribute()
         {
             List<string> ss = new List<string>();
-            ss.Add("Default");
             foreach (var item in _sTDEditor.GroupDictionary)
             {
                 ss.Add(item.Value.name.ToString());

+ 9 - 9
OTSPartA_STDEditor/UI/STDRuleslist.Designer.cs

@@ -34,7 +34,7 @@
             this.ToolStripMenuItem_Del = new System.Windows.Forms.ToolStripMenuItem();
             this.tabControl1 = new System.Windows.Forms.TabControl();
             this.tabPage_GroupView = new System.Windows.Forms.TabPage();
-            this.treeView1 = new System.Windows.Forms.TreeView();
+            this.treeView_G = new System.Windows.Forms.TreeView();
             this.tabPage_RuleView = new System.Windows.Forms.TabPage();
             this.Grid_Minerals = new SourceGrid.Grid();
             this.button_DownOrder = new System.Windows.Forms.Button();
@@ -86,7 +86,7 @@
             // 
             // tabPage_GroupView
             // 
-            this.tabPage_GroupView.Controls.Add(this.treeView1);
+            this.tabPage_GroupView.Controls.Add(this.treeView_G);
             this.tabPage_GroupView.Location = new System.Drawing.Point(4, 4);
             this.tabPage_GroupView.Name = "tabPage_GroupView";
             this.tabPage_GroupView.Padding = new System.Windows.Forms.Padding(3);
@@ -95,13 +95,13 @@
             this.tabPage_GroupView.Text = "分组视图";
             this.tabPage_GroupView.UseVisualStyleBackColor = true;
             // 
-            // treeView1
+            // treeView_G
             // 
-            this.treeView1.Dock = System.Windows.Forms.DockStyle.Fill;
-            this.treeView1.Location = new System.Drawing.Point(3, 3);
-            this.treeView1.Name = "treeView1";
-            this.treeView1.Size = new System.Drawing.Size(299, 750);
-            this.treeView1.TabIndex = 0;
+            this.treeView_G.Dock = System.Windows.Forms.DockStyle.Fill;
+            this.treeView_G.Location = new System.Drawing.Point(3, 3);
+            this.treeView_G.Name = "treeView_G";
+            this.treeView_G.Size = new System.Drawing.Size(299, 750);
+            this.treeView_G.TabIndex = 0;
             // 
             // tabPage_RuleView
             // 
@@ -190,7 +190,7 @@
         private System.Windows.Forms.TabPage tabPage_RuleView;
         public System.Windows.Forms.Button button_DownOrder;
         public System.Windows.Forms.Button button_UpOrder;
-        private System.Windows.Forms.TreeView treeView1;
+        private System.Windows.Forms.TreeView treeView_G;
         public SourceGrid.Grid Grid_Minerals;
     }
 }

+ 82 - 4
OTSPartA_STDEditor/UI/STDRuleslist.cs

@@ -9,6 +9,7 @@ using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
 using System.Windows.Forms;
+using static System.Windows.Forms.VisualStyles.VisualStyleElement;
 
 namespace OTSPartA_STDEditor
 {
@@ -17,7 +18,7 @@ namespace OTSPartA_STDEditor
         public int PreRow = 1;//之前选中的位置
         public Form_Main m_MainForm = null;
         ValueChangedEvent m_ValueChangedEvent = null;//单元格内容改变事件
-
+        Dictionary<int,STDGroups> GroupViewDic=null;
         public STDRuleslist(Form_Main mainForm)
         {
             InitializeComponent();
@@ -120,7 +121,42 @@ namespace OTSPartA_STDEditor
 
         private void MineralsGrid_Click(object sender, EventArgs e)
         {
+            SourceGrid.Grid ls_gd = (SourceGrid.Grid)sender;
+            ls_gd.Focus();
+            int i = ls_gd.Selection.ActivePosition.Row;
+            int j = ls_gd.Selection.ActivePosition.Column;
+            //string jj =m_MainForm.m_Attributes.Grid_Attributes[10, 1].Value.ToString();
+            /// 保证鼠标点击的GRID行和列是有效的
+            if (i >= 0 && j >= 0)
+            {
+                ////规则名称不为空
+                //if (Grid_Minerals[i, 0].Value.ToString().Replace(" ", "").Trim() != "")
+                //{
+                //    if (m_MainForm.CheckAttributes() && m_MainForm.Checktextbox_STDEditor())
+                //    {
+
+                m_MainForm.SaveDataOfSelRule(PreRow, 0);
+                m_MainForm.ChangeSTDEditorAndGrid_Attributes(int.Parse(Grid_Minerals[i, 0].Tag.ToString()));
+                m_MainForm.m_SubMidWindow.m_ComparativeLibrary.MakeCheckboxUnchecked();
+                PreRow = i;
+
+                //    }
+                //    else
+                //    {
+                //        Position pos = new Position(PreRow, 0);
+                //        Grid_Minerals.Selection.Focus(pos, true);
+                //        m_MainForm.m_SubMidWindow.m_ComparativeLibrary.MakeCheckboxUnchecked();
+                //    }
+                //}
+                //else
+                //{
+                //    Position pos = new Position(PreRow, 0);
+                //    Grid_Minerals.Selection.Focus(pos, true);
+                //    m_MainForm.m_SubMidWindow.m_ComparativeLibrary.MakeCheckboxUnchecked();
+                //}
+            }
 
+            SetOrderButtonsStatus();
         }
         /// <summary>
         /// 新建
@@ -517,7 +553,6 @@ namespace OTSPartA_STDEditor
                 button_DownOrder.Enabled = false;
             }
         }
-
         private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
         {
             if (tabControl1.SelectedIndex == 0)
@@ -526,13 +561,56 @@ namespace OTSPartA_STDEditor
             }
             else if (tabControl1.SelectedIndex == 1)
             {
-                
+                ConvertToRuleViewDic();
             }
         }
-
         void InitGroupEditorView()
         {
+            GroupViewDic = ConvertToGroupViewDic();
+            foreach(STDGroups group in GroupViewDic.Values)
+            {
+                TreeNode treeNode = new TreeNode();
+                treeNode.Tag = group;
+                treeNode.Text=group.name;
+                treeNode.BackColor= Attributes.colorHx16toRGB(group.color);
+                treeView_G.Nodes.Add(treeNode);
+                foreach(STDdata ddata in group.ContainSTD)
+                {
+                    TreeNode childtreeNode = new TreeNode();
+                    childtreeNode.Tag = ddata;
+                    childtreeNode.Text = ddata.StrName;
+                    treeNode.Nodes.Add(childtreeNode);
+                }
+            }
 
+            treeView_G.Font = new Font("微软雅黑", 12);
+            treeView_G.ShowLines=false;
+            //treeView_G.ExpandAll();
+            this.Refresh();
+        }
+        Dictionary<int, STDGroups> ConvertToGroupViewDic()
+        {
+            Dictionary<int, STDGroups> keyValuePairs = new Dictionary<int, STDGroups>();
+            keyValuePairs = m_MainForm._sTDEditor.GroupDictionary;
+            foreach (STDGroups group in keyValuePairs.Values)
+            {
+                group.ContainSTD.Clear();
+            }
+            foreach (STDdata Ddata in  m_MainForm._sTDEditor.STDDictionary.Values)
+            {
+                keyValuePairs[int.Parse(Ddata.GroupId)].ContainSTD.Add(Ddata);
+            }
+            return keyValuePairs;
+        }
+        void ConvertToRuleViewDic()
+        {
+            foreach (STDGroups group in GroupViewDic.Values)
+            {
+                foreach (STDdata Ddata in group.ContainSTD)
+                {
+                    m_MainForm._sTDEditor.STDDictionary[int.Parse(Ddata.STDId)].GroupId = group.id.ToString();
+                }
+            }
         }
     }
 }