瀏覽代碼

修改bug

cxs 3 月之前
父節點
當前提交
8f50a85c54
共有 2 個文件被更改,包括 75 次插入12 次删除
  1. 15 3
      OTSPartA_STDEditor/UI/STDRuleslist.Designer.cs
  2. 60 9
      OTSPartA_STDEditor/UI/STDRuleslist.cs

+ 15 - 3
OTSPartA_STDEditor/UI/STDRuleslist.Designer.cs

@@ -39,6 +39,7 @@
             this.ToolStripMenuItem_NewGroup = new System.Windows.Forms.ToolStripMenuItem();
             this.ToolStripMenuItem_DelGroup = new System.Windows.Forms.ToolStripMenuItem();
             this.ToolStripMenuItem_EDGcolor = new System.Windows.Forms.ToolStripMenuItem();
+            this.ToolStripMenuItem_RenameGroup = new System.Windows.Forms.ToolStripMenuItem();
             this.tabPage_RuleView = new System.Windows.Forms.TabPage();
             this.Grid_Minerals = new SourceGrid.Grid();
             this.button_DownOrder = new System.Windows.Forms.Button();
@@ -57,7 +58,7 @@
             this.ToolStripMenuItem_New,
             this.ToolStripMenuItem_Del});
             this.MenuStrip_STDRulelist.Name = "MenuStrip_STDRulelist";
-            this.MenuStrip_STDRulelist.Size = new System.Drawing.Size(101, 50);
+            this.MenuStrip_STDRulelist.Size = new System.Drawing.Size(101, 48);
             // 
             // ToolStripMenuItem_New
             // 
@@ -104,10 +105,12 @@
             this.treeView_G.AllowDrop = true;
             this.treeView_G.ContextMenuStrip = this.contextMenuStrip_GroupView;
             this.treeView_G.Dock = System.Windows.Forms.DockStyle.Fill;
+            this.treeView_G.LabelEdit = true;
             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;
+            this.treeView_G.AfterLabelEdit += new System.Windows.Forms.NodeLabelEditEventHandler(this.treeView_G_AfterLabelEdit);
             this.treeView_G.ItemDrag += new System.Windows.Forms.ItemDragEventHandler(this.treeView_G_ItemDrag);
             this.treeView_G.NodeMouseClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.treeView_G_NodeMouseClick);
             this.treeView_G.DragDrop += new System.Windows.Forms.DragEventHandler(this.treeView_G_DragDrop);
@@ -118,9 +121,10 @@
             this.contextMenuStrip_GroupView.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
             this.ToolStripMenuItem_NewGroup,
             this.ToolStripMenuItem_DelGroup,
-            this.ToolStripMenuItem_EDGcolor});
+            this.ToolStripMenuItem_EDGcolor,
+            this.ToolStripMenuItem_RenameGroup});
             this.contextMenuStrip_GroupView.Name = "contextMenuStrip_GroupView";
-            this.contextMenuStrip_GroupView.Size = new System.Drawing.Size(137, 70);
+            this.contextMenuStrip_GroupView.Size = new System.Drawing.Size(137, 92);
             // 
             // ToolStripMenuItem_NewGroup
             // 
@@ -143,6 +147,13 @@
             this.ToolStripMenuItem_EDGcolor.Text = "修改组颜色";
             this.ToolStripMenuItem_EDGcolor.Click += new System.EventHandler(this.ToolStripMenuItem_EdGroupColor_Click);
             // 
+            // ToolStripMenuItem_RenameGroup
+            // 
+            this.ToolStripMenuItem_RenameGroup.Name = "ToolStripMenuItem_RenameGroup";
+            this.ToolStripMenuItem_RenameGroup.Size = new System.Drawing.Size(136, 22);
+            this.ToolStripMenuItem_RenameGroup.Text = "修改组名称";
+            this.ToolStripMenuItem_RenameGroup.Click += new System.EventHandler(this.ToolStripMenuItem_RenameGroup_Click);
+            // 
             // tabPage_RuleView
             // 
             this.tabPage_RuleView.Controls.Add(this.Grid_Minerals);
@@ -239,5 +250,6 @@
         private System.Windows.Forms.ToolStripMenuItem ToolStripMenuItem_DelGroup;
         private System.Windows.Forms.ToolStripMenuItem ToolStripMenuItem_EDGcolor;
         public System.Windows.Forms.TabControl tabControl1;
+        private System.Windows.Forms.ToolStripMenuItem ToolStripMenuItem_RenameGroup;
     }
 }

+ 60 - 9
OTSPartA_STDEditor/UI/STDRuleslist.cs

@@ -545,9 +545,11 @@ namespace OTSPartA_STDEditor
             else
             {
                 MessageBox.Show("Please select a group!", "Tip");
+
                 return;
             }
         }
