Equation Editor interface support

This commit is contained in:
2016-11-17 15:05:15 +00:00
parent 3e212834ea
commit 0b7371367c
26 changed files with 2129 additions and 855 deletions

View File

@@ -647,7 +647,7 @@ namespace Volian.Controls.Library
}
SetButtonAndMenuEnabling(true);
SetStepButtonAndMenuEnabling(true);
SetMenuEnablingForFigures();
SetMenuEnablingForObjectsWOText();
_MyLastFormatID = MyItemInfo.ActiveFormat.FormatID;
}
}
@@ -1187,7 +1187,7 @@ namespace Volian.Controls.Library
public void SetButtonAndMenuEnabling(bool docontextmenus)
{
if (_MyStepRTB == null) return;
if (_MyStepRTB.FieldToEdit != E_FieldToEdit.StepText && !MyItemInfo.IsFigure) // want menu enabling for figures
if (_MyStepRTB.FieldToEdit != E_FieldToEdit.StepText && !MyItemInfo.IsFigure & !MyItemInfo.IsRtfRaw) // want menu enabling for figures & equations
return; // No need to change menu that does not get used
DocVersionInfo dvi = MyEditItem.MyItemInfo.MyProcedure.ActiveParent as DocVersionInfo;
if (dvi == null) return;
@@ -1228,11 +1228,30 @@ namespace Volian.Controls.Library
try // RHM20150506 Multiline ItemID TextBox
{
IDataObject iData = Clipboard.GetDataObject();
DataFormats.Format frm = DataFormats.GetFormat("Embed Source");
System.Windows.Forms.RichTextBox richTextBox1;
richTextBox1 = new System.Windows.Forms.RichTextBox();
richTextBox1.Location = new System.Drawing.Point(35, 32);
richTextBox1.Name = "richTextBox1";
richTextBox1.Size = new System.Drawing.Size(67, 58);
richTextBox1.TabIndex = 0;
richTextBox1.Text = "";
richTextBox1.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.None;
bool noEquationData = true;
try
{
richTextBox1.Paste(frm);
if (richTextBox1.Rtf.ToUpper().Contains("EQUAT")) noEquationData = false;
}
catch (Exception ex)
{
noEquationData = false;
}
//btnEdit3CMPaste.Enabled = btnPasteText.Enabled = btnCMPasteText.Enabled = btnCMPaste.Enabled = btnPaste.Enabled = (iData.GetDataPresent(DataFormats.Text) || iData.GetDataPresent(DataFormats.Rtf));
//btnPasteText.Enabled = btnPasteStepText.Enabled = btnPaste.Enabled = (iData.GetDataPresent(DataFormats.Text) || iData.GetDataPresent(DataFormats.Rtf));
btnPaste.Enabled = (iData.GetDataPresent(DataFormats.Text) || iData.GetDataPresent(DataFormats.Rtf));
btnCMPasteText.Enabled = btnPasteText.Enabled = iData.GetDataPresent(DataFormats.Text);
btnCMPaste.Enabled = btnPasteStepText.Enabled = iData.GetDataPresent(DataFormats.Rtf);
btnPaste.Enabled = noEquationData && (iData.GetDataPresent(DataFormats.Text) || iData.GetDataPresent(DataFormats.Rtf));
btnCMPasteText.Enabled = btnPasteText.Enabled = noEquationData && iData.GetDataPresent(DataFormats.Text);
btnCMPaste.Enabled = btnPasteStepText.Enabled = noEquationData && iData.GetDataPresent(DataFormats.Rtf);
}
catch (Exception) // Error while trying to access the clipboard
{ // This happens when the ItemID Text Box at the bottom of the screen is used to paste
@@ -1243,7 +1262,7 @@ namespace Volian.Controls.Library
}
}
// all selected copy while in either Edit or View mode
btnCMCopy.Enabled = btnCopy.Enabled = _MyStepRTB.SelectionLength > 0;
btnCMCopy.Enabled = btnCopy.Enabled = _MyStepRTB.SelectionLength > 0 && !MyItemInfo.IsRtfRaw;
// paste step only available if a step was copied. Also, check for valid types:
SetPasteButtonEnabled();
@@ -1262,12 +1281,12 @@ namespace Volian.Controls.Library
btnCMEditRO.Enabled = false;
}
// OLD: SetStepButtonAndMenuEnabling(docontextmenus);
SetMenuEnablingForFigures();
SetMenuEnablingForObjectsWOText();
}
private void SetMenuEnablingForFigures()
private void SetMenuEnablingForObjectsWOText()
{
if (MyItemInfo.IsFigure)
if (MyItemInfo.IsFigure || MyItemInfo.IsRtfRaw)
{
btnInsTrans.Enabled = btnCMTransition.Enabled = false;
btnInsRO.Enabled = btnCMRO.Enabled = false;
@@ -1286,6 +1305,11 @@ namespace Volian.Controls.Library
btnPaste.Enabled = false;
btnCMPaste.Enabled = false;
btnCMPasteText.Enabled = false;
if (MyItemInfo.IsRtfRaw)
{
btnCopy.Enabled = false;
btnCMCopy.Enabled = false;
}
}
}
@@ -1343,6 +1367,12 @@ namespace Volian.Controls.Library
SetPasteButtons(false);
return;
}
//if copy item is equation, can only paste if from an equation
if ((tmp.MyDisplayTabControl.MyCopyStep.IsRtfRaw && !MyItemInfo.IsRtfRaw) || (!tmp.MyDisplayTabControl.MyCopyStep.IsRtfRaw && MyItemInfo.IsRtfRaw))
{
SetPasteButtons(false);
return;
}
//copy item is procedure, turn all off and return must be done from tree
if(tmp.MyDisplayTabControl.MyCopyStep.IsProcedure)
{
@@ -1531,7 +1561,7 @@ namespace Volian.Controls.Library
if (MyItemInfo.IsProcedure || MyItemInfo.IsSection)
{
btnInsCaut.Enabled = btnInsNote.Enabled = btnInsRNO.Enabled = btnInsFig.Enabled =
btnInsTable.Enabled = btnInsSubstep.Enabled = btnInsBefore.Enabled = btnInsAfter.Enabled = false;
btnInsTable.Enabled = btnInsSubstep.Enabled = btnInsBefore.Enabled = btnInsAfter.Enabled = btnInsEquation.Enabled = false;
// if on a section, allow note/caution. May want to add condition that this is a subsection?
if (MyItemInfo.IsSection && MyItemInfo.IsStepSection && MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.AllowNoteCautionAdd)
{
@@ -1589,16 +1619,18 @@ namespace Volian.Controls.Library
btnInsSubstep.Enabled = (actable & E_AccStep.AddingSub) > 0;
btnInsBefore.Enabled = btnInsBefH.Enabled = !MyItemInfo.IsRNOPart && (actable & E_AccStep.AddingPrev) > 0;
btnInsAfter.Enabled = btnInsAftH.Enabled = !MyItemInfo.IsRNOPart && (actable & E_AccStep.AddingNext) > 0;
btnInsEquation.Enabled = (actable & E_AccStep.AddingTable) > 0 && MyItemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList.Equation != null;
// if this step has a table or figure, disable both of those buttons.
// if this step has a table, figure or equation, disable both of those buttons.
if (MyItemInfo.Tables != null && MyItemInfo.Tables.Count > 0)
btnInsTable.Enabled = btnInsFig.Enabled = btnCMInsFigure.Enabled = btnCMInsTable.Enabled = false;
btnInsTable.Enabled = btnInsFig.Enabled = btnInsEquation.Enabled = btnCMInsFigure.Enabled = btnCMInsTable.Enabled = btnCMInsEquation.Enabled = false;
btnInsHLS.SubItems.Clear();
btnInsCaut.SubItems.Clear();
btnInsNote.SubItems.Clear();
btnInsRNO.SubItems.Clear();
btnInsFig.SubItems.Clear();
btnInsEquation.SubItems.Clear();
btnInsTable.SubItems.Clear();
btnInsSubstep.SubItems.Clear();
@@ -1608,9 +1640,12 @@ namespace Volian.Controls.Library
btnCMInsCaution.SubItems.Clear();
btnCMInsNote.SubItems.Clear();
btnCMInsFigure.SubItems.Clear();
btnCMInsEquation.SubItems.Clear();
btnCMInsTable.SubItems.Clear();
btnCMInsSubStps.SubItems.Clear();
btnCMInsRNO.SubItems.Clear();
btnCMInsEquation.Enabled = btnInsEquation.Enabled;
btnCMInsFigure.Enabled = btnInsFig.Enabled;
}
btnInsRNO.Enabled = btnCMInsRNO.Enabled = btnInsRNO.Enabled && (MyItemInfo.RNOs == null || MyItemInfo.RNOs.Count == 0); // don't insert an RNO if has an RNO
@@ -1628,8 +1663,8 @@ namespace Volian.Controls.Library
if (btnInsTable.Enabled) GalleryForSubTypes(MyItemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList.Table, sd, btnInsTable, (int)E_FromType.Table, btnCMInsTable, docontextmenus);
if (btnInsSubstep.Enabled) GalleryForSubTypes(MyItemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList.Substep, sd, btnInsSubstep, (int)E_FromType.Step, btnCMInsSubStps, docontextmenus);
if (btnInsRNO.Enabled) GalleryForSubTypes(MyItemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList.RNO, sd, btnInsRNO, 0, btnCMInsRNO, docontextmenus);
btnInsTrans.Enabled = btnCMTransition.Enabled = !MyItemInfo.IsFigure;
if (btnInsEquation.Enabled) GalleryForSubTypes(MyItemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList.Equation, sd, btnInsEquation, (int)E_FromType.Table, btnCMInsEquation, docontextmenus);
btnInsTrans.Enabled = btnCMTransition.Enabled = !MyItemInfo.IsFigure && !MyItemInfo.IsRtfRaw;
btnInsRO.Enabled = btnCMRO.Enabled = Mydvi.DocVersionAssociationCount > 0; // 2016-128 don't enable if RO Path was not selected at the Working Draft node
// if in Calvert Alarms Condition/Response, disable insert of Cautions and Notes
@@ -1653,7 +1688,7 @@ namespace Volian.Controls.Library
// The first argument (boolean) in StepGetLevelTypes provides the option to get a complete list of step types
// regardless of whether in the AER or RNO column (set to true). For all types, get both except for figures
// and tables.
bool getall = !(btn.Name == "btnInsFig" || (btn.Name == "btnInsTable"));
bool getall = !(btn.Name == "btnInsFig" || btn.Name == "btnInsTable" || btn.Name == "btnInsEquation");
List<StepDataRetval> sdl = MyItemInfo.ActiveFormat.PlantFormat.FormatData.StepGetLevelTypes(getall, sdc, ref cursel, selType==null?"Section":selType.Type, MyItemInfo);
if (sdl != null && sdl.Count > 0)
{
@@ -2469,7 +2504,7 @@ namespace Volian.Controls.Library
MyEditItem.ToggleEditView(MyEditItem.MyStepPanel.VwMode);
SetButtonAndMenuEnabling(true);
SetStepButtonAndMenuEnabling(true);
SetMenuEnablingForFigures();
SetMenuEnablingForObjectsWOText();
MyEditItem.MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OnModeChange(this, new StepRTBModeChangeEventArgs(MyEditItem.MyStepPanel.VwMode));
btnEditMode.Checked = btnCMEditMode1.Checked = MyEditItem.MyStepPanel.VwMode == E_ViewMode.View;
MyEditItem.MyStepRTB.SpellCheckContextMenuOn(MyEditItem.MyStepPanel.VwMode != E_ViewMode.View);
@@ -2797,6 +2832,10 @@ namespace Volian.Controls.Library
//btnInsCaut.Enabled = (actable & E_AccStep.AddingCaution) > 0;
switch (menuName)
{
case "OpenRtfRawContextMenu":
ClearContextMenu();
MessageBox.Show("No context menu for equations.");
break;
case "PSI":
displayMenu = true;
_ContextMenuBar.SetContextMenuEx(_MyStepRTB, btnCMPSI);
@@ -2851,6 +2890,10 @@ namespace Volian.Controls.Library
displayMenu = ((actable & E_AccStep.AddingTable) > 0) && btnCMInsFigure.Enabled;
_ContextMenuBar.SetContextMenuEx(_MyStepRTB, btnCMInsFigure);
break;
case "InsEquation":
displayMenu = ((actable & E_AccStep.AddingTable) > 0) && btnCMInsEquation.Enabled;
_ContextMenuBar.SetContextMenuEx(_MyStepRTB, btnCMInsEquation);
break;
case "StepPaste":
displayMenu = true;
if (MyFlexGrid != null)
@@ -3662,7 +3705,6 @@ namespace Volian.Controls.Library
(this.Parent as StepTabPanel).MyDisplayTabControl.ItemsChangeIds.Remove(_MyEditItem.MyStepRTB.MyItemInfo.MyProcedure.ItemID);
(this.Parent as StepTabPanel).MyDisplayTabControl.ItemsChangeIds.Add(_MyEditItem.MyStepRTB.MyItemInfo.MyProcedure.ItemID, txtBxChgId.Text);
}
private frmImportWordContents fiwc = null;
// open the Import Word Text dialog
private void rbnImpWrd_ItemClick(object sender, EventArgs e)