|
@@ -2,20 +2,17 @@
|
|
|
using SourceGrid;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
-using System.ComponentModel;
|
|
|
-using System.Data;
|
|
|
using System.Drawing;
|
|
|
-using System.Linq;
|
|
|
-using System.Text;
|
|
|
-using System.Threading.Tasks;
|
|
|
+using System.Drawing.Imaging;
|
|
|
+using System.Runtime.InteropServices;
|
|
|
+
|
|
|
using System.Windows.Forms;
|
|
|
-using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
|
|
|
|
|
namespace OTSPartA_STDEditor
|
|
|
{
|
|
|
public partial class STDRuleslist : DockContent
|
|
|
{
|
|
|
- public int PreRow = 1;//之前选中的位置
|
|
|
+ public STDdata Predata = null;//之前选中的位置
|
|
|
public Form_Main m_MainForm = null;
|
|
|
ValueChangedEvent m_ValueChangedEvent = null;//单元格内容改变事件
|
|
|
Dictionary<int,STDGroups> GroupViewDic=null;
|
|
@@ -26,75 +23,16 @@ namespace OTSPartA_STDEditor
|
|
|
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");
|
|
|
- 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-10;
|
|
|
- Grid_Minerals.Columns[1].Width = this.Width/2-20;
|
|
|
-
|
|
|
-
|
|
|
- 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.Key;
|
|
|
-
|
|
|
-
|
|
|
- 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;
|
|
|
-
|
|
|
-
|
|
|
+ InitRuleView();
|
|
|
button_UpOrder.Enabled = false;
|
|
|
button_DownOrder.Enabled = false;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// [颜色:16进制转成RGB]
|
|
|
/// </summary>
|
|
@@ -125,67 +63,44 @@ namespace OTSPartA_STDEditor
|
|
|
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()));
|
|
|
+ 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();
|
|
|
- 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();
|
|
|
- //}
|
|
|
+ Predata = (STDdata)Grid_Minerals[i, 0].Tag;
|
|
|
}
|
|
|
-
|
|
|
SetOrderButtonsStatus();
|
|
|
}
|
|
|
- /// <summary>
|
|
|
- /// 新建
|
|
|
- /// </summary>
|
|
|
- /// <param name="sender"></param>
|
|
|
- /// <param name="e"></param>
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
private void ToolStripMenuItem_New_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
int i = Grid_Minerals.Selection.ActivePosition.Row;
|
|
|
int j = Grid_Minerals.Selection.ActivePosition.Column;
|
|
|
-
|
|
|
- /// 保证鼠标点击的GRID行和列是有效的
|
|
|
if (i >= 0 && j >= 0)
|
|
|
{
|
|
|
- ////规则名称不为空
|
|
|
- //if (Grid_Minerals[i, j].Value.ToString().Replace(" ", "").Trim() != "")
|
|
|
- //{
|
|
|
- // if (m_MainForm.CheckAttributes())
|
|
|
- // {
|
|
|
- // if (m_MainForm.Checktextbox_STDEditor())
|
|
|
- // {
|
|
|
- m_MainForm.SaveDataOfSelRule(i, j);
|
|
|
-
|
|
|
- int STDId = m_MainForm._sTDEditor.AddSTDDictionaryItem();
|
|
|
- AddNewRow(STDId, "NewRuleName", Attributes.colorHx16toRGB(m_MainForm._sTDEditor.STDDictionary[STDId].Color));
|
|
|
- m_MainForm.m_SubMidWindow.m_ComparativeLibrary.MakeCheckboxUnchecked();
|
|
|
- // }
|
|
|
- // }
|
|
|
- //}
|
|
|
+ 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
|
|
|
{
|
|
@@ -193,38 +108,30 @@ namespace OTSPartA_STDEditor
|
|
|
AddNewRow(STDId, "NewRuleName", Attributes.colorHx16toRGB(m_MainForm._sTDEditor.STDDictionary[STDId].Color));
|
|
|
m_MainForm.m_SubMidWindow.m_ComparativeLibrary.MakeCheckboxUnchecked();
|
|
|
}
|
|
|
- //SetOrderButtonsStatus();
|
|
|
}
|
|
|
-
|
|
|
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 = STDId;
|
|
|
+ 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();
|
|
|
- //Grid_Minerals[Grid_Minerals.Rows.Count - 1, 1].AddController(SourceGrid.Cells.Controllers.Unselectable.Default);
|
|
|
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);
|
|
|
-
|
|
|
- PreRow = Grid_Minerals.Rows.Count - 1;
|
|
|
+ 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((int)Grid_Minerals[x, 0].Tag);
|
|
|
+ m_MainForm.RemoveSTDDictionaryItem(((STDdata)Grid_Minerals[x, 0].Tag).STDId);
|
|
|
Grid_Minerals.Rows.Remove(x);
|
|
|
if (Grid_Minerals.RowsCount > 1)
|
|
|
{
|
|
@@ -233,9 +140,8 @@ namespace OTSPartA_STDEditor
|
|
|
Position pos = new Position(x, 0);
|
|
|
Grid_Minerals.Selection.Focus(pos, true);
|
|
|
Grid_Minerals[x, 0].Grid.Select();
|
|
|
-
|
|
|
- m_MainForm.ChangeSTDEditorAndGrid_Attributes(int.Parse(Grid_Minerals[x, 0].Tag.ToString()));
|
|
|
- PreRow = x;
|
|
|
+ m_MainForm.ChangeSTDEditorAndGrid_Attributes(((STDdata)Grid_Minerals[x, 0].Tag).STDId);
|
|
|
+ Predata = (STDdata)Grid_Minerals[x, 0].Tag;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -243,26 +149,45 @@ namespace OTSPartA_STDEditor
|
|
|
Grid_Minerals.Selection.Focus(pos, true);
|
|
|
Grid_Minerals[x - 1, 0].Grid.Select();
|
|
|
|
|
|
- m_MainForm.ChangeSTDEditorAndGrid_Attributes(int.Parse(Grid_Minerals[x - 1, 0].Tag.ToString()));
|
|
|
- PreRow = x - 1;
|
|
|
+ m_MainForm.ChangeSTDEditorAndGrid_Attributes(((STDdata)Grid_Minerals[x-1, 0].Tag).STDId);
|
|
|
+ Predata = (STDdata)Grid_Minerals[x-1, 0].Tag;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
m_MainForm.SetNull();
|
|
|
- PreRow = -1;
|
|
|
+ Predata = null;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
MessageBox.Show("There is no rule to delete!", "Tip");
|
|
|
}
|
|
|
- SetOrderButtonsStatus();
|
|
|
}
|
|
|
private void ToolStripMenuItem_Del_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
Grid_MineralsDelRow();
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
public class ValueChangedEvent : SourceGrid.Cells.Controllers.ControllerBase
|
|
|
{
|
|
@@ -285,12 +210,10 @@ namespace OTSPartA_STDEditor
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
public void ChangeStrName(int RowNum, string NewStrName)
|
|
|
{
|
|
|
m_MainForm.ChangeStrName(RowNum, NewStrName);
|
|
|
}
|
|
|
-
|
|
|
private void Grid_Minerals_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
|
|
|
{
|
|
|
SourceGrid.Grid ls_gd = (SourceGrid.Grid)sender;
|
|
@@ -303,27 +226,26 @@ namespace OTSPartA_STDEditor
|
|
|
}
|
|
|
if (e.KeyCode == Keys.Up)
|
|
|
{
|
|
|
- /// 保证鼠标点击的GRID行和列是有效的
|
|
|
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;
|
|
|
+ }
|
|
|
|
|
|
- m_MainForm.SaveDataOfSelRule(i, 0);
|
|
|
- m_MainForm.ChangeSTDEditorAndGrid_Attributes(int.Parse(Grid_Minerals[i - 1, 0].Tag.ToString()));
|
|
|
- m_MainForm.m_SubMidWindow.m_ComparativeLibrary.MakeCheckboxUnchecked();
|
|
|
- PreRow = i;
|
|
|
- if (i == 2)
|
|
|
- {
|
|
|
- button_UpOrder.Enabled = false;
|
|
|
- }
|
|
|
- if (i == ls_gd.RowsCount - 1)
|
|
|
- {
|
|
|
- button_DownOrder.Enabled = true;
|
|
|
- }
|
|
|
-
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -335,17 +257,15 @@ namespace OTSPartA_STDEditor
|
|
|
}
|
|
|
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(i, 0);
|
|
|
- m_MainForm.ChangeSTDEditorAndGrid_Attributes(int.Parse(Grid_Minerals[i + 1, 0].Tag.ToString()));
|
|
|
- PreRow = i;
|
|
|
+ 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)
|
|
@@ -371,137 +291,68 @@ namespace OTSPartA_STDEditor
|
|
|
Grid_MineralsDelRow();
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
public int ChangeSTDRulesLISTBackColor()
|
|
|
{
|
|
|
- if (Grid_Minerals.RowsCount > 1)
|
|
|
+ if (tabControl1.SelectedIndex == 1)
|
|
|
{
|
|
|
- Position pos = new Position(1, 0);
|
|
|
- Grid_Minerals[1, 0].Grid.Select();
|
|
|
+ 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[(int)Grid_Minerals[Grid_Minerals.Selection.ActivePosition.Row, 0].Tag].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 (int)Grid_Minerals[Grid_Minerals.Selection.ActivePosition.Row, 0].Tag;
|
|
|
+ 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;
|
|
|
+ }
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- return -1;
|
|
|
+ if(treeView_G.SelectedNode.Level==0)
|
|
|
+ {
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return id;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- private void MenuStrip_STDRulelist_Resize(object sender, EventArgs e)
|
|
|
- {
|
|
|
- }
|
|
|
-
|
|
|
private void button_UpOrder_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
- Grid_Minerals.Focus(true);
|
|
|
- int selrow = Grid_Minerals.Selection.ActivePosition.Row;
|
|
|
-
|
|
|
- int id = (int)Grid_Minerals[selrow, 0].Tag;
|
|
|
- int id2 = (int)Grid_Minerals[selrow - 1, 0].Tag;
|
|
|
- string sname = Grid_Minerals[selrow, 0].Value.ToString();
|
|
|
-
|
|
|
- Grid_Minerals[selrow, 0].Value = Grid_Minerals[selrow - 1, 0].Value;
|
|
|
- Grid_Minerals[selrow, 0].Tag = id2;
|
|
|
- SourceGrid.Cells.Views.Cell view = new SourceGrid.Cells.Views.Cell();
|
|
|
- view.BackColor = colorHx16toRGB(m_MainForm._sTDEditor.STDDictionary[id2].Color);
|
|
|
- Grid_Minerals[selrow, 1].View = view;
|
|
|
-
|
|
|
- Grid_Minerals[selrow - 1, 0].Value = sname;
|
|
|
- Grid_Minerals[selrow - 1, 0].Tag = id;
|
|
|
- SourceGrid.Cells.Views.Cell view2 = new SourceGrid.Cells.Views.Cell();
|
|
|
- view2.BackColor = colorHx16toRGB(m_MainForm._sTDEditor.STDDictionary[id].Color);
|
|
|
- Grid_Minerals[selrow - 1, 1].View = view2;
|
|
|
-
|
|
|
- m_MainForm._sTDEditor.STDDictionary[id].StrName = Grid_Minerals[selrow - 1, 0].Value.ToString();
|
|
|
- m_MainForm._sTDEditor.STDDictionary[id2].StrName = Grid_Minerals[selrow, 0].Value.ToString();
|
|
|
-
|
|
|
- Position pos = new Position(selrow - 1, 1);
|
|
|
- Grid_Minerals[selrow - 1, 0].Grid.Select();
|
|
|
- Grid_Minerals.Selection.Focus(pos, true);
|
|
|
- PreRow = selrow - 1;
|
|
|
-
|
|
|
- button_DownOrder.Enabled = true;
|
|
|
- if (selrow - 1 == 1)
|
|
|
- {
|
|
|
- button_UpOrder.Enabled = false;
|
|
|
- }
|
|
|
- m_MainForm.IsModified = true;
|
|
|
- Grid_Minerals.Refresh();
|
|
|
- //m_MainForm.ChangeSTDEditorAndGrid_Attributes(int.Parse(Grid_Minerals[selrow-1, 0].Tag.ToString()));
|
|
|
+
|
|
|
}
|
|
|
-
|
|
|
private void button_DownOrder_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
- Grid_Minerals.Focus(true);
|
|
|
- int selrow = Grid_Minerals.Selection.ActivePosition.Row;
|
|
|
-
|
|
|
- int id = (int)Grid_Minerals[selrow, 0].Tag;
|
|
|
- int id2 = (int)Grid_Minerals[selrow + 1, 0].Tag;
|
|
|
- string sname = Grid_Minerals[selrow, 0].Value.ToString();
|
|
|
-
|
|
|
- Grid_Minerals[selrow, 0].Value = Grid_Minerals[selrow + 1, 0].Value;
|
|
|
- Grid_Minerals[selrow, 0].Tag = id2;
|
|
|
- SourceGrid.Cells.Views.Cell view = new SourceGrid.Cells.Views.Cell();
|
|
|
- view.BackColor = colorHx16toRGB(m_MainForm._sTDEditor.STDDictionary[id2].Color);
|
|
|
- Grid_Minerals[selrow, 1].View = view;
|
|
|
-
|
|
|
- Grid_Minerals[selrow + 1, 0].Value = sname;
|
|
|
- Grid_Minerals[selrow + 1, 0].Tag = id;
|
|
|
- SourceGrid.Cells.Views.Cell view2 = new SourceGrid.Cells.Views.Cell();
|
|
|
- view2.BackColor = colorHx16toRGB(m_MainForm._sTDEditor.STDDictionary[id].Color);
|
|
|
- Grid_Minerals[selrow + 1, 1].View = view2;
|
|
|
-
|
|
|
- m_MainForm._sTDEditor.STDDictionary[id].StrName = Grid_Minerals[selrow + 1, 0].Value.ToString();
|
|
|
- m_MainForm._sTDEditor.STDDictionary[id2].StrName = Grid_Minerals[selrow, 0].Value.ToString();
|
|
|
-
|
|
|
- Position pos = new Position(selrow + 1, 0);
|
|
|
- Grid_Minerals[selrow + 1, 0].Grid.Select();
|
|
|
- Grid_Minerals.Selection.Focus(pos, true);
|
|
|
-
|
|
|
- PreRow = selrow + 1;
|
|
|
-
|
|
|
- button_UpOrder.Enabled = true;
|
|
|
- if (selrow + 1 == Grid_Minerals.RowsCount - 1)
|
|
|
- {
|
|
|
- button_DownOrder.Enabled = false;
|
|
|
- }
|
|
|
- #region 添加修改stdid顺序 ,由于需求改变只完成一部分(差相应修改能谱部分)
|
|
|
- //DialogResult result=MessageBox.Show("检测到顺序已修改,是否调整STDId?", "提示",MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
|
|
|
- //if (result == DialogResult.Yes)
|
|
|
- //{
|
|
|
- // ChangeSTDidFromNum changeSTDidFromNum = new ChangeSTDidFromNum();
|
|
|
- // DialogResult res=changeSTDidFromNum.ShowDialog();
|
|
|
- // {
|
|
|
- // if (res == DialogResult.OK)
|
|
|
- // {
|
|
|
- // int StartId = int.Parse(changeSTDidFromNum.textBox_NewFirstSTDId.Text);
|
|
|
- // Dictionary<int, STDdata> STDDictionaryCopy = new Dictionary<int, STDdata>();
|
|
|
- // for (int i = 0; i < Grid_Minerals.RowsCount-1; i++)
|
|
|
- // {
|
|
|
- // STDdata dataCopy = m_MainForm._sTDEditor.STDDictionary[(int)Grid_Minerals[i+1, 0].Tag];
|
|
|
- // STDDictionaryCopy.Add(StartId + i, dataCopy);
|
|
|
- // }
|
|
|
- // m_MainForm._sTDEditor.STDDictionary.Clear();
|
|
|
- // m_MainForm._sTDEditor.STDDictionary = STDDictionaryCopy;
|
|
|
- // }
|
|
|
- // }
|
|
|
- //}
|
|
|
- #endregion
|
|
|
- m_MainForm.IsModified = true;
|
|
|
- Grid_Minerals.Refresh();
|
|
|
+
|
|
|
}
|
|
|
|
|
|
public void InsertNewRow(int STDId, string RuleName, Color color)
|
|
|
{
|
|
|
Grid_Minerals.Focus(true);
|
|
|
Grid_Minerals.Rows.InsertRange(Grid_Minerals.Selection.ActivePosition.Row, 1);
|
|
|
- //Grid_Minerals.Rows.Insert(Grid_Minerals.Rows.Count);
|
|
|
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 = STDId;
|
|
|
+ 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);
|
|
@@ -510,19 +361,11 @@ namespace OTSPartA_STDEditor
|
|
|
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);
|
|
|
-
|
|
|
- PreRow = Grid_Minerals.Selection.ActivePosition.Row - 1;
|
|
|
+ Predata = (STDdata)Grid_Minerals[Grid_Minerals.Selection.ActivePosition.Row - 1, 0].Tag ;
|
|
|
SetOrderButtonsStatus();
|
|
|
}
|
|
|
-
|
|
|
- private void Grid_Minerals_VScrollPositionChanged(object sender, ScrollPositionChangedEventArgs e)
|
|
|
- {
|
|
|
- //Grid_Minerals.Refresh();
|
|
|
- }
|
|
|
-
|
|
|
void SetOrderButtonsStatus()
|
|
|
{
|
|
|
Grid_Minerals.Focus();
|
|
@@ -549,68 +392,418 @@ namespace OTSPartA_STDEditor
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- button_UpOrder.Enabled = false;
|
|
|
- button_DownOrder.Enabled = false;
|
|
|
+ button_UpOrder.Enabled = false;button_DownOrder.Enabled = false;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
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();
|
|
|
+ //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;
|
|
|
+ // if (m_MainForm._sTDEditor.STDDictionary.ContainsKey(id))
|
|
|
+ // {
|
|
|
+ // m_MainForm.ChangeSTDEditorAndGrid_Attributes(id);
|
|
|
+ // Predata = (STDdata)Grid_Minerals[i, 0].Tag;
|
|
|
+ // }
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+ //}
|
|
|
}
|
|
|
}
|
|
|
void InitGroupEditorView()
|
|
|
{
|
|
|
GroupViewDic = ConvertToGroupViewDic();
|
|
|
- foreach(STDGroups group in GroupViewDic.Values)
|
|
|
+ InitGroupView();
|
|
|
+ }
|
|
|
+
|
|
|
+ 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[Ddata.GroupId].ContainSTD.Add(Ddata);
|
|
|
+ }
|
|
|
+ return keyValuePairs;
|
|
|
+ }
|
|
|
+ public void ConvertToRuleViewDic()
|
|
|
+ {
|
|
|
+ m_MainForm._sTDEditor.GroupIdDictionaryFromId.Clear();
|
|
|
+ m_MainForm._sTDEditor.GroupIdDictionaryFromName.Clear();
|
|
|
+ m_MainForm._sTDEditor.STDDictionary.Clear();
|
|
|
+ foreach (STDGroups group in GroupViewDic.Values)
|
|
|
+ {
|
|
|
+ foreach (STDdata Ddata in group.ContainSTD)
|
|
|
+ {
|
|
|
+ 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());
|
|
|
+ }
|
|
|
+ if (treeView_G.SelectedNode == null){return;}
|
|
|
+ if (treeView_G.SelectedNode.Level == 1)
|
|
|
+ {
|
|
|
+ m_MainForm.SaveDataOfSelRule(((STDdata)treeView_G.SelectedNode.Tag).STDId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ private void ToolStripMenuItem_NewGroup_Click(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ STDGroups group = new STDGroups();
|
|
|
+ int id = 0;
|
|
|
+ foreach(STDGroups grp in GroupViewDic.Values)
|
|
|
+ {
|
|
|
+ if(grp.id>id)
|
|
|
+ {
|
|
|
+ id= grp.id;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ id++;
|
|
|
+ group.id = id;
|
|
|
+ group.name = "Group" + id.ToString();
|
|
|
+ group.color = Attributes.colorRGBtoHx16(Color.WhiteSmoke.R, Color.WhiteSmoke.G, Color.WhiteSmoke.B);
|
|
|
+ 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;
|
|
|
+ m_MainForm.SetNull();
|
|
|
+ Predata = null;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ private void ToolStripMenuItem_DelGroup_Click(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ if(treeView_G.SelectedNode==null)
|
|
|
+ {
|
|
|
+ MessageBox.Show("Please select a group!", "Tip");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (treeView_G.SelectedNode.Level == 0)
|
|
|
+ {
|
|
|
+ int id = ((STDGroups)treeView_G.SelectedNode.Tag).id;
|
|
|
+ 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);
|
|
|
+ GroupViewDic.Remove(id);
|
|
|
+ treeView_G.Nodes.Remove(treeView_G.SelectedNode);
|
|
|
+ this.Refresh();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ MessageBox.Show("Please select a group!", "Tip");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ private void ToolStripMenuItem_EdGroupColor_Click(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ if(treeView_G.SelectedNode==null)
|
|
|
+ {
|
|
|
+ MessageBox.Show("Please select a group!", "Tip");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (treeView_G.SelectedNode.Level == 0)
|
|
|
+ {
|
|
|
+ ColorDialog cd = new ColorDialog();
|
|
|
+ cd.FullOpen = true;//自定义颜色界面打开
|
|
|
+ DialogResult result = cd.ShowDialog();
|
|
|
+ if (result == DialogResult.OK)
|
|
|
+ {
|
|
|
+ GroupViewDic[((STDGroups)treeView_G.SelectedNode.Tag).id].color = Attributes.colorRGBtoHx16(cd.Color.R, cd.Color.G, cd.Color.B);
|
|
|
+ InitGroupView();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ MessageBox.Show("Please select a group!", "Tip");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ void InitGroupView()
|
|
|
+ {
|
|
|
+ treeView_G.ImageList=new ImageList();
|
|
|
+ treeView_G.Nodes.Clear();
|
|
|
+ treeView_G.ImageList.ColorDepth = ColorDepth.Depth32Bit;
|
|
|
+ foreach (STDGroups group in GroupViewDic.Values)
|
|
|
{
|
|
|
TreeNode treeNode = new TreeNode();
|
|
|
treeNode.Tag = group;
|
|
|
- treeNode.Text=group.name;
|
|
|
- treeNode.BackColor= Attributes.colorHx16toRGB(group.color);
|
|
|
+ treeNode.Text = group.name;
|
|
|
+ Color color = Attributes.colorHx16toRGB(group.color);
|
|
|
+ Bitmap bitmap = new Bitmap(100, 100, PixelFormat.Format32bppArgb);
|
|
|
+ Graphics graphics = Graphics.FromImage(bitmap);
|
|
|
+ SolidBrush b1 = new SolidBrush(color);
|
|
|
+ graphics.FillEllipse(b1, new Rectangle(0, 0, 100, 100));
|
|
|
+ treeView_G.ImageList.Images.Add(group.id.ToString(),bitmap);
|
|
|
+ treeNode.ImageKey = group.id.ToString();
|
|
|
+ treeNode.SelectedImageKey = group.id.ToString();
|
|
|
treeView_G.Nodes.Add(treeNode);
|
|
|
- foreach(STDdata ddata in group.ContainSTD)
|
|
|
+ foreach (STDdata ddata in group.ContainSTD)
|
|
|
{
|
|
|
TreeNode childtreeNode = new TreeNode();
|
|
|
childtreeNode.Tag = ddata;
|
|
|
childtreeNode.Text = ddata.StrName;
|
|
|
+ Color color2 = Attributes.colorHx16toRGB(ddata.Color);
|
|
|
+ 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);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
treeView_G.Font = new Font("微软雅黑", 12);
|
|
|
- treeView_G.ShowLines=false;
|
|
|
- //treeView_G.ExpandAll();
|
|
|
+ treeView_G.ShowLines = false;
|
|
|
this.Refresh();
|
|
|
}
|
|
|
- Dictionary<int, STDGroups> ConvertToGroupViewDic()
|
|
|
+ void InitRuleView()
|
|
|
{
|
|
|
- Dictionary<int, STDGroups> keyValuePairs = new Dictionary<int, STDGroups>();
|
|
|
- keyValuePairs = m_MainForm._sTDEditor.GroupDictionary;
|
|
|
- foreach (STDGroups group in keyValuePairs.Values)
|
|
|
+ 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")
|
|
|
{
|
|
|
- group.ContainSTD.Clear();
|
|
|
+ head1 = new SourceGrid.Cells.ColumnHeader("Rule Name");
|
|
|
}
|
|
|
- foreach (STDdata Ddata in m_MainForm._sTDEditor.STDDictionary.Values)
|
|
|
+ else
|
|
|
{
|
|
|
- keyValuePairs[int.Parse(Ddata.GroupId)].ContainSTD.Add(Ddata);
|
|
|
+ head1 = new SourceGrid.Cells.ColumnHeader("规则名称");
|
|
|
}
|
|
|
- return keyValuePairs;
|
|
|
+ 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;
|
|
|
}
|
|
|
- void ConvertToRuleViewDic()
|
|
|
+
|
|
|
+ private void treeView_G_ItemDrag(object sender, ItemDragEventArgs e)
|
|
|
{
|
|
|
- foreach (STDGroups group in GroupViewDic.Values)
|
|
|
+ if (e.Button == MouseButtons.Left)
|
|
|
{
|
|
|
- foreach (STDdata Ddata in group.ContainSTD)
|
|
|
+ //只处理左键拖拽操作;
|
|
|
+ m_targetNode = null;
|
|
|
+ TreeNode _node = (TreeNode)e.Item;
|
|
|
+ //只允许拖拽子级节点;
|
|
|
+ if (_node.Level > 0)
|
|
|
{
|
|
|
- m_MainForm._sTDEditor.STDDictionary[int.Parse(Ddata.STDId)].GroupId = group.id.ToString();
|
|
|
+ //开始拖拽;
|
|
|
+ DoDragDrop(e.Item, DragDropEffects.Move | DragDropEffects.Copy);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ TreeNode m_targetNode; //用于记录当前拖拽到的目标节点;
|
|
|
+ private void treeView_G_DragDrop(object sender, DragEventArgs e)
|
|
|
+ {
|
|
|
+ if (m_targetNode != null)
|
|
|
+ {
|
|
|
+ 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)
|
|
|
+ {
|
|
|
+ _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.Tag).id;
|
|
|
+ m_targetNode.Nodes.Add(_node);
|
|
|
+ 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()));
|
|
|
+ Predata = (STDdata)_node.Tag;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ m_targetNode = null;
|
|
|
+ _node = null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ [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;
|
|
|
+ Point pt = treeView_G.PointToClient(Cursor.Position);
|
|
|
+ if ((pt.Y + scrollRegion) > treeView_G.Height)
|
|
|
+ {
|
|
|
+ SendMessage(treeView_G.Handle, (int)277, (int)1, 0);
|
|
|
+ }
|
|
|
+ else if (pt.Y < (treeView_G.Top + scrollRegion))
|
|
|
+ {
|
|
|
+ SendMessage(treeView_G.Handle, (int)277, (int)0, 0);
|
|
|
+ }
|
|
|
+ TreeNode _node2 = treeView_G.GetNodeAt(treeView_G.PointToClient(new Point(e.X, e.Y)));
|
|
|
+ m_targetNode = null;
|
|
|
+
|
|
|
+ if (_node2 != null)
|
|
|
+ {
|
|
|
+ m_targetNode = _node2;
|
|
|
+ e.Effect = DragDropEffects.Move;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ e.Effect = DragDropEffects.None;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ private void treeView_G_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
|
|
|
+ {
|
|
|
+ if(Predata!=null)
|
|
|
+ {
|
|
|
+ m_MainForm.SaveDataOfSelRule(Predata.STDId);
|
|
|
+ }
|
|
|
+ if(e.Node.Level==0)
|
|
|
+ {
|
|
|
+ m_MainForm.SetNull();
|
|
|
+ Predata = null;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ m_MainForm.ChangeSTDEditorAndGrid_Attributes(int.Parse(((STDdata)e.Node.Tag).STDId.ToString()));
|
|
|
+ Predata = (STDdata)e.Node.Tag;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ public void AdjustTreenodeByGroup(int Groupid)
|
|
|
+ {
|
|
|
+ if (m_MainForm.m_STDRuleslist.tabControl1.SelectedIndex == 1)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (treeView_G.SelectedNode.Level == 0)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ STDdata ddata = (STDdata)treeView_G.SelectedNode.Tag;
|
|
|
+ TreeNode nodenew = null;
|
|
|
+ foreach (TreeNode node in treeView_G.Nodes)
|
|
|
+ {
|
|
|
+ if (((STDGroups)node.Tag).id == Groupid)
|
|
|
+ {
|
|
|
+ nodenew = node;break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ foreach (TreeNode node in treeView_G.Nodes)
|
|
|
+ {
|
|
|
+ foreach (TreeNode node1 in node.Nodes)
|
|
|
+ {
|
|
|
+ if (((STDdata)node1.Tag).STDId == ddata.STDId)
|
|
|
+ {
|
|
|
+ GroupViewDic[((STDGroups)node.Tag).id].ContainSTD.Remove(ddata);
|
|
|
+ node1.Remove();
|
|
|
+ ((STDdata)node1.Tag).GroupId = ddata.GroupId;
|
|
|
+ nodenew.Nodes.Add(node1);
|
|
|
+ GroupViewDic[Groupid].ContainSTD.Add(ddata);
|
|
|
+ treeView_G.SelectedNode = node1;
|
|
|
+ nodenew.Expand();
|
|
|
+ m_MainForm.ChangeSTDEditorAndGrid_Attributes(int.Parse(((STDdata)node1.Tag).STDId.ToString()));
|
|
|
+ Predata = ddata;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|