+
         private void ToolStripMenuItem_EdGroupColor_Click(object sender, EventArgs e)
         {
             if(treeView_G.SelectedNode==null)
@@ -600,7 +602,6 @@ namespace OTSPartA_STDEditor
                     SolidBrush b2 = new SolidBrush(color2);
                     graphics.FillEllipse(b2, new Rectangle(0, 0, 100, 100));
                     treeView_G.ImageList.Images.Add("0x"+ ddata.STDId, bitmap);
-                    //bitmap.Save(@"C:\Users\yunyunyun\Desktop\9-9-1\a\"+ ddata.STDId + @".bmp");
                     childtreeNode.ImageKey = "0x" + ddata.STDId;
                     childtreeNode.SelectedImageKey = "0x" + ddata.STDId;
                     treeNode.Nodes.Add(childtreeNode);
@@ -671,13 +672,10 @@ namespace OTSPartA_STDEditor
         {
             if (e.Button == MouseButtons.Left)
             {
-                //只处理左键拖拽操作;
                 m_targetNode = null;
                 TreeNode _node = (TreeNode)e.Item;
-                //只允许拖拽子级节点;
                 if (_node.Level > 0)
                 {
-                    //开始拖拽;
                     DoDragDrop(e.Item, DragDropEffects.Move | DragDropEffects.Copy);
                 }
             }
@@ -690,17 +688,26 @@ namespace OTSPartA_STDEditor
                 TreeNode _node = (TreeNode)e.Data.GetData(typeof(TreeNode));
                 if (!m_targetNode.Equals(_node))
                 {
-
                     if (m_targetNode.Level == _node.Level)
                     {
-                        //1. 不同的父节点;
-                        //2. 被拖拽的节点不在目标节点的上面(相邻);
-                        if (!_node.Parent.Equals(m_targetNode.Parent) || m_targetNode.Index - 1 != _node.Index)
+                        if (_node.Parent.Equals(m_targetNode.Parent))
                         {
                             _node.Remove();
                             m_targetNode.Parent.Nodes.Insert(m_targetNode.Index, _node);
                             m_targetNode.Parent.ExpandAll();
                         }
+                        else
+                        {
+                            GroupViewDic[((STDGroups)_node.Parent.Tag).id].ContainSTD.Remove((STDdata)_node.Tag);
+                            _node.Remove();
+                            ((STDdata)_node.Tag).GroupId = ((STDGroups)m_targetNode.Parent.Tag).id;
+                            m_targetNode.Parent.Nodes.Add(_node);
+                            GroupViewDic[((STDGroups)m_targetNode.Parent.Tag).id].ContainSTD.Add((STDdata)_node.Tag);
+                            treeView_G.SelectedNode = _node; // 选中节点
+                            m_targetNode.Parent.Expand(); // 展开父节点
+                            m_MainForm.ChangeSTDEditorAndGrid_Attributes(int.Parse(((STDdata)_node.Tag).STDId.ToString()));
+                            Predata = (STDdata)_node.Tag;
+                        }
                     }
                     else
                     {
@@ -750,6 +757,7 @@ namespace OTSPartA_STDEditor
         }
         private void treeView_G_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
         {
+
             if(Predata!=null)
             {
                 m_MainForm.SaveDataOfSelRule(Predata.STDId);
@@ -758,6 +766,7 @@ namespace OTSPartA_STDEditor
             {
                 m_MainForm.SetNull();
                 Predata = null;
+                treeView_G.SelectedNode = e.Node;
             }
             else
             {
@@ -771,6 +780,10 @@ namespace OTSPartA_STDEditor
             {
                 return;
             }
+            if (treeView_G.SelectedNode.Level == null)
+            {
+                return;
+            }
             if (treeView_G.SelectedNode.Level == 0)
             {
                 return;
@@ -802,7 +815,45 @@ namespace OTSPartA_STDEditor
                         break;
                     }
                 }
-
+            }
+        }
+        private void ToolStripMenuItem_RenameGroup_Click(object sender, EventArgs e)
+        {
+            if (treeView_G.SelectedNode != null)
+            {
+                if (treeView_G.SelectedNode.Level == 0)
+                {
+                    treeView_G.SelectedNode.BeginEdit();
+                }
+                else
+                {
+                    MessageBox.Show("Please select a group!", "Tip");
+                    treeView_G.SelectedNode.EndEdit(true);
+                }
+            }
+        }
+        private void treeView_G_AfterLabelEdit(object sender, NodeLabelEditEventArgs e)
+        {
+            if (treeView_G.SelectedNode.Level == 0)
+            {
+                if(e.Label==null|| e.Label =="")
+                {
+                    MessageBox.Show("GroupName Cannot Be Null!", "Tip");
+                    e.CancelEdit=true;
+                    return;
+                }
+                STDGroups Group = (STDGroups)treeView_G.SelectedNode.Tag;
+                m_MainForm._sTDEditor.GroupIdDictionaryFromId.Remove(Group.id);
+                m_MainForm._sTDEditor.GroupIdDictionaryFromName.Remove(GroupViewDic[Group.id].name);
+                GroupViewDic[Group.id].name = e.Label;
+                m_MainForm._sTDEditor.GroupIdDictionaryFromId.Add(Group.id, Group.name);
+                m_MainForm._sTDEditor.GroupIdDictionaryFromName.Add(GroupViewDic[Group.id].name, Group.id);
+                m_MainForm.m_Attributes.AddSTDGroupsToAttribute();
+            }
+            else
+            {
+                MessageBox.Show("Please select a group!", "Tip");
+                return;
             }
         }
     }