|
@@ -1,14 +1,13 @@
|
|
|
using OTS.WinFormsUI.Docking;
|
|
|
-using SourceGrid;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Drawing;
|
|
|
using System.Drawing.Imaging;
|
|
|
using System.Linq;
|
|
|
using System.Runtime.InteropServices;
|
|
|
-
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
+
|
|
|
namespace OTSPartA_STDEditor
|
|
|
{
|
|
|
public partial class STDRuleslist : DockContent
|
|
@@ -16,24 +15,23 @@ namespace OTSPartA_STDEditor
|
|
|
public STDdata Predata = null;//之前选中的位置
|
|
|
public Form_Main m_MainForm = null;
|
|
|
ValueChangedEvent m_ValueChangedEvent = null;//单元格内容改变事件
|
|
|
- Dictionary<int,STDGroups> GroupViewDic=null;
|
|
|
+ public Dictionary<int,STDGroups> GroupViewDic=null;
|
|
|
+
|
|
|
+ System.Collections.Hashtable table_STDRuleslist;
|
|
|
+ bool RenFlag = false;
|
|
|
public STDRuleslist(Form_Main mainForm)
|
|
|
{
|
|
|
InitializeComponent();
|
|
|
m_MainForm = mainForm;
|
|
|
m_ValueChangedEvent = new ValueChangedEvent(this);
|
|
|
}
|
|
|
- System.Collections.Hashtable table_STDRuleslist;
|
|
|
+
|
|
|
private void STDRuleslist_Load(object sender, EventArgs e)
|
|
|
{
|
|
|
m_MainForm.lan = new Language(this);
|
|
|
table_STDRuleslist = m_MainForm.lan.GetNameTable("Attributes");
|
|
|
- InitRuleView();
|
|
|
- button_UpOrder.Enabled = false;
|
|
|
- button_DownOrder.Enabled = false;
|
|
|
+ InitGroupEditorView();
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// [颜色:16进制转成RGB]
|
|
|
/// </summary>
|
|
@@ -58,135 +56,6 @@ 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;
|
|
|
- if (i >= 0 && j >= 0)
|
|
|
- {
|
|
|
- if (Predata != null)
|
|
|
- {
|
|
|
- m_MainForm.SaveDataOfSelRule(Predata.STDId);
|
|
|
- }
|
|
|
- m_MainForm.ChangeSTDEditorAndGrid_Attributes(((STDdata)Grid_Minerals[i, 0].Tag).STDId);
|
|
|
- m_MainForm.m_SubMidWindow.m_ComparativeLibrary.MakeCheckboxUnchecked();
|
|
|
- Predata = (STDdata)Grid_Minerals[i, 0].Tag;
|
|
|
- }
|
|
|
- SetOrderButtonsStatus();
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- private void ToolStripMenuItem_New_Click(object sender, EventArgs e)
|
|
|
- {
|
|
|
- int i = Grid_Minerals.Selection.ActivePosition.Row;
|
|
|
- int j = Grid_Minerals.Selection.ActivePosition.Column;
|
|
|
- if (i >= 0 && j >= 0)
|
|
|
- {
|
|
|
- int id = ((STDdata)Grid_Minerals[i, 0].Tag).STDId;
|
|
|
- m_MainForm.SaveDataOfSelRule(id);
|
|
|
- Predata = (STDdata)Grid_Minerals[i, 0].Tag;
|
|
|
- int STDId = m_MainForm._sTDEditor.AddSTDDictionaryItem();
|
|
|
- AddNewRow(STDId, "NewRuleName", Attributes.colorHx16toRGB(m_MainForm._sTDEditor.STDDictionary[STDId].Color));
|
|
|
- m_MainForm.m_SubMidWindow.m_ComparativeLibrary.MakeCheckboxUnchecked();
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- int STDId = m_MainForm._sTDEditor.AddSTDDictionaryItem();
|
|
|
- AddNewRow(STDId, "NewRuleName", Attributes.colorHx16toRGB(m_MainForm._sTDEditor.STDDictionary[STDId].Color));
|
|
|
- m_MainForm.m_SubMidWindow.m_ComparativeLibrary.MakeCheckboxUnchecked();
|
|
|
- }
|
|
|
- }
|
|
|
- public void AddNewRow(int STDId, string RuleName, Color color)
|
|
|
- {
|
|
|
- Grid_Minerals.Rows.Insert(Grid_Minerals.Rows.Count);
|
|
|
- Grid_Minerals[Grid_Minerals.Rows.Count - 1, 0] = new SourceGrid.Cells.Cell(RuleName, typeof(string));
|
|
|
- Grid_Minerals[Grid_Minerals.Rows.Count - 1, 0].Tag = m_MainForm._sTDEditor.STDDictionary[STDId];
|
|
|
- Grid_Minerals.Rows[Grid_Minerals.Rows.Count - 1].Height = 25;
|
|
|
- Grid_Minerals[Grid_Minerals.Rows.Count - 1, 1] = new SourceGrid.Cells.Cell();
|
|
|
- m_MainForm._sTDEditor.STDDictionary[STDId].StrName = RuleName;
|
|
|
- m_MainForm.ChangeSTDEditorAndGrid_Attributes(STDId);
|
|
|
- SourceGrid.Cells.Views.Cell view = new SourceGrid.Cells.Views.Cell();
|
|
|
- view.BackColor = color;
|
|
|
- Grid_Minerals[Grid_Minerals.Rows.Count - 1, 1].View = view;
|
|
|
- Position pos = new Position(Grid_Minerals.Rows.Count - 1, 0);
|
|
|
- Grid_Minerals.Selection.Focus(pos, true);
|
|
|
- Predata = (STDdata)Grid_Minerals[Grid_Minerals.Rows.Count - 1, 0].Tag;
|
|
|
- SetOrderButtonsStatus();
|
|
|
- }
|
|
|
- void Grid_MineralsDelRow()
|
|
|
- {
|
|
|
- int x = Grid_Minerals.Selection.ActivePosition.Row;
|
|
|
- if (x > 0)
|
|
|
- {
|
|
|
- m_MainForm.RemoveSTDDictionaryItem(((STDdata)Grid_Minerals[x, 0].Tag).STDId);
|
|
|
- Grid_Minerals.Rows.Remove(x);
|
|
|
- if (Grid_Minerals.RowsCount > 1)
|
|
|
- {
|
|
|
- if (x != Grid_Minerals.RowsCount)
|
|
|
- {
|
|
|
- Position pos = new Position(x, 0);
|
|
|
- Grid_Minerals.Selection.Focus(pos, true);
|
|
|
- Grid_Minerals[x, 0].Grid.Select();
|
|
|
- m_MainForm.ChangeSTDEditorAndGrid_Attributes(((STDdata)Grid_Minerals[x, 0].Tag).STDId);
|
|
|
- Predata = (STDdata)Grid_Minerals[x, 0].Tag;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- Position pos = new Position(x - 1, 0);
|
|
|
- Grid_Minerals.Selection.Focus(pos, true);
|
|
|
- Grid_Minerals[x - 1, 0].Grid.Select();
|
|
|
-
|
|
|
- m_MainForm.ChangeSTDEditorAndGrid_Attributes(((STDdata)Grid_Minerals[x-1, 0].Tag).STDId);
|
|
|
- Predata = (STDdata)Grid_Minerals[x-1, 0].Tag;
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- m_MainForm.SetNull();
|
|
|
- Predata = null;
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- MessageBox.Show("There is no rule to delete!", "Tip");
|
|
|
- }
|
|
|
- }
|
|
|
- private void ToolStripMenuItem_Del_Click(object sender, EventArgs e)
|
|
|
- {
|
|
|
- Grid_MineralsDelRow();
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
|
|
|
|
|
|
|
|
@@ -207,7 +76,6 @@ namespace OTSPartA_STDEditor
|
|
|
else
|
|
|
{
|
|
|
m_parentWnd.ChangeStrName(sender.Position.Row, "NewRuleName");
|
|
|
- m_parentWnd.Grid_Minerals[sender.Position.Row,0].Value = "NewRuleName";
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -215,229 +83,59 @@ namespace OTSPartA_STDEditor
|
|
|
{
|
|
|
m_MainForm.ChangeStrName(RowNum, NewStrName);
|
|
|
}
|
|
|
- private void Grid_Minerals_PreviewKeyDown(object sender, PreviewKeyDownEventArgs 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;
|
|
|
- if(i==-1)
|
|
|
- {
|
|
|
- return;
|
|
|
- }
|
|
|
- if (e.KeyCode == Keys.Up)
|
|
|
- {
|
|
|
- if (i >= 2 && j >= 0)
|
|
|
- {
|
|
|
- //规则名称不为空
|
|
|
- if (Grid_Minerals[i, 0].Value.ToString().Replace(" ", "").Trim() != "")
|
|
|
- {
|
|
|
- int id = ((STDdata)Grid_Minerals[i, 0].Tag).STDId;
|
|
|
|
|
|
- m_MainForm.SaveDataOfSelRule(id);
|
|
|
- m_MainForm.ChangeSTDEditorAndGrid_Attributes(((STDdata)Grid_Minerals[i - 1, 0].Tag).STDId);
|
|
|
- m_MainForm.m_SubMidWindow.m_ComparativeLibrary.MakeCheckboxUnchecked();
|
|
|
- Predata = (STDdata)Grid_Minerals[i - 1, 0].Tag;
|
|
|
- if (i == 2)
|
|
|
- {
|
|
|
- button_UpOrder.Enabled = false;
|
|
|
- }
|
|
|
- if (i == ls_gd.RowsCount - 1)
|
|
|
- {
|
|
|
- button_DownOrder.Enabled = true;
|
|
|
- }
|
|
|
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- Position pos = new Position(i + 1, 0);
|
|
|
- Grid_Minerals.Selection.Focus(pos, true);
|
|
|
- m_MainForm.m_SubMidWindow.m_ComparativeLibrary.MakeCheckboxUnchecked();
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if (e.KeyCode == Keys.Down)
|
|
|
- {
|
|
|
- if (i < ls_gd.RowsCount - 1 && j >= 0)
|
|
|
- {
|
|
|
- if (Grid_Minerals[i, 0].Value.ToString().Replace(" ", "").Trim() != "")
|
|
|
- {
|
|
|
- int id = ((STDdata)Grid_Minerals[i, 0].Tag).STDId;
|
|
|
-
|
|
|
- m_MainForm.SaveDataOfSelRule(id);
|
|
|
- m_MainForm.ChangeSTDEditorAndGrid_Attributes(((STDdata)Grid_Minerals[i + 1, 0].Tag).STDId);
|
|
|
- Predata = (STDdata)Grid_Minerals[i+1, 0].Tag;
|
|
|
- m_MainForm.m_SubMidWindow.m_ComparativeLibrary.MakeCheckboxUnchecked();
|
|
|
-
|
|
|
- if (i == 1)
|
|
|
- {
|
|
|
- button_UpOrder.Enabled = true;
|
|
|
- }
|
|
|
- if (i == ls_gd.RowsCount - 2)
|
|
|
- {
|
|
|
- button_DownOrder.Enabled = false;
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- Position pos = new Position(i - 1, 0);
|
|
|
- Grid_Minerals.Selection.Focus(pos, true);
|
|
|
- m_MainForm.m_SubMidWindow.m_ComparativeLibrary.MakeCheckboxUnchecked();
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+
|
|
|
+
|
|
|
+ private void Grid_Minerals_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
|
|
|
+ {
|
|
|
+
|
|
|
if (e.KeyCode == Keys.Delete)
|
|
|
{
|
|
|
- Grid_MineralsDelRow();
|
|
|
+ ToolStripMenuItem_Del_Click(null, null);
|
|
|
}
|
|
|
}
|
|
|
public int ChangeSTDRulesLISTBackColor()
|
|
|
{
|
|
|
- if (tabControl1.SelectedIndex == 1)
|
|
|
+ if (treeView_G.SelectedNode.Level == 0)
|
|
|
{
|
|
|
- if (Grid_Minerals.RowsCount > 1)
|
|
|
- {
|
|
|
- Position pos = new Position(1, 0);
|
|
|
- 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._sTDEditor.STDDictionary[((STDdata)Grid_Minerals[Grid_Minerals.Selection.ActivePosition.Row, 0].Tag).STDId].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 ((STDdata)Grid_Minerals[Grid_Minerals.Selection.ActivePosition.Row, 0].Tag).STDId;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- return -1;
|
|
|
- }
|
|
|
+ return -1;
|
|
|
}
|
|
|
- else
|
|
|
+ STDdata ddata = (STDdata)treeView_G.SelectedNode.Tag;
|
|
|
+ int id = ddata.STDId;
|
|
|
+ foreach(STDdata ddata1 in ((STDGroups)treeView_G.SelectedNode.Parent.Tag).ContainSTD)
|
|
|
{
|
|
|
- if(treeView_G.SelectedNode.Level==0)
|
|
|
+ if(ddata1.STDId== ddata.STDId)
|
|
|
{
|
|
|
- return -1;
|
|
|
- }
|
|
|
- STDdata ddata = (STDdata)treeView_G.SelectedNode.Tag;
|
|
|
- int id= ddata.STDId;
|
|
|
- m_MainForm._sTDEditor.STDDictionary[id].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);
|
|
|
- InitGroupView();
|
|
|
- foreach(TreeNode treeNode in treeView_G.Nodes)
|
|
|
- {
|
|
|
- if(((STDGroups)treeNode.Tag).id== ddata.GroupId)
|
|
|
- {
|
|
|
- foreach (TreeNode node in treeNode.Nodes)
|
|
|
- {
|
|
|
- if (((STDdata)node.Tag).STDId == id)
|
|
|
- {
|
|
|
- treeView_G.SelectedNode = node;
|
|
|
- Predata = (STDdata)node.Tag;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ ddata1.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);
|
|
|
+ break;
|
|
|
}
|
|
|
- return id;
|
|
|
}
|
|
|
- }
|
|
|
- private void button_UpOrder_Click(object sender, EventArgs e)
|
|
|
- {
|
|
|
-
|
|
|
- }
|
|
|
- private void button_DownOrder_Click(object sender, EventArgs e)
|
|
|
- {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- public void InsertNewRow(int STDId, string RuleName, Color color)
|
|
|
- {
|
|
|
- Grid_Minerals.Focus(true);
|
|
|
- Grid_Minerals.Rows.InsertRange(Grid_Minerals.Selection.ActivePosition.Row, 1);
|
|
|
- int i = Grid_Minerals.Selection.ActivePosition.Row;
|
|
|
- Grid_Minerals[Grid_Minerals.Selection.ActivePosition.Row, 0] = new SourceGrid.Cells.Cell(RuleName, typeof(string));
|
|
|
- Grid_Minerals[Grid_Minerals.Selection.ActivePosition.Row, 0].Tag = m_MainForm._sTDEditor.STDDictionary[STDId];
|
|
|
- Grid_Minerals.Rows[Grid_Minerals.Selection.ActivePosition.Row].Height = 25;
|
|
|
- Grid_Minerals[Grid_Minerals.Selection.ActivePosition.Row, 1] = new SourceGrid.Cells.Cell();
|
|
|
- m_MainForm.ChangeSTDEditorAndGrid_Attributes(STDId);
|
|
|
-
|
|
|
- Grid_Minerals.Focus(true);
|
|
|
- SourceGrid.Cells.Views.Cell view = new SourceGrid.Cells.Views.Cell();
|
|
|
- view.BackColor = color;
|
|
|
- Grid_Minerals[Grid_Minerals.Selection.ActivePosition.Row, 1].View = view;
|
|
|
- Position pos = new Position(Grid_Minerals.Selection.ActivePosition.Row, 0);
|
|
|
- Grid_Minerals.Selection.Focus(pos, true);
|
|
|
- Predata = (STDdata)Grid_Minerals[Grid_Minerals.Selection.ActivePosition.Row - 1, 0].Tag ;
|
|
|
- SetOrderButtonsStatus();
|
|
|
- }
|
|
|
- void SetOrderButtonsStatus()
|
|
|
- {
|
|
|
- Grid_Minerals.Focus();
|
|
|
- int i = Grid_Minerals.Selection.ActivePosition.Row;
|
|
|
- int j = Grid_Minerals.Selection.ActivePosition.Column;
|
|
|
- if (i != -1)
|
|
|
+ InitGroupView();
|
|
|
+ foreach (TreeNode treeNode in treeView_G.Nodes)
|
|
|
{
|
|
|
- if (i == 1)
|
|
|
- {
|
|
|
- button_UpOrder.Enabled = false;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- button_UpOrder.Enabled = true;
|
|
|
- }
|
|
|
- if (i == Grid_Minerals.RowsCount - 1)
|
|
|
- {
|
|
|
- button_DownOrder.Enabled = false;
|
|
|
- }
|
|
|
- else
|
|
|
+ if (((STDGroups)treeNode.Tag).id == ddata.GroupId)
|
|
|
{
|
|
|
- button_DownOrder.Enabled = true;
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- button_UpOrder.Enabled = false;button_DownOrder.Enabled = false;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
+ foreach (TreeNode node in treeNode.Nodes)
|
|
|
+ {
|
|
|
+ if (((STDdata)node.Tag).STDId == id)
|
|
|
+ {
|
|
|
+ treeView_G.SelectedNode = node;
|
|
|
+ Predata = (STDdata)node.Tag;
|
|
|
+ break;
|
|
|
|
|
|
- private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
- {
|
|
|
- if (Predata != null)
|
|
|
- {
|
|
|
- m_MainForm.SaveDataOfSelRule(Predata.STDId);
|
|
|
- }
|
|
|
- if (tabControl1.SelectedIndex == 0)
|
|
|
- {
|
|
|
- Predata = null;
|
|
|
- InitGroupEditorView();
|
|
|
- }
|
|
|
- else if (tabControl1.SelectedIndex == 1)
|
|
|
- {
|
|
|
- ConvertToRuleViewDic();
|
|
|
- InitRuleView();
|
|
|
- if (m_MainForm._sTDEditor.STDDictionary.Count == 0)
|
|
|
- {
|
|
|
- m_MainForm.SetNull();
|
|
|
- Predata = null;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
|
|
|
- Position pos = new Position(1, 0);
|
|
|
- Grid_Minerals[1, 0].Grid.Select();
|
|
|
- Grid_Minerals.Selection.Focus(pos, true);
|
|
|
- Grid_Minerals.Refresh();
|
|
|
- m_MainForm.ChangeSTDEditorAndGrid_Attributes(((STDdata)Grid_Minerals[1, 0].Tag).STDId);
|
|
|
-
|
|
|
- Predata = (STDdata)Grid_Minerals[1, 0].Tag;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- //}
|
|
|
}
|
|
|
+ return id;
|
|
|
}
|
|
|
- void InitGroupEditorView()
|
|
|
+ public void InitGroupEditorView()
|
|
|
{
|
|
|
GroupViewDic = ConvertToGroupViewDic();
|
|
|
InitGroupView();
|
|
|
}
|
|
|
-
|
|
|
Dictionary<int, STDGroups> ConvertToGroupViewDic()
|
|
|
{
|
|
|
Dictionary<int, STDGroups> keyValuePairs = new Dictionary<int, STDGroups>();
|
|
@@ -457,19 +155,18 @@ namespace OTSPartA_STDEditor
|
|
|
m_MainForm._sTDEditor.GroupIdDictionaryFromId.Clear();
|
|
|
m_MainForm._sTDEditor.GroupIdDictionaryFromName.Clear();
|
|
|
m_MainForm._sTDEditor.STDDictionary.Clear();
|
|
|
- for(int i=0;i< treeView_G.Nodes.Count;i++)
|
|
|
- {
|
|
|
- STDGroups tDGroups = (STDGroups)treeView_G.Nodes[i].Tag;
|
|
|
- GroupViewDic[tDGroups.id].iorder = i;
|
|
|
- }
|
|
|
- foreach (STDGroups group in GroupViewDic.Values)
|
|
|
+ foreach (TreeNode treeNode in treeView_G.Nodes)
|
|
|
{
|
|
|
- foreach (STDdata Ddata in group.ContainSTD)
|
|
|
+ STDGroups tDGroups = (STDGroups)treeNode.Tag;
|
|
|
+ GroupViewDic[tDGroups.id].iorder = treeNode.Index;
|
|
|
+ foreach (TreeNode treeNode1 in treeNode.Nodes)
|
|
|
{
|
|
|
+ STDdata Ddata = (STDdata)treeNode1.Tag;
|
|
|
+ Ddata.ListNum = treeNode1.Index.ToString();
|
|
|
m_MainForm._sTDEditor.STDDictionary.Add(Ddata.STDId, Ddata);
|
|
|
}
|
|
|
- m_MainForm._sTDEditor.GroupIdDictionaryFromName.Add(group.name.ToString(), int.Parse(group.id.ToString()));
|
|
|
- m_MainForm._sTDEditor.GroupIdDictionaryFromId.Add(int.Parse(group.id.ToString()), group.name.ToString());
|
|
|
+ m_MainForm._sTDEditor.GroupIdDictionaryFromName.Add(tDGroups.name.ToString(), int.Parse(tDGroups.id.ToString()));
|
|
|
+ m_MainForm._sTDEditor.GroupIdDictionaryFromId.Add(int.Parse(tDGroups.id.ToString()), tDGroups.name.ToString());
|
|
|
}
|
|
|
if (treeView_G.SelectedNode == null){return;}
|
|
|
if (treeView_G.SelectedNode.Level == 1)
|
|
@@ -482,6 +179,12 @@ namespace OTSPartA_STDEditor
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
private void ToolStripMenuItem_NewGroup_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
STDGroups group = new STDGroups();
|
|
@@ -497,55 +200,100 @@ namespace OTSPartA_STDEditor
|
|
|
group.id = id;
|
|
|
group.name = "Group" + id.ToString();
|
|
|
group.color = Attributes.colorRGBtoHx16(Color.WhiteSmoke.R, Color.WhiteSmoke.G, Color.WhiteSmoke.B);
|
|
|
+ group.iorder = GroupViewDic.Count-1;
|
|
|
GroupViewDic.Add(group.id, group);
|
|
|
m_MainForm.m_Attributes.AddSTDGroupsToAttribute();
|
|
|
- this.Refresh();
|
|
|
- TreeNode treeNode = new TreeNode();
|
|
|
- treeNode.Tag = group;
|
|
|
- treeNode.Text = group.name;
|
|
|
m_MainForm._sTDEditor.GroupIdDictionaryFromId.Add(id, group.name);
|
|
|
m_MainForm._sTDEditor.GroupIdDictionaryFromName.Add(group.name, group.id);
|
|
|
- treeView_G.Nodes.Add(treeNode);
|
|
|
- treeView_G.SelectedNode = treeNode;
|
|
|
+ InitGroupView();
|
|
|
+ foreach (TreeNode treeNode in treeView_G.Nodes)
|
|
|
+ {
|
|
|
+ if (((STDGroups)treeNode.Tag).id == id)
|
|
|
+ {
|
|
|
+ treeView_G.SelectedNode = treeNode;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
m_MainForm.SetNull();
|
|
|
Predata = null;
|
|
|
+ this.Refresh();
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- private void ToolStripMenuItem_DelGroup_Click(object sender, EventArgs e)
|
|
|
+ private void ToolStripMenuItem_Del_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
- if(treeView_G.SelectedNode==null)
|
|
|
+ if (treeView_G.SelectedNode == null)
|
|
|
{
|
|
|
- MessageBox.Show("Please select a group!", "Tip");
|
|
|
+ MessageBox.Show("Please select a node!", "Tip");
|
|
|
return;
|
|
|
}
|
|
|
if (treeView_G.SelectedNode.Level == 0)
|
|
|
{
|
|
|
int id = ((STDGroups)treeView_G.SelectedNode.Tag).id;
|
|
|
- if(((STDGroups)treeView_G.SelectedNode.Tag).id==0)
|
|
|
+ if (((STDGroups)treeView_G.SelectedNode.Tag).id == 0)
|
|
|
{
|
|
|
MessageBox.Show("Can not delete the group which named default!", "Tip");
|
|
|
return;
|
|
|
}
|
|
|
- DialogResult result = MessageBox.Show("删除组会一并删除组内规则,是否继续?", "Tip", MessageBoxButtons.YesNo);
|
|
|
- if (result == DialogResult.Yes)
|
|
|
+ m_MainForm._sTDEditor.GroupIdDictionaryFromId.Remove(id);
|
|
|
+
|
|
|
+ m_MainForm._sTDEditor.GroupIdDictionaryFromName.Remove(GroupViewDic[id].name);
|
|
|
+ foreach (TreeNode treeNode1 in treeView_G.Nodes)
|
|
|
+ {
|
|
|
+ if (((STDGroups)treeNode1.Tag).name == "Default")
|
|
|
+ {
|
|
|
+ if (Predata != null)
|
|
|
+ {
|
|
|
+ m_MainForm.SaveDataOfSelRule(Predata.STDId);
|
|
|
+ }
|
|
|
+ foreach (STDdata ddata in GroupViewDic[((STDGroups)treeView_G.SelectedNode.Tag).id].ContainSTD)
|
|
|
+ {
|
|
|
+ ddata.GroupId = ((STDGroups)treeNode1.Tag).id;
|
|
|
+ ddata.ListNum = "1000";
|
|
|
+ }
|
|
|
+ GroupViewDic[((STDGroups)treeNode1.Tag).id].ContainSTD.AddRange(GroupViewDic[((STDGroups)treeView_G.SelectedNode.Tag).id].ContainSTD);
|
|
|
+
|
|
|
+ GroupViewDic.Remove(id);
|
|
|
+ InitGroupView();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ foreach (TreeNode treeNode1 in treeView_G.Nodes)
|
|
|
{
|
|
|
- m_MainForm._sTDEditor.GroupIdDictionaryFromId.Remove(id);
|
|
|
- m_MainForm._sTDEditor.GroupIdDictionaryFromName.Remove(GroupViewDic[id].name);
|
|
|
- GroupViewDic.Remove(id);
|
|
|
- treeView_G.Nodes.Remove(treeView_G.SelectedNode);
|
|
|
- this.Refresh();
|
|
|
+ if (((STDGroups)treeNode1.Tag).name == "Default")
|
|
|
+ {
|
|
|
+ treeView_G.SelectedNode = treeNode1;
|
|
|
+ m_MainForm.SetNull();
|
|
|
+ Predata = null;
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- MessageBox.Show("Please select a group!", "Tip");
|
|
|
-
|
|
|
- return;
|
|
|
+ foreach (int grpid in GroupViewDic.Keys)
|
|
|
+ {
|
|
|
+ foreach (STDdata ddata in GroupViewDic[grpid].ContainSTD)
|
|
|
+ {
|
|
|
+ if (ddata.STDId == ((STDdata)treeView_G.SelectedNode.Tag).STDId)
|
|
|
+ {
|
|
|
+ GroupViewDic[grpid].ContainSTD.Remove(ddata);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ treeView_G.SelectedNode.Remove();
|
|
|
+ if (treeView_G.SelectedNode != null&& treeView_G.SelectedNode.Level !=0)
|
|
|
+ {
|
|
|
+ m_MainForm.ChangeSTDEditorAndGrid_Attributes((STDdata)treeView_G.SelectedNode.Tag);
|
|
|
+ Predata = (STDdata)treeView_G.SelectedNode.Tag;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ m_MainForm.SetNull();
|
|
|
+ Predata = null;
|
|
|
+ }
|
|
|
+ this.Refresh();
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
private void ToolStripMenuItem_EdGroupColor_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
if(treeView_G.SelectedNode==null)
|
|
@@ -555,6 +303,12 @@ namespace OTSPartA_STDEditor
|
|
|
}
|
|
|
if (treeView_G.SelectedNode.Level == 0)
|
|
|
{
|
|
|
+ if (treeView_G.SelectedNode.Text == "Default")
|
|
|
+ {
|
|
|
+ MessageBox.Show("The default group cannot be changed!", "Tip");
|
|
|
+ treeView_G.SelectedNode.EndEdit(true);
|
|
|
+ return;
|
|
|
+ }
|
|
|
ColorDialog cd = new ColorDialog();
|
|
|
cd.FullOpen = true;//自定义颜色界面打开
|
|
|
DialogResult result = cd.ShowDialog();
|
|
@@ -569,7 +323,7 @@ namespace OTSPartA_STDEditor
|
|
|
MessageBox.Show("Please select a group!", "Tip");
|
|
|
}
|
|
|
}
|
|
|
- void InitGroupView()
|
|
|
+ public void InitGroupView()
|
|
|
{
|
|
|
treeView_G.ImageList=new ImageList();
|
|
|
treeView_G.Nodes.Clear();
|
|
@@ -579,12 +333,11 @@ namespace OTSPartA_STDEditor
|
|
|
{
|
|
|
if (group.name == "Default")
|
|
|
{
|
|
|
- group.iorder = 9999999;
|
|
|
+ group.iorder = 10000;
|
|
|
}
|
|
|
groups.Add(group);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
groups=groups.OrderBy(s => s.iorder).ToList();
|
|
|
|
|
|
for (int i=0;i< groups.Count;i++)
|
|
@@ -601,8 +354,10 @@ namespace OTSPartA_STDEditor
|
|
|
treeNode.ImageKey = groups[i].id.ToString();
|
|
|
treeNode.SelectedImageKey = groups[i].id.ToString();
|
|
|
treeView_G.Nodes.Add(treeNode);
|
|
|
- foreach (STDdata ddata in groups[i].ContainSTD)
|
|
|
+ groups[i].ContainSTD= groups[i].ContainSTD.OrderBy(s => int.Parse(s.ListNum)).ToList();
|
|
|
+ for(int j=0;j<groups[i].ContainSTD.Count;j++)
|
|
|
{
|
|
|
+ STDdata ddata = groups[i].ContainSTD[j];
|
|
|
TreeNode childtreeNode = new TreeNode();
|
|
|
childtreeNode.Tag = ddata;
|
|
|
childtreeNode.Text = ddata.StrName;
|
|
@@ -621,62 +376,6 @@ namespace OTSPartA_STDEditor
|
|
|
treeView_G.ShowLines = false;
|
|
|
this.Refresh();
|
|
|
}
|
|
|
- void InitRuleView()
|
|
|
- {
|
|
|
- Grid_Minerals.Rows.Clear();
|
|
|
- Grid_Minerals.Columns.Clear();
|
|
|
-
|
|
|
- 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")
|
|
|
- {
|
|
|
- head1 = new SourceGrid.Cells.ColumnHeader("Rule Name");
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- head1 = new SourceGrid.Cells.ColumnHeader("规则名称");
|
|
|
- }
|
|
|
- Grid_Minerals[0, 0] = head1;
|
|
|
-
|
|
|
- SourceGrid.Cells.ColumnHeader head2 = null;
|
|
|
- if (m_MainForm.lan.GetNameTable("Form_Main")["language"].ToString() == "EN")
|
|
|
- {
|
|
|
- head2 = new SourceGrid.Cells.ColumnHeader("Color");
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- head2 = new SourceGrid.Cells.ColumnHeader("颜色");
|
|
|
- }
|
|
|
- Grid_Minerals[0, 1] = head2;
|
|
|
- SourceGrid.Cells.Views.ColumnHeader boldHeader = new SourceGrid.Cells.Views.ColumnHeader();
|
|
|
- boldHeader.Font = new Font("Microsoft YaHei UI", 11, FontStyle.Bold);
|
|
|
- boldHeader.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter;
|
|
|
- Grid_Minerals[0, 0].View = boldHeader;
|
|
|
- Grid_Minerals[0, 1].View = boldHeader;
|
|
|
- Grid_Minerals.Rows.SetHeight(0, 25);
|
|
|
- head1.AutomaticSortEnabled = false;
|
|
|
- head2.AutomaticSortEnabled = false;
|
|
|
- Grid_Minerals.Selection.EnableMultiSelection = false;
|
|
|
- Grid_Minerals.AutoStretchColumnsToFitWidth = true;
|
|
|
- Grid_Minerals.Columns[0].Width = this.Width / 2 - 15;
|
|
|
- Grid_Minerals.Columns[1].Width = this.Width / 2 - 39;
|
|
|
- int i = 1;
|
|
|
- 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;
|
|
|
- Grid_Minerals[i, 0].Tag = kv.Value;
|
|
|
- Grid_Minerals[i, 1] = new SourceGrid.Cells.Cell();
|
|
|
- SourceGrid.Cells.Views.Cell view = new SourceGrid.Cells.Views.Cell();
|
|
|
- view.BackColor = colorHx16toRGB(kv.Value.Color);
|
|
|
- Grid_Minerals[i, 1].View = view;
|
|
|
- i++;
|
|
|
- }
|
|
|
- Grid_Minerals.Controller.AddController(m_ValueChangedEvent);
|
|
|
- Grid_Minerals.FixedRows = 1;
|
|
|
- Grid_Minerals.Selection.FocusStyle = FocusStyle.None;
|
|
|
- }
|
|
|
-
|
|
|
private void treeView_G_ItemDrag(object sender, ItemDragEventArgs e)
|
|
|
{
|
|
|
if (e.Button == MouseButtons.Left)
|
|
@@ -695,6 +394,10 @@ namespace OTSPartA_STDEditor
|
|
|
if (m_targetNode != null)
|
|
|
{
|
|
|
TreeNode _node = (TreeNode)e.Data.GetData(typeof(TreeNode));
|
|
|
+ if (Predata != null)
|
|
|
+ {
|
|
|
+ m_MainForm.SaveDataOfSelRule(Predata.STDId);
|
|
|
+ }
|
|
|
if (_node.Level == 1)
|
|
|
{
|
|
|
if (!m_targetNode.Equals(_node))
|
|
@@ -706,6 +409,9 @@ namespace OTSPartA_STDEditor
|
|
|
_node.Remove();
|
|
|
m_targetNode.Parent.Nodes.Insert(m_targetNode.Index+1, _node);
|
|
|
m_targetNode.Parent.ExpandAll();
|
|
|
+ treeView_G.SelectedNode = _node;
|
|
|
+ m_MainForm.ChangeSTDEditorAndGrid_Attributes((STDdata)_node.Tag);
|
|
|
+ Predata = (STDdata)_node.Tag;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -716,7 +422,7 @@ namespace OTSPartA_STDEditor
|
|
|
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()));
|
|
|
+ m_MainForm.ChangeSTDEditorAndGrid_Attributes((STDdata)_node.Tag);
|
|
|
Predata = (STDdata)_node.Tag;
|
|
|
}
|
|
|
}
|
|
@@ -729,13 +435,15 @@ namespace OTSPartA_STDEditor
|
|
|
GroupViewDic[((STDGroups)m_targetNode.Tag).id].ContainSTD.Add((STDdata)_node.Tag);
|
|
|
treeView_G.SelectedNode = _node; // 选中节点
|
|
|
m_targetNode.Expand(); // 展开父节点
|
|
|
- m_MainForm.ChangeSTDEditorAndGrid_Attributes(int.Parse(((STDdata)_node.Tag).STDId.ToString()));
|
|
|
+ m_MainForm.ChangeSTDEditorAndGrid_Attributes((STDdata)_node.Tag);
|
|
|
Predata = (STDdata)_node.Tag;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
+ m_MainForm.SetNull();
|
|
|
+ Predata = null;
|
|
|
if (!m_targetNode.Equals(_node)&& m_targetNode.Text != "Default")
|
|
|
{
|
|
|
if (m_targetNode.Level == _node.Level)
|
|
@@ -743,16 +451,12 @@ namespace OTSPartA_STDEditor
|
|
|
_node.Remove();
|
|
|
treeView_G.Nodes.Insert(m_targetNode.Index+1, _node);
|
|
|
treeView_G.SelectedNode = _node;
|
|
|
- m_MainForm.SetNull();
|
|
|
- Predata = null;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
_node.Remove();
|
|
|
treeView_G.Nodes.Insert(m_targetNode.Parent.Index+1, _node);
|
|
|
treeView_G.SelectedNode = _node;
|
|
|
- m_MainForm.SetNull();
|
|
|
- Predata = null;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -763,7 +467,6 @@ namespace OTSPartA_STDEditor
|
|
|
|
|
|
[DllImport("user32.dll")]
|
|
|
private static extern int SendMessage(IntPtr hWnd, int wMsg, int wParam,int lParam);
|
|
|
-
|
|
|
private void treeView_G_DragOver(object sender, DragEventArgs e)
|
|
|
{
|
|
|
const Single scrollRegion = 20;
|
|
@@ -779,6 +482,9 @@ namespace OTSPartA_STDEditor
|
|
|
TreeNode _node2 = treeView_G.GetNodeAt(treeView_G.PointToClient(new Point(e.X, e.Y)));
|
|
|
m_targetNode = null;
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
if (_node2 != null)
|
|
|
{
|
|
|
m_targetNode = _node2;
|
|
@@ -791,8 +497,7 @@ namespace OTSPartA_STDEditor
|
|
|
}
|
|
|
private void treeView_G_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
|
|
|
{
|
|
|
-
|
|
|
- if(Predata!=null)
|
|
|
+ if (Predata!=null)
|
|
|
{
|
|
|
m_MainForm.SaveDataOfSelRule(Predata.STDId);
|
|
|
}
|
|
@@ -804,8 +509,9 @@ namespace OTSPartA_STDEditor
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- m_MainForm.ChangeSTDEditorAndGrid_Attributes(int.Parse(((STDdata)e.Node.Tag).STDId.ToString()));
|
|
|
+ m_MainForm.ChangeSTDEditorAndGrid_Attributes((STDdata)e.Node.Tag);
|
|
|
Predata = (STDdata)e.Node.Tag;
|
|
|
+ treeView_G.SelectedNode = e.Node;
|
|
|
}
|
|
|
}
|
|
|
public void AdjustTreenodeByGroup(int Groupid)
|
|
@@ -844,24 +550,25 @@ namespace OTSPartA_STDEditor
|
|
|
GroupViewDic[Groupid].ContainSTD.Add(ddata);
|
|
|
treeView_G.SelectedNode = node1;
|
|
|
nodenew.Expand();
|
|
|
- m_MainForm.ChangeSTDEditorAndGrid_Attributes(int.Parse(((STDdata)node1.Tag).STDId.ToString()));
|
|
|
+ m_MainForm.ChangeSTDEditorAndGrid_Attributes((STDdata)node1.Tag);
|
|
|
Predata = ddata;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- private void ToolStripMenuItem_RenameGroup_Click(object sender, EventArgs e)
|
|
|
+ private void ToolStripMenuItem_Rename_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
if (treeView_G.SelectedNode != null)
|
|
|
{
|
|
|
-
|
|
|
+ RenFlag = true;
|
|
|
+ treeView_G.SelectedNode.Text = "";
|
|
|
if (treeView_G.SelectedNode.Level == 0)
|
|
|
{
|
|
|
|
|
|
if (treeView_G.SelectedNode.Text == "Default")
|
|
|
{
|
|
|
- MessageBox.Show("默认组不能更改名称!", "Tip");
|
|
|
+ MessageBox.Show("The default group cannot be changed!", "Tip");
|
|
|
treeView_G.SelectedNode.EndEdit(true);
|
|
|
return;
|
|
|
}
|
|
@@ -872,8 +579,7 @@ namespace OTSPartA_STDEditor
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- MessageBox.Show("Please select a group!", "Tip");
|
|
|
- treeView_G.SelectedNode.EndEdit(true);
|
|
|
+ treeView_G.SelectedNode.BeginEdit();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -881,25 +587,192 @@ namespace OTSPartA_STDEditor
|
|
|
{
|
|
|
if (treeView_G.SelectedNode.Level == 0)
|
|
|
{
|
|
|
- if(e.Label==null|| e.Label =="")
|
|
|
+ if(e.Label == null|| e.Label == "")
|
|
|
{
|
|
|
MessageBox.Show("GroupName Cannot Be Null!", "Tip");
|
|
|
e.CancelEdit=true;
|
|
|
+ treeView_G.SelectedNode.Text = ((STDGroups)treeView_G.SelectedNode.Tag).name;
|
|
|
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();
|
|
|
+ if (e.Label != null && e.Label != "")
|
|
|
+ {
|
|
|
+ if (m_MainForm._sTDEditor.GroupIdDictionaryFromName.ContainsKey(e.Label))
|
|
|
+ {
|
|
|
+ MessageBox.Show("Group names cannot be duplicated!", "Tip");
|
|
|
+ e.CancelEdit = true;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ 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;
|
|
|
+ if (e.Label == null || e.Label == "")
|
|
|
+ {
|
|
|
+ MessageBox.Show("RuleName Cannot Be Null!", "Tip");
|
|
|
+ e.CancelEdit = true;
|
|
|
+ treeView_G.SelectedNode.Text = ((STDdata)treeView_G.SelectedNode.Tag).StrName;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (e.Label != null && e.Label != "")
|
|
|
+ {
|
|
|
+ STDdata sT = (STDdata)treeView_G.SelectedNode.Tag;
|
|
|
+ foreach (int grpid in GroupViewDic.Keys)
|
|
|
+ {
|
|
|
+ foreach (STDdata ddata in GroupViewDic[grpid].ContainSTD)
|
|
|
+ {
|
|
|
+ if (ddata.STDId == ((STDdata)treeView_G.SelectedNode.Tag).STDId)
|
|
|
+ {
|
|
|
+ ddata.StrName = e.Label;
|
|
|
+ m_MainForm.ChangeSTDEditorAndGrid_Attributes(ddata);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ private void ToolStripMenuItem_NewRule_Click(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ TreeNode _node2 = treeView_G.SelectedNode;
|
|
|
+ if (_node2 != null)
|
|
|
+ {
|
|
|
+ if (Predata != null)
|
|
|
+ {
|
|
|
+ m_MainForm.SaveDataOfSelRule(Predata.STDId);
|
|
|
+ }
|
|
|
+ STDdata ddata= m_MainForm._sTDEditor.AddSTDDictionaryItem();
|
|
|
+ int STDId = 40000;
|
|
|
+ foreach (STDGroups grp in GroupViewDic.Values)
|
|
|
+ {
|
|
|
+ foreach (STDdata ddata1 in grp.ContainSTD)
|
|
|
+ {
|
|
|
+ if (STDId < ddata1.STDId)
|
|
|
+ {
|
|
|
+ STDId = ddata1.STDId;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ddata.STDId = STDId + 1;
|
|
|
+ TreeNode treeNode = new TreeNode();
|
|
|
+ treeNode.Text = ddata.StrName;
|
|
|
+ treeNode.Tag = ddata;
|
|
|
+ if (_node2.Level == 0)
|
|
|
+ {
|
|
|
+ ddata.ListNum = ((((STDGroups)treeView_G.SelectedNode.Tag).ContainSTD).Count - 1).ToString();
|
|
|
+ ddata.GroupId = ((STDGroups)_node2.Tag).id;
|
|
|
+ ((STDGroups)treeView_G.SelectedNode.Tag).ContainSTD.Add(ddata);
|
|
|
+ _node2.Nodes.Add(treeNode);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ddata.ListNum = ((((STDGroups)treeView_G.SelectedNode.Parent.Tag).ContainSTD).Count - 1).ToString();
|
|
|
+ ddata.GroupId = ((STDGroups)_node2.Parent.Tag).id;
|
|
|
+ ((STDGroups)treeView_G.SelectedNode.Parent.Tag).ContainSTD.Add(ddata);
|
|
|
+ _node2.Parent.Nodes.Add(treeNode);
|
|
|
+ }
|
|
|
+ m_MainForm.ChangeSTDEditorAndGrid_Attributes(ddata);
|
|
|
+ Predata = (STDdata)treeNode.Tag;
|
|
|
+ InitGroupView();
|
|
|
+ foreach(TreeNode node in treeView_G.Nodes)
|
|
|
+ {
|
|
|
+ foreach (TreeNode node1 in node.Nodes)
|
|
|
+ {
|
|
|
+ if (((STDdata)node1.Tag).STDId == ddata.STDId)
|
|
|
+ {
|
|
|
+ treeView_G.SelectedNode = node1;
|
|
|
+ this.Refresh();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ foreach (TreeNode treeNode1 in treeView_G.Nodes)
|
|
|
+ {
|
|
|
+ if (((STDGroups)treeNode1.Tag).name == "Default")
|
|
|
+ {
|
|
|
+ if(Predata != null)
|
|
|
+ {
|
|
|
+ m_MainForm.SaveDataOfSelRule(Predata.STDId);
|
|
|
+ }
|
|
|
+ STDdata ddata = m_MainForm._sTDEditor.AddSTDDictionaryItem();
|
|
|
+ int STDId = 40000;
|
|
|
+ foreach (STDGroups grp in GroupViewDic.Values)
|
|
|
+ {
|
|
|
+ foreach (STDdata ddata1 in grp.ContainSTD)
|
|
|
+ {
|
|
|
+ if (STDId < ddata1.STDId)
|
|
|
+ {
|
|
|
+ STDId = ddata1.STDId;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ddata.STDId = STDId + 1;
|
|
|
+ TreeNode treeNode = new TreeNode();
|
|
|
+ treeNode.Text= ddata.StrName;
|
|
|
+ treeNode.Tag = ddata;
|
|
|
+
|
|
|
+ ddata.ListNum = ((((STDGroups)treeNode1.Tag).ContainSTD).Count - 1).ToString();
|
|
|
+ ddata.GroupId = ((STDGroups)treeNode1.Tag).id;
|
|
|
+ ((STDGroups)treeNode1.Tag).ContainSTD.Add(ddata);
|
|
|
+ InitGroupView();
|
|
|
+
|
|
|
+ foreach (TreeNode node in treeView_G.Nodes)
|
|
|
+ {
|
|
|
+ foreach (TreeNode node1 in node.Nodes)
|
|
|
+ {
|
|
|
+ if (((STDdata)node1.Tag).STDId == ddata.STDId)
|
|
|
+ {
|
|
|
+ treeView_G.SelectedNode = node1;
|
|
|
+ m_MainForm.ChangeSTDEditorAndGrid_Attributes(ddata);
|
|
|
+ Predata = (STDdata)treeNode.Tag;
|
|
|
+ treeView_G.Focus();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ private void treeView_G_KeyUp(object sender, KeyEventArgs e)
|
|
|
+ {
|
|
|
+ if (e.KeyCode == Keys.Up|| e.KeyCode == Keys.Down)
|
|
|
+ {
|
|
|
+ if (Predata != null)
|
|
|
+ {
|
|
|
+ int id = Predata.STDId;
|
|
|
+ m_MainForm.SaveDataOfSelRule(id);
|
|
|
+ }
|
|
|
+ if (treeView_G.SelectedNode.Level != 0 && treeView_G.SelectedNode != null)
|
|
|
+ {
|
|
|
+ m_MainForm.ChangeSTDEditorAndGrid_Attributes((STDdata)treeView_G.SelectedNode.Tag);
|
|
|
+ Predata = (STDdata)treeView_G.SelectedNode.Tag;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ m_MainForm.SetNull();
|
|
|
+ Predata = null;
|
|
|
+ }
|
|
|
+ m_MainForm.m_SubMidWindow.m_ComparativeLibrary.MakeCheckboxUnchecked();
|
|
|
}
|
|
|
}
|
|
|
+ private void treeView_G_BeforeLabelEdit(object sender, NodeLabelEditEventArgs e)
|
|
|
+ {
|
|
|
+ if (!RenFlag) e.CancelEdit = true;
|
|
|
+ RenFlag = false;
|
|
|
+ }
|
|
|
}
|
|
|
}
|