|
@@ -68,8 +68,6 @@ namespace OTSPartA_STDEditor
|
|
|
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.STDDictionary)
|
|
@@ -129,43 +127,26 @@ namespace OTSPartA_STDEditor
|
|
|
/// 保证鼠标点击的GRID行和列是有效的
|
|
|
if (i >= 0 && j >= 0)
|
|
|
{
|
|
|
- if (i == 1)
|
|
|
- {
|
|
|
- button_UpOrder.Enabled = false;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- button_UpOrder.Enabled = true;
|
|
|
- }
|
|
|
- if (i == ls_gd.RowsCount - 1)
|
|
|
- {
|
|
|
- button_DownOrder.Enabled = false;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- button_DownOrder.Enabled = true;
|
|
|
- }
|
|
|
-
|
|
|
- if (PreRow != -1&& PreRow != Grid_Minerals.Selection.ActivePosition.Row)
|
|
|
- {
|
|
|
- //规则名称不为空
|
|
|
- if (Grid_Minerals[i, 0].Value.ToString().Replace(" ", "").Trim() != "")
|
|
|
+ // if (PreRow != -1&& PreRow != Grid_Minerals.Selection.ActivePosition.Row)
|
|
|
+ // {
|
|
|
+ //规则名称不为空
|
|
|
+ if (Grid_Minerals[i, 0].Value.ToString().Replace(" ", "").Trim() != "")
|
|
|
{
|
|
|
- if (m_MainForm.CheckAttributes())
|
|
|
+ if (m_MainForm.CheckAttributes()&& m_MainForm.Checktextbox_STDEditor())
|
|
|
{
|
|
|
- if (m_MainForm.Checktextbox_STDEditor())
|
|
|
- {
|
|
|
+ //if (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();
|
|
|
+ //}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -180,16 +161,22 @@ namespace OTSPartA_STDEditor
|
|
|
Grid_Minerals.Selection.Focus(pos, true);
|
|
|
m_MainForm.m_SubMidWindow.m_ComparativeLibrary.MakeCheckboxUnchecked();
|
|
|
}
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- m_MainForm.ChangeSTDEditorAndGrid_Attributes(int.Parse(Grid_Minerals[i, 0].Tag.ToString()));
|
|
|
- PreRow = i;
|
|
|
- m_MainForm.m_SubMidWindow.m_ComparativeLibrary.MakeCheckboxUnchecked();
|
|
|
- }
|
|
|
+ // }
|
|
|
+ // else
|
|
|
+ // {
|
|
|
+ // m_MainForm.ChangeSTDEditorAndGrid_Attributes(int.Parse(Grid_Minerals[i, 0].Tag.ToString()));
|
|
|
+ // PreRow = i;
|
|
|
+ // m_MainForm.m_SubMidWindow.m_ComparativeLibrary.MakeCheckboxUnchecked();
|
|
|
+ // }
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
+ 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;
|
|
@@ -220,6 +207,7 @@ namespace OTSPartA_STDEditor
|
|
|
AddNewRow(STDId, "NewRuleName", Color.Gray);
|
|
|
m_MainForm.m_SubMidWindow.m_ComparativeLibrary.MakeCheckboxUnchecked();
|
|
|
}
|
|
|
+ //SetOrderButtonsStatus();
|
|
|
}
|
|
|
|
|
|
public void AddNewRow(int STDId, string RuleName, Color color)
|
|
@@ -242,6 +230,7 @@ namespace OTSPartA_STDEditor
|
|
|
Grid_Minerals.Selection.Focus(pos, true);
|
|
|
|
|
|
PreRow = Grid_Minerals.Rows.Count - 1;
|
|
|
+ SetOrderButtonsStatus();
|
|
|
}
|
|
|
|
|
|
void Grid_MineralsDelRow()
|
|
@@ -283,6 +272,7 @@ namespace OTSPartA_STDEditor
|
|
|
{
|
|
|
MessageBox.Show("There is no rule to delete!", "Tip");
|
|
|
}
|
|
|
+ SetOrderButtonsStatus();
|
|
|
}
|
|
|
private void ToolStripMenuItem_Del_Click(object sender, EventArgs e)
|
|
|
{
|
|
@@ -318,50 +308,44 @@ namespace OTSPartA_STDEditor
|
|
|
|
|
|
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)
|
|
|
{
|
|
|
- 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)
|
|
|
- {
|
|
|
- button_UpOrder.Enabled = false;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- button_UpOrder.Enabled = true;
|
|
|
- }
|
|
|
- if (i == ls_gd.RowsCount - 1)
|
|
|
- {
|
|
|
- button_DownOrder.Enabled = false;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- button_DownOrder.Enabled = true;
|
|
|
- }
|
|
|
-
|
|
|
/// 保证鼠标点击的GRID行和列是有效的
|
|
|
if (i >= 2 && j >= 0)
|
|
|
{
|
|
|
//规则名称不为空
|
|
|
if (Grid_Minerals[i, 0].Value.ToString().Replace(" ", "").Trim() != "")
|
|
|
{
|
|
|
- if (m_MainForm.CheckAttributes())
|
|
|
+ if (m_MainForm.CheckAttributes()&& m_MainForm.Checktextbox_STDEditor())
|
|
|
{
|
|
|
- if (m_MainForm.Checktextbox_STDEditor())
|
|
|
- {
|
|
|
+ //if (m_MainForm.Checktextbox_STDEditor())
|
|
|
+ //{
|
|
|
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;
|
|
|
+ //}
|
|
|
+ //else
|
|
|
+ //{
|
|
|
+ // Position pos = new Position(i + 1, 0);
|
|
|
+ // Grid_Minerals.Selection.Focus(pos, true);
|
|
|
+ // m_MainForm.m_SubMidWindow.m_ComparativeLibrary.MakeCheckboxUnchecked();
|
|
|
+ //}
|
|
|
+ if (i == 2)
|
|
|
+ {
|
|
|
+ button_UpOrder.Enabled = false;
|
|
|
}
|
|
|
- else
|
|
|
+ if (i == ls_gd.RowsCount - 1)
|
|
|
{
|
|
|
- Position pos = new Position(i + 1, 0);
|
|
|
- Grid_Minerals.Selection.Focus(pos, true);
|
|
|
- m_MainForm.m_SubMidWindow.m_ComparativeLibrary.MakeCheckboxUnchecked();
|
|
|
+ button_DownOrder.Enabled = true;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
@@ -381,48 +365,57 @@ namespace OTSPartA_STDEditor
|
|
|
}
|
|
|
if (e.KeyCode == Keys.Down)
|
|
|
{
|
|
|
- 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)
|
|
|
- {
|
|
|
- button_UpOrder.Enabled = false;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- button_UpOrder.Enabled = true;
|
|
|
- }
|
|
|
- if (i == ls_gd.RowsCount - 1)
|
|
|
- {
|
|
|
- button_DownOrder.Enabled = false;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- button_DownOrder.Enabled = true;
|
|
|
- }
|
|
|
+ //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)
|
|
|
+ //{
|
|
|
+ // button_UpOrder.Enabled = false;
|
|
|
+ //}
|
|
|
+ //else
|
|
|
+ //{
|
|
|
+ // button_UpOrder.Enabled = true;
|
|
|
+ //}
|
|
|
+ //if (i == ls_gd.RowsCount - 1)
|
|
|
+ //{
|
|
|
+ // button_DownOrder.Enabled = false;
|
|
|
+ //}
|
|
|
+ //else
|
|
|
+ //{
|
|
|
+ // button_DownOrder.Enabled = true;
|
|
|
+ //}
|
|
|
|
|
|
/// 保证鼠标点击的GRID行和列是有效的
|
|
|
if (i < ls_gd.RowsCount - 1 && j >= 0)
|
|
|
{
|
|
|
//规则名称不为空
|
|
|
- //if (Grid_Minerals[i, 0].Value.ToString().Replace(" ", "").Trim() != "")
|
|
|
- //{
|
|
|
- if (m_MainForm.CheckAttributes())
|
|
|
+ if (Grid_Minerals[i, 0].Value.ToString().Replace(" ", "").Trim() != "")
|
|
|
+ {
|
|
|
+ if (m_MainForm.CheckAttributes()&& m_MainForm.Checktextbox_STDEditor())
|
|
|
{
|
|
|
- if (m_MainForm.Checktextbox_STDEditor())
|
|
|
- {
|
|
|
+ //if (m_MainForm.Checktextbox_STDEditor())
|
|
|
+ //{
|
|
|
m_MainForm.SaveDataOfSelRule(i, 0);
|
|
|
m_MainForm.ChangeSTDEditorAndGrid_Attributes(int.Parse(Grid_Minerals[i + 1, 0].Tag.ToString()));
|
|
|
PreRow = i;
|
|
|
m_MainForm.m_SubMidWindow.m_ComparativeLibrary.MakeCheckboxUnchecked();
|
|
|
+
|
|
|
+ //}
|
|
|
+ //else
|
|
|
+ //{
|
|
|
+ // Position pos = new Position(i - 1, 0);
|
|
|
+ // Grid_Minerals.Selection.Focus(pos, true);
|
|
|
+ // m_MainForm.m_SubMidWindow.m_ComparativeLibrary.MakeCheckboxUnchecked();
|
|
|
+ //}
|
|
|
+ if (i == 1)
|
|
|
+ {
|
|
|
+ button_UpOrder.Enabled = true;
|
|
|
}
|
|
|
- else
|
|
|
+ if (i == ls_gd.RowsCount - 2)
|
|
|
{
|
|
|
- Position pos = new Position(i - 1, 0);
|
|
|
- Grid_Minerals.Selection.Focus(pos, true);
|
|
|
- m_MainForm.m_SubMidWindow.m_ComparativeLibrary.MakeCheckboxUnchecked();
|
|
|
+ button_DownOrder.Enabled = false;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
@@ -431,13 +424,13 @@ namespace OTSPartA_STDEditor
|
|
|
Grid_Minerals.Selection.Focus(pos, true);
|
|
|
m_MainForm.m_SubMidWindow.m_ComparativeLibrary.MakeCheckboxUnchecked();
|
|
|
}
|
|
|
- //}
|
|
|
- //else
|
|
|
- //{
|
|
|
- // Position pos = new Position(i - 1, 0);
|
|
|
- // Grid_Minerals.Selection.Focus(pos, true);
|
|
|
- // m_MainForm.m_SubMidWindow.m_ComparativeLibrary.MakeCheckboxUnchecked();
|
|
|
- //}
|
|
|
+ }
|
|
|
+ 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.Delete)
|
|
@@ -588,11 +581,43 @@ namespace OTSPartA_STDEditor
|
|
|
Grid_Minerals.Selection.Focus(pos, true);
|
|
|
|
|
|
PreRow = Grid_Minerals.Selection.ActivePosition.Row - 1;
|
|
|
+ SetOrderButtonsStatus();
|
|
|
}
|
|
|
|
|
|
private void Grid_Minerals_VScrollPositionChanged(object sender, ScrollPositionChangedEventArgs e)
|
|
|
{
|
|
|
//Grid_Minerals.Refresh();
|
|
|
}
|
|
|
+
|
|
|
+ void SetOrderButtonsStatus()
|
|
|
+ {
|
|
|
+ Grid_Minerals.Focus();
|
|
|
+ int i = Grid_Minerals.Selection.ActivePosition.Row;
|
|
|
+ int j = Grid_Minerals.Selection.ActivePosition.Column;
|
|
|
+ if (i != -1)
|
|
|
+ {
|
|
|
+ if (i == 1)
|
|
|
+ {
|
|
|
+ button_UpOrder.Enabled = false;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ button_UpOrder.Enabled = true;
|
|
|
+ }
|
|
|
+ if (i == Grid_Minerals.RowsCount - 1)
|
|
|
+ {
|
|
|
+ button_DownOrder.Enabled = false;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ button_DownOrder.Enabled = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ button_UpOrder.Enabled = false;
|
|
|
+ button_DownOrder.Enabled = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|