Inserting new step/substeps is disabled when the edit window is empty

This commit is contained in:
2012-04-12 18:55:20 +00:00
parent b9bed798d9
commit 7bfc9b223f
3 changed files with 399 additions and 383 deletions

View File

@@ -140,6 +140,7 @@ namespace Volian.Controls.Library
if (_MyEditItem != null) _MyEditItem.Leave += new EventHandler(_MyEditItem_Leave);
//_MyStepRTB.Leave += new EventHandler(_MyStepRTB_Leave);
_MyStepRTB.LinkChanged += new StepRTBLinkEvent(_MyStepRTB_LinkChanged);
_MyStepRTB.TextChanged += new EventHandler(_MyStepRTB_TextChanged);
if (MyFlexGrid != null)
{
MyFlexGrid.CopyOptionChanged += new VlnFlexGridEvent(MyFlexGrid_CopyOptionChanged);
@@ -173,6 +174,23 @@ namespace Volian.Controls.Library
}
}
}
void _MyStepRTB_TextChanged(object sender, EventArgs e)
{
// if we are in view mode or the edit window is empty, then don't allow inserting steps/substeps,
// page breaks, copy step, nor creating a pdf
bool allow = (MyEditItem.MyStepPanel.VwMode != E_ViewMode.View && _MyStepRTB.TextLength > 0);
// turn ribbon items on/off base on whether there is text in the edit window
rbnSiblings.Enabled = rbnBreaks.Enabled = rbnStepParts.Enabled = allow;
btnInsAftH.Enabled = btnInsBefH.Enabled = btnInsAfter.Enabled = btnInsBefore.Enabled = allow;
btnCpyStp.Enabled = rbPdf.Enabled = allow;
// toggle context menus used with the shortcut key
btnCMInsHLS.Enabled = btnCMInsRNO.Enabled = btnCMInsSubStps.Enabled = btnCMInsCaution.Enabled =
btnCMInsNote.Enabled = btnCMInsTable.Enabled = btnCMInsFigure.Enabled = allow;
}
void MyFlexGrid_SelChange(object sender, EventArgs e)
{
if (MyFlexGrid == null)
@@ -622,9 +640,7 @@ namespace Volian.Controls.Library
{
if (rtabTableGridTools.Checked)
rtabHome.Select();
Console.WriteLine("rtabTableGridTools.Visible1 = {0}", rtabTableGridTools.Visible);
rtabTableGridTools.Visible = false;
Console.WriteLine("rtabTableGridTools.Visible2 = {0}", rtabTableGridTools.Visible);
SetButtonMenuEnabledDisabledOnStepType(false);
this.Refresh();
return;
@@ -1519,7 +1535,7 @@ namespace Volian.Controls.Library
_ContextMenuBar.SetContextMenuEx(_MyStepRTB, btnCMPSI);
break;
case "InsHLS":
displayMenu = true;
displayMenu = btnCMInsHLS.Enabled;
Cursor.Position = new Point(0, 0); // Enter Key hit, move mouse pointer out of way of context menu
_ContextMenuBar.SetContextMenuEx(_MyStepRTB, btnCMInsHLS);
foreach (DevComponents.DotNetBar.ButtonItem bi in btnCMInsHLS.SubItems)
@@ -1530,11 +1546,11 @@ namespace Volian.Controls.Library
}
break;
case "InsRNO":
displayMenu = (actable & E_AccStep.AddingRNO) > 0;
displayMenu = ((actable & E_AccStep.AddingRNO) > 0) && btnCMInsRNO.Enabled;
_ContextMenuBar.SetContextMenuEx(_MyStepRTB, btnCMInsRNO);
break;
case "InsSubStps":
displayMenu = (actable & E_AccStep.AddingSub) > 0;
displayMenu = ((actable & E_AccStep.AddingSub) > 0) && btnCMInsSubStps.Enabled;
_ContextMenuBar.SetContextMenuEx(_MyStepRTB, btnCMInsSubStps);
if (displayMenu) Cursor.Position = new Point(0, 0); // Enter Key hit, move mouse pointer out of way of context menu
foreach (DevComponents.DotNetBar.ButtonItem bi in btnCMInsSubStps.SubItems)
@@ -1545,19 +1561,19 @@ namespace Volian.Controls.Library
}
break;
case "InsCaution":
displayMenu = (actable & E_AccStep.AddingCaution) > 0;
displayMenu = ((actable & E_AccStep.AddingCaution) > 0) && btnCMInsCaution.Enabled;
_ContextMenuBar.SetContextMenuEx(_MyStepRTB, btnCMInsCaution);
break;
case "InsNote":
displayMenu = (actable & E_AccStep.AddingNote) > 0;
displayMenu = ((actable & E_AccStep.AddingNote) > 0) && btnCMInsNote.Enabled;
_ContextMenuBar.SetContextMenuEx(_MyStepRTB, btnCMInsNote);
break;
case "InsTable":
displayMenu = (actable & E_AccStep.AddingTable) > 0;
displayMenu = ((actable & E_AccStep.AddingTable) > 0) && btnCMInsTable.Enabled;
_ContextMenuBar.SetContextMenuEx(_MyStepRTB, btnCMInsTable);
break;
case "InsFigure":
displayMenu = (actable & E_AccStep.AddingTable) > 0;
displayMenu = ((actable & E_AccStep.AddingTable) > 0) && btnCMInsFigure.Enabled;
_ContextMenuBar.SetContextMenuEx(_MyStepRTB, btnCMInsFigure);
break;
case "StepPaste":