
Correct dispose logic for transition destination ITEMs Correct cursor position after Transition Insert Correct logic to parse Transition Link Token Correct Save Config to dispose of ITEM Removed debug vlnStackTrace
1237 lines
48 KiB
C#
1237 lines
48 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Drawing;
|
|
using System.Data;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
using System.IO;
|
|
using System.Text.RegularExpressions;
|
|
using VEPROMS.CSLA.Library;
|
|
|
|
namespace Volian.Controls.Library
|
|
{
|
|
public partial class StepTabRibbon : UserControl
|
|
{
|
|
#region Properties
|
|
private StepItem _MyStepItem;
|
|
public StepItem MyStepItem
|
|
{
|
|
get { return _MyStepItem; }
|
|
set
|
|
{
|
|
_MyStepItem = value;
|
|
if (value != null)
|
|
{
|
|
MyStepRTB = value.MyStepRTB;
|
|
}
|
|
}
|
|
}
|
|
private DocVersionInfo _MyDVI;
|
|
public DocVersionInfo MyDVI
|
|
{
|
|
get
|
|
{
|
|
if (_MyDVI != null) return _MyDVI;
|
|
if (_MyStepItem != null)
|
|
{
|
|
ItemInfo procInfo = _MyStepItem.MyItemInfo.MyProcedure as ItemInfo;
|
|
if (procInfo == null) return null;
|
|
_MyDVI = procInfo.ActiveParent as DocVersionInfo;
|
|
return _MyDVI;
|
|
}
|
|
return null;
|
|
}
|
|
}
|
|
private ItemInfo MyItemInfo
|
|
{ get { return _MyStepRTB.MyItemInfo; } }
|
|
|
|
private DevComponents.DotNetBar.ButtonItem _DefaultContextMenu;
|
|
|
|
public void ClearContextMenu()
|
|
{
|
|
_ContextMenuBar.SetContextMenuEx(_MyStepRTB, null);
|
|
}
|
|
public void SetContextMenu()
|
|
{
|
|
_ContextMenuBar.SetContextMenuEx(_MyStepRTB, btnCMRtfEdit);
|
|
}
|
|
public void OpenContextMenu(Point loc)
|
|
{
|
|
btnCMRtfEdit.Popup(loc);
|
|
}
|
|
private int _MyLastFormatID = -1;
|
|
private StepRTB _MyStepRTB;
|
|
public StepRTB MyStepRTB
|
|
{
|
|
get { return _MyStepRTB; }
|
|
set
|
|
{
|
|
_MyStepRTB = value;
|
|
if (value != null)
|
|
{
|
|
//Console.WriteLine(string.Format("StepTabRibbon: In set of MyStepRTB, Selected Text = {0}", MyStepRTB.SelectedText));
|
|
switch (_MyStepRTB.FieldToEdit)
|
|
{
|
|
case E_FieldToEdit.StepText:
|
|
_ContextMenuBar.SetContextMenuEx(_MyStepRTB, btnCMRtfEdit);
|
|
_DefaultContextMenu = btnCMRtfEdit;
|
|
break;
|
|
case E_FieldToEdit.Text:
|
|
case E_FieldToEdit.Number:
|
|
_ContextMenuBar.SetContextMenuEx(_MyStepRTB, btnCMRtfEdit3);
|
|
_DefaultContextMenu = btnCMRtfEdit3;
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
// The following two lines were replaced by the third line so that the Ribbon KeyTips will work properly.
|
|
// ex. Positon on a substep, press <shift><F6> <N> <S> <S>, to list the substep types
|
|
//_MyStepRTB.MouseUp += new MouseEventHandler(_MyStepRTB_MouseUp); //+= new MouseEventHandler(MyStepRTB_SelectionChanged);
|
|
//_MyStepRTB.KeyUp += new KeyEventHandler(_MyStepRTB_KeyUp); //+= new KeyEventHandler(MyStepRTB_SelectionChanged);
|
|
_MyStepRTB.SelectionChanged += new EventHandler(_MyStepRTB_SelectionChanged);
|
|
_MyStepRTB.ModeChange += new StepRTBModeChangeEvent(_MyStepRTB_ModeChange);
|
|
_MyStepRTB.Leave += new EventHandler(MyStepRTB_Leave);
|
|
_MyStepRTB.LinkChanged += new StepRTBLinkEvent(_MyStepRTB_LinkChanged);
|
|
// Add symbols into the tab ribbon based on format selection. For now, only add symbols once
|
|
// because all symbols are same!!! If we start defining different symbols in different formats
|
|
// this will have to change, i.e. remove the second part of 'if' statement.
|
|
if (MyItemInfo.ActiveFormat.FormatID != _MyLastFormatID && _MyLastFormatID == -1)
|
|
{
|
|
// Add symbols to the tabribbon & also to the context menu getting info from the format file...
|
|
// Note that the ButtonItems must be used in order to place the buttons on a gallery (cannot
|
|
// use buttonx or dotnet/windows/button). However, you cannot change the font on ButtonItems so
|
|
// the ribbon MUST use the Arial Unicode MS Font for this to work!!!!
|
|
FormatInfo fmt = MyItemInfo.ActiveFormat;
|
|
SymbolList sl = fmt.PlantFormat.FormatData.SymbolList;
|
|
if (sl == null || sl.Count <= 0)
|
|
{
|
|
MessageBox.Show("No symbols are available, check with administrator");
|
|
return;
|
|
}
|
|
BuildSymbolGallery(sl, galleryContainerSymbolsCM);
|
|
BuildSymbolGallery(sl, galleryContainerSymbolsCM3);
|
|
}
|
|
SetButtonAndMenuEnabling(true);
|
|
SetStepButtonAndMenuEnabling(true);
|
|
|
|
_MyLastFormatID = MyItemInfo.ActiveFormat.FormatID;
|
|
}
|
|
}
|
|
}
|
|
|
|
void _MyStepRTB_SelectionChanged(object sender, EventArgs e)
|
|
{
|
|
SetButtonAndMenuEnabling(false);
|
|
}
|
|
//void _MyStepRTB_MouseUp(object sender, MouseEventArgs e)
|
|
//{
|
|
// //SetButtonAndMenuEnabling(false);
|
|
//}
|
|
|
|
//void _MyStepRTB_KeyUp(object sender, KeyEventArgs e)
|
|
//{
|
|
// //SetButtonAndMenuEnabling(false);
|
|
//}
|
|
|
|
private void BuildSymbolGallery(SymbolList sl, DevComponents.DotNetBar.GalleryContainer gc)
|
|
{
|
|
foreach (Symbol sym in sl)
|
|
{
|
|
DevComponents.DotNetBar.ButtonItem btn = new DevComponents.DotNetBar.ButtonItem();
|
|
btn.Text = string.Format("{0}", (char)sym.Unicode);
|
|
// to name button use unicode rather than desc, desc may have spaces or odd chars
|
|
btn.Name = "btn" + sym.Unicode.ToString();
|
|
btn.Tooltip = sym.Desc;
|
|
btn.Tag = string.Format(@"{0}", sym.Unicode);
|
|
btn.FontBold = true;
|
|
btn.Click += new System.EventHandler(btnSym_Click);
|
|
galleryContainerSymbols.SubItems.Add(btn);
|
|
DevComponents.DotNetBar.ButtonItem btnCM = new DevComponents.DotNetBar.ButtonItem();
|
|
btnCM.Text = string.Format("{0}", (char)sym.Unicode);
|
|
// to name button use unicode rather than desc, desc may have spaces or odd chars
|
|
btnCM.Name = "btnCM" + sym.Unicode.ToString();
|
|
btnCM.Tooltip = sym.Desc;
|
|
btnCM.Tag = string.Format(@"{0}", sym.Unicode);
|
|
btnCM.FontBold = true;
|
|
btnCM.Click += new System.EventHandler(btnSym_Click);
|
|
gc.SubItems.Add(btnCM);
|
|
}
|
|
}
|
|
|
|
void _MyStepRTB_ModeChange(object sender, StepRTBModeChangeEventArgs args)
|
|
{
|
|
SetButtonAndMenuEnabling(true);
|
|
}
|
|
#endregion
|
|
#region Constructor
|
|
public StepTabRibbon()
|
|
{
|
|
InitializeComponent();
|
|
_RibbonControl.SizeChanged += new EventHandler(_RibbonControl_SizeChanged);
|
|
// When AutoExpand is set to true, [CTRL][F1] will hide/expand the ribbon bar
|
|
// causing its state to be out of sync with that of the QAT menu option to
|
|
// expand/hide the ribbon.
|
|
// Note: the QAT menu is to the right of the V start button in the upper left
|
|
_RibbonControl.AutoExpand = false;
|
|
_RibbonControl.Items[0].RaiseClick(); // initially default to HOME tab
|
|
}
|
|
|
|
void _RibbonControl_SizeChanged(object sender, EventArgs e)
|
|
{
|
|
this.Size = _RibbonControl.Size;
|
|
}
|
|
public bool Expanded
|
|
{
|
|
get { return _RibbonControl.Expanded; }
|
|
set{ _RibbonControl.Expanded = value; }
|
|
}
|
|
#endregion
|
|
#region Events
|
|
void _MyStepRTB_LinkChanged(object sender, StepPanelLinkEventArgs args)
|
|
{
|
|
// do all Transition and ReferencedObject menu items/buttons based on whether a 'link is selected' and the link type.
|
|
btnCMGoTo.Enabled = btnGoTo.Enabled = _MyStepRTB.IsSelectionLinked(_MyStepRTB.SelectionStart, _MyStepRTB.SelectionLength);
|
|
if (btnCMGoTo.Enabled == true && _MyStepRTB.MyLinkText != null) // must have some link test, use it to set edit of transition or ro...
|
|
{
|
|
btnCMEditTran.Enabled = _MyStepRTB.MyLinkText.IndexOf("Transition") > -1; // selected link must be a transition
|
|
btnCMEditRO.Enabled = _MyStepRTB.MyLinkText.IndexOf("ReferencedObject") > -1; // selected link must be ro
|
|
}
|
|
else
|
|
{
|
|
btnCMEditTran.Enabled = false;
|
|
btnCMEditRO.Enabled = false;
|
|
}
|
|
}
|
|
void MyStepRTB_Leave(object sender, EventArgs e)
|
|
{
|
|
// The following two lines were replaced by the third line so that the Ribbon KeyTips will work properly.
|
|
// ex. Positon on a substep, press <shift><F6> <N> <S> <S>, to list the substep types
|
|
//_MyStepRTB.KeyUp -=new KeyEventHandler(_MyStepRTB_KeyUp);
|
|
//_MyStepRTB.MouseUp -= new MouseEventHandler(_MyStepRTB_MouseUp);
|
|
_MyStepRTB.SelectionChanged -=new EventHandler(_MyStepRTB_SelectionChanged);
|
|
_MyStepRTB.Leave -= new EventHandler(MyStepRTB_Leave);
|
|
_MyStepRTB.LinkChanged -= new StepRTBLinkEvent(_MyStepRTB_LinkChanged);
|
|
}
|
|
void btnInsStep_Click(object sender, EventArgs e)
|
|
{
|
|
DevComponents.DotNetBar.ButtonItem b = (DevComponents.DotNetBar.ButtonItem)sender;
|
|
if (b.Tag == null) return;
|
|
char [] sep = {' '};
|
|
string[] insdata = b.Tag.ToString().Split(sep);
|
|
if (insdata.Length != 2) return;
|
|
int fromtype = Convert.ToInt32(insdata[0]);
|
|
int contenttype = Convert.ToInt32(insdata[1]) + 20000;
|
|
|
|
// if from type == 0, we've inserted a hls.
|
|
// if inserting from section, insert first child
|
|
// else do a after from current HLS - if not at HLS, go up parents until find it.
|
|
if (fromtype == 0 && !_MyStepItem.MyItemInfo.IsStepSection)
|
|
{
|
|
StepItem hlsStepItem = _MyStepItem;
|
|
while (!hlsStepItem.MyItemInfo.IsHigh)
|
|
hlsStepItem = hlsStepItem.ActiveParent;
|
|
hlsStepItem.AddSiblingAfter((int ?)contenttype);
|
|
}
|
|
else
|
|
{
|
|
// Maybe someday for Grid Tables
|
|
//bool addchild = true;
|
|
//if (InsertingTable(contenttype))
|
|
//{
|
|
// VlnFlexGrid grd = CreateNewTable();
|
|
// // if (grd == null) // if null grd, then user changed mind, abort insert of table
|
|
// addchild = false;
|
|
//}
|
|
//if (addchild)
|
|
_MyStepItem.AddChild((E_FromType)fromtype, contenttype);
|
|
}
|
|
}
|
|
// Future Table Grid?
|
|
//private bool InsertingTable(int contenttype)
|
|
//{
|
|
// bool rtnval = false;
|
|
// switch (contenttype)
|
|
// {
|
|
// case 20008: // Centered table
|
|
// case 20010: // AER table
|
|
// case 20033: // AER table without boarder
|
|
// case 20034: // Centered table without boarder
|
|
// rtnval = true;
|
|
// break;
|
|
// }
|
|
// return rtnval;
|
|
//}
|
|
private void btnInsBefore_Click(object sender, EventArgs e)
|
|
{
|
|
_MyStepItem.AddSiblingBefore();
|
|
}
|
|
|
|
private void btnInsAfter_Click(object sender, EventArgs e)
|
|
{
|
|
_MyStepItem.AddSiblingAfter();
|
|
}
|
|
/// <summary>
|
|
/// Using style for step type, enable/disable formatting buttons
|
|
/// </summary>
|
|
private void SetButtonForStyle()
|
|
{
|
|
btnBold.Enabled = btnCMBold.Enabled = (!((_MyStepRTB.MyStyleFont.Style & E_Style.Bold) == E_Style.Bold || (_MyStepRTB.MyStyleFont.Style & E_Style.MmBold) == E_Style.MmBold));
|
|
btnUnderline.Enabled = btnCMUnderline.Enabled = (!((_MyStepRTB.MyStyleFont.Style & E_Style.Underline) == E_Style.Underline));
|
|
btnItalics.Enabled = btnCMItalics.Enabled = (!((_MyStepRTB.MyStyleFont.Style & E_Style.Italics) == E_Style.Italics));
|
|
}
|
|
private void SetButtonMenuEnabledDisabledOnSelection(bool setting)
|
|
{
|
|
btnCMBold.Enabled = btnBold.Enabled = setting;
|
|
btnCMItalics.Enabled = btnItalics.Enabled = setting;
|
|
btnCMUnderline.Enabled = btnUnderline.Enabled = setting;
|
|
btnCMSubscript.Enabled = btnSubscript.Enabled = setting;
|
|
btnCMSuperscript.Enabled = btnSuperscript.Enabled = setting;
|
|
btnCMCut.Enabled = btnCut.Enabled = setting;
|
|
btnCMUndo.Enabled = btnUndo.Enabled = setting;
|
|
btnCMRedo.Enabled = btnRedo.Enabled = setting;
|
|
btnCMPaste.Enabled = btnPaste.Enabled = setting;
|
|
btnCMCopy.Enabled = btnCopy.Enabled = setting;
|
|
btnPasteAfter.Enabled = btnPasteBefore.Enabled = btnStepPaste.Enabled = btnPasteReplace.Enabled = setting;
|
|
}
|
|
private void SetButtonMenuEnabledDisabledOnStepType(bool setting)
|
|
{
|
|
btnPageBreak.Enabled = btnInsPgBrk.Enabled = setting;
|
|
btnCMChgStep.Enabled = btnChgTyp.Enabled = setting;
|
|
btnInsHLS.Enabled = btnInsCaut.Enabled = btnInsNote.Enabled = btnInsRNO.Enabled = btnInsFig.Enabled =
|
|
btnInsTable.Enabled = btnInsSubstep.Enabled = btnInsBefore.Enabled = btnInsAfter.Enabled = setting;
|
|
btnInsTrans.Enabled = btnCMTransition.Enabled = btnInsRO.Enabled = btnCMRO.Enabled = setting;
|
|
btnInsAftH.Enabled = btnInsBefH.Enabled = setting;
|
|
btnCMChgCase.Enabled = btnChgCase.Enabled = setting;
|
|
btnCMHardSpace.Enabled = btnInsHrdSpc.Enabled = setting;
|
|
btnCMSymbol.Enabled = btnSymbols.Enabled = setting;
|
|
btnIndent.Enabled = setting;
|
|
btnDelelete.Enabled = btnDelStep.Enabled = setting;
|
|
btnSpell.Enabled = setting;
|
|
}
|
|
private void SetButtonAndMenuEnabling(bool docontextmenus)
|
|
{
|
|
if (_MyStepRTB.FieldToEdit != E_FieldToEdit.StepText)
|
|
return; // No need to change menu that does not get used
|
|
if (_MyStepRTB == null) return;
|
|
DocVersionInfo dvi = MyStepItem.MyItemInfo.MyProcedure.ActiveParent as DocVersionInfo;
|
|
if (dvi == null) return;
|
|
if (dvi.VersionType > 127 || MyStepItem.MyStepPanel.PanelViewEditMode == E_ViewMode.View)
|
|
{
|
|
SetButtonMenuEnabledDisabledOnSelection(false);
|
|
}
|
|
else
|
|
{
|
|
SetButtonMenuEnabledDisabledOnSelection(true);
|
|
|
|
if (_MyStepRTB.SelectionFont != null)
|
|
{
|
|
btnCMBold.Checked = btnBold.Checked = RTBAPI.IsBold(_MyStepRTB);
|
|
btnCMItalics.Checked = btnItalics.Checked = RTBAPI.IsItalic(_MyStepRTB);
|
|
btnCMUnderline.Checked = btnUnderline.Checked = RTBAPI.IsUnderline(_MyStepRTB);
|
|
btnCMSubscript.Checked = btnSubscript.Checked = RTBAPI.IsSubScript(_MyStepRTB);
|
|
btnCMSuperscript.Checked = btnSuperscript.Checked = RTBAPI.IsSuperScript(_MyStepRTB);
|
|
}
|
|
SetButtonForStyle();
|
|
|
|
btnCMCut.Enabled = btnCut.Enabled = _MyStepRTB.SelectionLength > 0;
|
|
btnCMUndo.Enabled = btnUndo.Enabled = _MyStepRTB.CanUndo;
|
|
btnCMRedo.Enabled = btnRedo.Enabled = _MyStepRTB.CanRedo;
|
|
|
|
// for paste, see if there is clipboard data, & if so, of a type we can use.
|
|
IDataObject iData = Clipboard.GetDataObject();
|
|
btnCMPaste.Enabled = btnPaste.Enabled = (iData.GetDataPresent(DataFormats.Text) || iData.GetDataPresent(DataFormats.Rtf));
|
|
}
|
|
// all selected copy while in either Edit or View mode
|
|
btnCMCopy.Enabled = btnCopy.Enabled = _MyStepRTB.SelectionLength > 0;
|
|
|
|
// paste step only available if a step was copied. Also, check for valid types:
|
|
SetPasteButtonEnabled();
|
|
|
|
// do all Transition and ReferencedObject menu items/buttons based on whether a 'link is selected' and the link type.
|
|
btnCMGoTo.Enabled = btnGoTo.Enabled = _MyStepRTB.IsSelectionLinked(_MyStepRTB.SelectionStart, _MyStepRTB.SelectionLength); //(_MyStepRTB.MyLinkText != null);
|
|
if (btnCMGoTo.Enabled == true && _MyStepRTB.MyLinkText != null) // must have some link test, use it to set edit of transition or ro...
|
|
{
|
|
btnCMEditTran.Enabled = _MyStepRTB.MyLinkText.IndexOf("Transition")>-1; // selected link must be a transition
|
|
btnCMEditRO.Enabled = _MyStepRTB.MyLinkText.IndexOf("ReferencedObject") > -1; // selected link must be ro
|
|
}
|
|
else
|
|
{
|
|
btnCMEditTran.Enabled = false;
|
|
btnCMEditRO.Enabled = false;
|
|
}
|
|
// OLD: SetStepButtonAndMenuEnabling(docontextmenus);
|
|
}
|
|
|
|
private void SetPasteButtonEnabled()
|
|
{
|
|
// if there is no 'copied' step, or if a procedure is copied, just turn all buttons off, this can only
|
|
// be done from the tree.
|
|
StepTabPanel tmp = Parent as StepTabPanel;
|
|
if (tmp.MyDisplayTabControl.MyCopyStep == null || tmp.MyDisplayTabControl.MyCopyStep.IsProcedurePart)
|
|
{
|
|
btnPasteReplace.Enabled = btnPasteBefore.Enabled = btnPasteAfter.Enabled = btnStepPaste.Enabled = false;
|
|
return;
|
|
}
|
|
// If a section is copied, it can be pasted as a section (before/after/replace). If can also
|
|
// be pasted as a subsection if the format allows it.
|
|
if (tmp.MyDisplayTabControl.MyCopyStep.IsSectionPart)
|
|
{
|
|
btnPasteBefore.Enabled = btnPasteAfter.Enabled = btnPasteReplace.Enabled = MyItemInfo.IsSectionPart;
|
|
// when doing 'substep' part of paste, need to check if format allows subsection.
|
|
}
|
|
else if (tmp.MyDisplayTabControl.MyCopyStep.IsCautionPart || tmp.MyDisplayTabControl.MyCopyStep.IsNotePart)
|
|
// Part type of copied step must be same as Part type of destination, with exceptions of caution/note and step/rno
|
|
// can be pasted into each other.
|
|
// Part types are procedure - 1, section = 2, step = 6, caution = 3, note = 4, RNO (IsRNO), = 5 table/figure = 7.
|
|
btnPasteBefore.Enabled = btnPasteAfter.Enabled = btnPasteReplace.Enabled = (MyItemInfo.IsCautionPart || MyItemInfo.IsNotePart);
|
|
else if (tmp.MyDisplayTabControl.MyCopyStep.IsRNOPart || tmp.MyDisplayTabControl.MyCopyStep.IsStepPart)
|
|
btnPasteBefore.Enabled = btnPasteAfter.Enabled = btnPasteReplace.Enabled = (MyItemInfo.IsRNOPart || MyItemInfo.IsStepPart);
|
|
else
|
|
btnPasteBefore.Enabled = btnPasteAfter.Enabled = btnPasteReplace.Enabled = tmp.MyDisplayTabControl.MyCopyStep.IsTablePart == MyItemInfo.IsTablePart;
|
|
|
|
// Can't replace step with same step
|
|
if (tmp.MyDisplayTabControl.MyCopyStep.ItemID == MyItemInfo.ItemID) btnPasteReplace.Enabled = false;
|
|
}
|
|
private void SetStepButtonAndMenuEnabling(bool docontextmenus)
|
|
{
|
|
if (MyStepItem == null) return;
|
|
DocVersionInfo dvi = MyStepItem.MyItemInfo.MyProcedure.ActiveParent as DocVersionInfo;
|
|
if (dvi == null) return;
|
|
if (dvi.VersionType > 127)
|
|
btnCMEditMode1.Enabled = btnEditMode.Enabled = false; // in approved
|
|
if (dvi.VersionType > 127 || MyStepItem.MyStepPanel.PanelViewEditMode == E_ViewMode.View)
|
|
{
|
|
SetButtonMenuEnabledDisabledOnStepType(false);
|
|
return;
|
|
}
|
|
btnInsPgBrk.Checked = false;
|
|
// see if manual page break - only available on HLS
|
|
if (MyItemInfo.IsHigh)
|
|
{
|
|
StepConfig cfg = MyItemInfo.MyConfig as StepConfig;
|
|
btnInsPgBrk.Checked = cfg == null ? false : cfg.Step_ManualPagebreak;
|
|
}
|
|
btnInsPgBrk.Enabled = MyItemInfo.IsHigh;
|
|
btnEditMode.Checked = btnCMEditMode1.Checked = MyStepItem.MyStepPanel.PanelViewEditMode != E_ViewMode.View;
|
|
// if on procedure, 'Delete' buttons should be disabled.
|
|
btnDelelete.Enabled = btnDelStep.Enabled = ! MyItemInfo.IsProcedure;
|
|
btnCpyStp.Enabled = !MyItemInfo.IsProcedure;
|
|
// if on procedure or section, 'change type' & 'insert' buttons should be disabled.
|
|
if (MyItemInfo.IsProcedure || MyItemInfo.IsSection)
|
|
{
|
|
btnChgTyp.Enabled = false;
|
|
|
|
btnInsCaut.Enabled = btnInsNote.Enabled = btnInsRNO.Enabled = btnInsFig.Enabled =
|
|
btnInsTable.Enabled = btnInsSubstep.Enabled = btnInsBefore.Enabled = btnInsAfter.Enabled = false;
|
|
// if on a procedure or section title, don't allow for insert of ROs or Transitions:
|
|
// disable buttons. Info panels for ROs and Transitions are made invisible in frmVEPROMS.cs
|
|
btnInsTrans.Enabled = btnCMTransition.Enabled = btnInsRO.Enabled = btnCMRO.Enabled = false;
|
|
btnInsAftH.Enabled = btnInsBefH.Enabled = false;
|
|
btnInsHLS.Enabled = (!MyItemInfo.IsStepSection) ? false : true; // allow hls from step section
|
|
if (btnInsHLS.Enabled) GalleryForSubTypes(MyItemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList.HLS, MyItemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList.HLS, btnInsHLS, (int)E_FromType.Step, btnCMInsHLS, docontextmenus);
|
|
this.Refresh();
|
|
return;
|
|
}
|
|
|
|
btnChgTyp.Enabled = true;
|
|
|
|
// set up insert buttons based on format
|
|
E_AccStep? actable = 0;
|
|
StepData sd = MyItemInfo.FormatStepData;
|
|
actable = sd.StepEditData.AcTable;
|
|
if (actable == null) actable = 0;
|
|
btnInsHLS.Enabled = true;
|
|
btnInsCaut.Enabled = (actable & E_AccStep.AddingCaution)>0;
|
|
btnInsNote.Enabled = (actable & E_AccStep.AddingNote) > 0;
|
|
btnInsRNO.Enabled = (actable & E_AccStep.AddingRNO) > 0;
|
|
btnInsFig.Enabled = (actable & E_AccStep.AddingTable) > 0;
|
|
btnInsTable.Enabled = (actable & E_AccStep.AddingTable) > 0;
|
|
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;
|
|
|
|
btnInsHLS.SubItems.Clear();
|
|
btnInsCaut.SubItems.Clear();
|
|
btnInsNote.SubItems.Clear();
|
|
btnInsRNO.SubItems.Clear();
|
|
btnInsFig.SubItems.Clear();
|
|
btnInsTable.SubItems.Clear();
|
|
btnInsSubstep.SubItems.Clear();
|
|
|
|
if (docontextmenus)
|
|
{
|
|
btnCMInsHLS.SubItems.Clear();
|
|
btnCMInsCaution.SubItems.Clear();
|
|
btnCMInsNote.SubItems.Clear();
|
|
btnCMInsFigure.SubItems.Clear();
|
|
btnCMInsTable.SubItems.Clear();
|
|
btnCMInsSubStps.SubItems.Clear();
|
|
btnCMInsRNO.SubItems.Clear();
|
|
}
|
|
// if (rno is enabled, set the tag:
|
|
if (btnInsRNO.Enabled)
|
|
btnInsRNO.Tag = string.Format("{0} {1}", (int)E_FromTypes.RNOs, MyStepItem.MyItemInfo.ActiveFormat.PlantFormat.FormatData.GetIndexFromType("RNOType"));
|
|
|
|
// add subitems depending on whether parent type is enabled:
|
|
if (btnInsHLS.Enabled) GalleryForSubTypes(MyItemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList.HLS, sd, btnInsHLS, 0, btnCMInsHLS, docontextmenus);
|
|
if (btnInsCaut.Enabled) GalleryForSubTypes(MyItemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList.Caution, sd, btnInsCaut, (int)E_FromType.Caution, btnCMInsCaution, docontextmenus);
|
|
if (btnInsNote.Enabled) GalleryForSubTypes(MyItemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList.Note, sd, btnInsNote, (int)E_FromType.Note, btnCMInsNote, docontextmenus);
|
|
if (btnInsFig.Enabled) GalleryForSubTypes(MyItemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList.Fig, sd, btnInsFig, (int)E_FromType.Table, btnCMInsFigure, docontextmenus);
|
|
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 = btnInsRO.Enabled = btnCMRO.Enabled = true;
|
|
}
|
|
/// <summary>
|
|
/// set up a gallery of step types whose parent are defined by input StepData. Can be below
|
|
/// more than one level, for example. Substep, EquipmentList, EquipmentWBlank - both equipment
|
|
/// lists would be put in gallery
|
|
/// </summary>
|
|
/// <param name="sdc">StepData: find subtypes related to this</param>
|
|
/// <param name="selType">StepData: this should be selected button</param>
|
|
/// <param name="btn">DevComponents.DotNetBar.ButtonItem: if items in the gallery, add gallery to this button</param>
|
|
/// <param name="cmbtn">DevComponents.DotNetBar.ButtonItem: if items in the gallery, add btns to context menu</param>
|
|
private void GalleryForSubTypes(StepData sdc, StepData selType, DevComponents.DotNetBar.ButtonItem btn, int fromtype, DevComponents.DotNetBar.ButtonItem cmbtn, bool docontextmenus)
|
|
{
|
|
int cursel = -1;
|
|
// 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"));
|
|
List<StepDataRetval> sdl = MyItemInfo.ActiveFormat.PlantFormat.FormatData.StepGetLevelTypes(getall, sdc, ref cursel, selType.Type, MyItemInfo);
|
|
if (sdl != null && sdl.Count > 0)
|
|
{
|
|
Char kt = 'A'; // start with letter A for KeyTips
|
|
// if doing the insert substep button, check for substeps already there and if so must match type.
|
|
if (btn.Name == "btnInsSubstep")
|
|
{
|
|
if (MyItemInfo.Steps != null)
|
|
{
|
|
ItemInfo ichld = MyItemInfo.Steps[0];
|
|
btn.Click += new System.EventHandler(btnInsStep_Click);
|
|
btn.Tag = string.Format("{0} {1}", fromtype, ichld.MyContent.Type - 20000);
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
btn.Tag = null;
|
|
btn.Click -= new System.EventHandler(btnInsStep_Click);
|
|
}
|
|
}
|
|
foreach (StepDataRetval sdr in sdl)
|
|
{
|
|
bool addit = true;
|
|
StepData sd = MyItemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList[sdr.Index];
|
|
int hlsSubType = -1; // if on hls, use this to set default on substep menu to first child
|
|
if (MyItemInfo.IsHigh && MyItemInfo.Steps != null)
|
|
{
|
|
hlsSubType = (int)MyItemInfo.Steps[0].MyContent.Type - 20000;
|
|
}
|
|
// unfortunately, there are some special cases to be handled.
|
|
// if high level step, don't put the rno button on
|
|
// if caution don't add note button (the StepGetLevelTypes method returns cautions/notes together
|
|
if (btn.Name == "btnInsHLS" && sd.Type == "RNOType") addit = false;
|
|
if (btn.Name == "btnInsCaut" && sd.Type.Length>=4 && sd.Type.Substring(0, 4) == "Note") addit = false;
|
|
if (btn.Name == "btnInsNote" && sd.Type.Length>=7 && sd.Type.Substring(0, 7) == "Caution") addit = false;
|
|
if (btn.Name == "btnInsSubstep" && MyItemInfo.Steps != null) addit = false;
|
|
if (addit)
|
|
{
|
|
DevComponents.DotNetBar.ButtonItem bi = new DevComponents.DotNetBar.ButtonItem("btn" + sd.Type, sd.Type);
|
|
bi.ButtonStyle = DevComponents.DotNetBar.eButtonStyle.TextOnlyAlways;
|
|
bi.Text = sdr.Name;
|
|
bi.Tag = string.Format("{0} {1}", fromtype, sdr.Index); // index of type to insert it when button is clicked
|
|
bi.Checked = (sd.Type == selType.Type);
|
|
if (docontextmenus)
|
|
{
|
|
DevComponents.DotNetBar.ButtonItem cmbi = new DevComponents.DotNetBar.ButtonItem("cmbtn" + sd.Type, sd.Type);
|
|
cmbi.ButtonStyle = DevComponents.DotNetBar.eButtonStyle.TextOnlyAlways;
|
|
cmbi.Text = sdr.Name;
|
|
cmbi.Tag = string.Format("{0} {1}", fromtype, sdr.Index); // index of type to insert it when button is clicked
|
|
cmbi.Checked = (sd.Type == selType.Type);
|
|
cmbi.Click += new System.EventHandler(btnInsStep_Click);
|
|
cmbtn.SubItems.Add(cmbi);
|
|
}
|
|
if (MyItemInfo.IsHigh && hlsSubType != -1 && sdr.Index == hlsSubType) bi.Checked = true;
|
|
bi.Click += new System.EventHandler(btnInsStep_Click);
|
|
// Assign only A-Z to the KeyTips in the list (i.e. assign only the first 24 in the list)
|
|
// Note that KeyTips logic support only single characters at this level (can't have 'AA' for example)
|
|
if (kt != '0')
|
|
{
|
|
bi.KeyTips = kt.ToString();
|
|
if (kt == 'Z')
|
|
kt = '0';
|
|
else
|
|
kt++;
|
|
}
|
|
btn.SubItems.Add(bi);
|
|
}
|
|
}
|
|
// if only 1, be sure event exists on button to insert item & if more than 1 remove event because
|
|
// we want the drop down to appear.
|
|
if (btn.Name != "btnInsRNO")
|
|
btn.Click -= new System.EventHandler(btnInsStep_Click);
|
|
if (docontextmenus)
|
|
cmbtn.Click -= new System.EventHandler(btnInsStep_Click);
|
|
if (btn.SubItems.Count == 1)
|
|
{
|
|
btn.SubItems.Clear();
|
|
if (btn.Name != "btnInsRNO")
|
|
{
|
|
btn.Tag = string.Format("{0} {1}", fromtype, sdc.Index);
|
|
btn.Click += new System.EventHandler(btnInsStep_Click);
|
|
}
|
|
if (docontextmenus)
|
|
{
|
|
cmbtn.SubItems.Clear();
|
|
DevComponents.DotNetBar.ButtonItem cmbi = new DevComponents.DotNetBar.ButtonItem("cmbtn" + sdc.Type, sdc.Type);
|
|
cmbi.ButtonStyle = DevComponents.DotNetBar.eButtonStyle.TextOnlyAlways;
|
|
cmbi.Text = btn.Text;
|
|
if (btn.Name == "btnInsRNO")
|
|
cmbi.Tag = btn.Tag;
|
|
else
|
|
cmbi.Tag = string.Format("{0} {1}", fromtype, sdc.Index); // index of type to insert it when button is clicked
|
|
cmbi.Click += new System.EventHandler(btnInsStep_Click);
|
|
cmbtn.SubItems.Add(cmbi);
|
|
}
|
|
}
|
|
}
|
|
rbnStepParts.Refresh();
|
|
}
|
|
#endregion
|
|
#region Insert Tab
|
|
private void btnSym_Click(object sender, EventArgs e)
|
|
{
|
|
DevComponents.DotNetBar.ButtonItem b = (DevComponents.DotNetBar.ButtonItem)sender;
|
|
_MyStepRTB.InsertSymbol(Convert.ToInt32(b.Tag));
|
|
}
|
|
public void btnInsPgBrk_Click(object sender, EventArgs e)
|
|
{
|
|
rtabInsert.Select();
|
|
if (MyItemInfo.IsProcedure || MyItemInfo.IsSection) return;
|
|
|
|
// toggle manual page break
|
|
StepConfig cfg = MyItemInfo.MyConfig as StepConfig;
|
|
cfg.Step_ManualPagebreak = !cfg.Step_ManualPagebreak;
|
|
btnInsPgBrk.Checked = cfg.Step_ManualPagebreak;
|
|
}
|
|
private void btnIndent_Click(object sender, EventArgs e)
|
|
{
|
|
_MyStepRTB.InsertIndent();
|
|
}
|
|
private void btnCMIndent_Click(object sender, EventArgs e)
|
|
{
|
|
_MyStepRTB.InsertIndent();
|
|
}
|
|
#endregion
|
|
#region Home Tab
|
|
private void btnPaste_Click(object sender, EventArgs e)
|
|
{
|
|
IDataObject myDO = Clipboard.GetDataObject();
|
|
if (myDO.GetDataPresent(DataFormats.Rtf))
|
|
{
|
|
string tmpForLink = myDO.GetData(DataFormats.Rtf).ToString();
|
|
tmpForLink = Regex.Replace(tmpForLink, @"#Link:ReferencedObject:[0-9]+ ", @"#Link:ReferencedObject:<NewID> ");
|
|
tmpForLink = Regex.Replace(tmpForLink, @"#Link:Transition:([0-9]+) [0-9]+ ", @"#Link:Transition:$1 <NewID> ");
|
|
tmpForLink = Regex.Replace(tmpForLink, @"#Link:TransitionRange:([0-9]+) [0-9]+ ", @"#Link:TransitionRange:$1 <NewID> ");
|
|
_MyStepRTB.SelectedRtf = tmpForLink;
|
|
}
|
|
else if (myDO.GetDataPresent(DataFormats.Text))
|
|
_MyStepRTB.SelectedText = myDO.GetData(DataFormats.Text).ToString();
|
|
if (_MyStepRTB.SelectionLength == 0) _MyStepRTB.SelectionFont = _MyStepRTB.MyStyleFont.WindowsFont;
|
|
}
|
|
private void btnCut_Click(object sender, EventArgs e)
|
|
{
|
|
Clipboard.Clear();
|
|
DataObject myDO = new DataObject("Rich Text Format", _MyStepRTB.SelectedRtf);
|
|
myDO.SetText(_MyStepRTB.SelectedText);
|
|
Clipboard.SetDataObject(myDO);
|
|
_MyStepRTB.SelectedText = "";
|
|
}
|
|
private void btnCopy_Click(object sender, EventArgs e)
|
|
{
|
|
Clipboard.Clear();
|
|
DataObject myDO = new DataObject("Rich Text Format", _MyStepRTB.SelectedRtf);
|
|
myDO.SetText(_MyStepRTB.SelectedText);
|
|
Clipboard.SetDataObject(myDO);
|
|
}
|
|
private void btnBold_Click(object sender, EventArgs e)
|
|
{
|
|
RTBAPI.ToggleBold(!RTBAPI.IsBold(_MyStepRTB), _MyStepRTB, _MyStepRTB.SelectionLength == 0 ? RTBAPI.RTBSelection.SCF_DEFAULT : RTBAPI.RTBSelection.SCF_SELECTION);
|
|
btnCMBold.Checked = btnBold.Checked = RTBAPI.IsBold(_MyStepRTB);
|
|
}
|
|
private void btnItalics_Click(object sender, EventArgs e)
|
|
{
|
|
RTBAPI.ToggleItalic(!RTBAPI.IsItalic(_MyStepRTB), _MyStepRTB, _MyStepRTB.SelectionLength == 0 ? RTBAPI.RTBSelection.SCF_DEFAULT : RTBAPI.RTBSelection.SCF_SELECTION);
|
|
btnCMItalics.Checked = btnItalics.Checked = RTBAPI.IsItalic(_MyStepRTB);
|
|
}
|
|
private void btnUnderline_Click(object sender, EventArgs e)
|
|
{
|
|
RTBAPI.ToggleUnderline(!RTBAPI.IsUnderline(_MyStepRTB), _MyStepRTB, _MyStepRTB.SelectionLength == 0 ? RTBAPI.RTBSelection.SCF_DEFAULT : RTBAPI.RTBSelection.SCF_SELECTION);
|
|
btnCMUnderline.Checked = btnUnderline.Checked = RTBAPI.IsUnderline(_MyStepRTB);
|
|
}
|
|
|
|
private void btnSuperscript_Click(object sender, EventArgs e)
|
|
{
|
|
RTBAPI.ToggleSuperscript(!RTBAPI.IsSuperScript(_MyStepRTB), _MyStepRTB, _MyStepRTB.SelectionLength == 0 ? RTBAPI.RTBSelection.SCF_DEFAULT : RTBAPI.RTBSelection.SCF_SELECTION);
|
|
btnCMSuperscript.Checked = btnSuperscript.Checked = RTBAPI.IsSuperScript(_MyStepRTB);
|
|
}
|
|
|
|
private void btnSubscript_Click(object sender, EventArgs e)
|
|
{
|
|
RTBAPI.ToggleSubscript(!RTBAPI.IsSubScript(_MyStepRTB), _MyStepRTB, _MyStepRTB.SelectionLength == 0 ? RTBAPI.RTBSelection.SCF_DEFAULT : RTBAPI.RTBSelection.SCF_SELECTION);
|
|
btnCMSubscript.Checked = btnSubscript.Checked = RTBAPI.IsSubScript(_MyStepRTB);
|
|
}
|
|
|
|
private void btnUppercase_Click(object sender, EventArgs e)
|
|
{
|
|
_MyStepRTB.SetSelectedCase('U');
|
|
}
|
|
|
|
private void btnLowercase_Click(object sender, EventArgs e)
|
|
{
|
|
_MyStepRTB.SetSelectedCase('l');
|
|
}
|
|
|
|
private void btnTitleCase_Click(object sender, EventArgs e)
|
|
{
|
|
_MyStepRTB.SetSelectedCase('T');
|
|
}
|
|
private void btnInsTrans_Click(object sender, EventArgs e)
|
|
{
|
|
// see if user is positioned 'on' a transition within the rtb, if so do a modify, otherwise,
|
|
// insert transition.
|
|
StepTabPanel tmp = Parent as StepTabPanel;
|
|
tmp.MyDisplayTabControl.OnLinkModifyTran(this, new StepPanelLinkEventArgs(_MyStepItem, MyStepRTB.MyLinkText));
|
|
}
|
|
|
|
private void btnInsHrdSpc_Click(object sender, EventArgs e)
|
|
{
|
|
_MyStepRTB.InsertSymbol(@"\u160?");
|
|
}
|
|
|
|
private void btnInsRO_Click(object sender, EventArgs e)
|
|
{
|
|
// see if user is positioned 'on' an ReferencedObject within the rtb, if so do a modify, otherwise,
|
|
// insert transition.
|
|
StepTabPanel tmp = Parent as StepTabPanel;
|
|
tmp.MyDisplayTabControl.OnLinkModifyRO(this, new StepPanelLinkEventArgs(_MyStepItem, MyStepRTB.MyLinkText));
|
|
}
|
|
|
|
private void btnRedo_Click(object sender, EventArgs e)
|
|
{
|
|
_MyStepRTB.Redo();
|
|
btnCMUndo.Enabled = btnUndo.Enabled = _MyStepRTB.CanUndo;
|
|
btnCMRedo.Enabled = btnRedo.Enabled = _MyStepRTB.CanRedo;
|
|
}
|
|
|
|
private void btnUndo_Click(object sender, EventArgs e)
|
|
{
|
|
_MyStepRTB.Undo();
|
|
if (_MyStepRTB.WasXDelete && (_MyStepRTB.Text[_MyStepRTB.SelectionStart - 1] == 'X'))
|
|
{
|
|
_MyStepRTB.Undo();
|
|
_MyStepRTB.WasXDelete = false;
|
|
|
|
// only allow one of these - not best case, but at least can get
|
|
// one undo
|
|
_MyStepRTB.ClearUndo();
|
|
}
|
|
btnCMRedo.Enabled = btnRedo.Enabled = _MyStepRTB.CanRedo;
|
|
btnCMUndo.Enabled = btnUndo.Enabled = _MyStepRTB.CanUndo;
|
|
}
|
|
private void btnGoTo_Click(object sender, EventArgs e)
|
|
{
|
|
// if on a transition, go to the selected transition 'to'. If on
|
|
// a referenced object, bring up ReferencedObject Editor (for now, just put up a message box.
|
|
if (_MyStepRTB.MyLinkText.IndexOf("Transition") > -1)
|
|
{
|
|
_MyStepItem.MyStepPanel.OnLinkClicked(sender, new StepPanelLinkEventArgs(_MyStepItem, _MyStepRTB.MyLinkText));
|
|
}
|
|
else
|
|
{
|
|
string roapp = Environment.GetEnvironmentVariable("roapp");
|
|
LinkText lt = new LinkText(_MyStepRTB.MyLinkText);
|
|
string args = "\"" + lt.MyRoUsageInfo.MyRODb.FolderPath + "\" " + lt.MyRoUsageInfo.ROID.ToLower();
|
|
System.Diagnostics.Process.Start(roapp, args);
|
|
}
|
|
}
|
|
private void btnChgTyp_Click(object sender, EventArgs e)
|
|
{
|
|
StepPanelTabDisplayEventArgs args = new StepPanelTabDisplayEventArgs("Change Step Type");
|
|
MyStepItem.MyStepPanel.OnTabDisplay(sender, args);
|
|
}
|
|
#endregion
|
|
#region RHM debug
|
|
//#if DEBUG
|
|
// // The following code generates an XML output for the selected item for print testing.
|
|
// private void btnPageBreak_Click(object sender, EventArgs e)
|
|
// {
|
|
// // This is here temporarily to get a node and all of it's children for print testing.
|
|
// OutputAllChildren(MyStepItem);
|
|
// }
|
|
// private void OutputAllChildren(StepItem myStepItem)
|
|
// {
|
|
// OutputAllChildren(myStepItem.MyBeforeStepItems);
|
|
// OutputStepInfo(myStepItem);
|
|
// OutputAllChildren(myStepItem.MyAfterStepItems);
|
|
// OutputAllChildren(myStepItem.MyRNOStepItems);
|
|
// }
|
|
// private void OutputStepInfo(StepItem myStepItem)
|
|
// {
|
|
// Label lbl = myStepItem.MyLabel;
|
|
// if (lbl.Text.Trim() != "")
|
|
// Console.WriteLine("<text x='{0}In' y='{1}In' font-family='{2}' font-size='{3}Pt'>{4}</text>",
|
|
// ToInches(myStepItem.Left + lbl.Left), ToInches(myStepItem.Top + lbl.Top),
|
|
// lbl.Font.FontFamily.Name,lbl.Font.SizeInPoints,lbl.Text);
|
|
// StepRTB rtb = myStepItem.MyStepRTB;
|
|
// Console.WriteLine("<foreignObject x='{0}In' y='{1}In' width='{2}In' " +
|
|
// "requiredExtensions='http://Volian.Com/EmbeddedRTF'>{3}</foreignObject>",
|
|
// ToInches(myStepItem.Left + rtb.Left), ToInches(myStepItem.Top + rtb.Top), ToInches(rtb.Width), myStepItem.MyItemInfo.MyContent.Text);
|
|
//// ToInches(myStepItem.Left + rtb.Left), ToInches(myStepItem.Top + rtb.Top), ToInches(rtb.Width), rtb.Rtf);
|
|
// }
|
|
// private float ToInches(int val)
|
|
// {
|
|
// return Convert.ToSingle(val)/96F;
|
|
// }
|
|
|
|
// private void OutputAllChildren(List<StepItem> list)
|
|
// {
|
|
// if(list != null)
|
|
// foreach (StepItem itm in list)
|
|
// OutputAllChildren(itm);
|
|
// }
|
|
|
|
|
|
//#endif
|
|
private void btnToggleEditView_Click(object sender, EventArgs e)
|
|
{
|
|
MyStepRTB.ToggleEditView();
|
|
SetStepButtonAndMenuEnabling(true);
|
|
}
|
|
#endregion
|
|
|
|
private void btnROEdit_Click(object sender, EventArgs e)
|
|
{
|
|
string roapp = Environment.GetEnvironmentVariable("roapp");
|
|
if (roapp == null)
|
|
{
|
|
MessageBox.Show("Could not find path to Ro Editor, check 'roapp' environment variable");
|
|
return;
|
|
}
|
|
if (MyDVI==null||MyDVI.DocVersionAssociationCount < 1)
|
|
{
|
|
MessageBox.Show("Could not find associated path for ro data.");
|
|
return;
|
|
}
|
|
string roloc = "\"" + MyDVI.DocVersionAssociations[0].MyROFst.MyRODb.FolderPath + "\"";
|
|
System.Diagnostics.Process.Start(roapp, roloc);
|
|
}
|
|
|
|
private void btnUpdROVal_Click(object sender, EventArgs e)
|
|
{
|
|
// use rodb directory path of the first rofst for the this document version. Later, will need
|
|
// to modify code to get which one (when there is more than one)
|
|
if (MyDVI.DocVersionAssociations.Count < 1)
|
|
{
|
|
MessageBox.Show("Error Updating ro.fst. No associated ro.fst");
|
|
return;
|
|
}
|
|
ROFstInfo roFstInfo = MyDVI.DocVersionAssociations[0].MyROFst;
|
|
|
|
string rofstPath = roFstInfo.MyRODb.FolderPath + @"\ro.fst";
|
|
if (!File.Exists(rofstPath))
|
|
{
|
|
MessageBox.Show("No existing ro.fst in path " + roFstInfo.MyRODb.FolderPath + ". Check for invalid path");
|
|
return;
|
|
}
|
|
FileInfo fiRofst = new FileInfo(rofstPath);
|
|
if (roFstInfo.DTS == fiRofst.LastWriteTime)
|
|
{
|
|
MessageBox.Show("ro.fst files are same for path " + roFstInfo.MyRODb.FolderPath + ", import of that ro.fst will not be done");
|
|
return;
|
|
}
|
|
if (roFstInfo.DTS > fiRofst.LastWriteTime)
|
|
{
|
|
MessageBox.Show("Cannot copy older ro.fst from " + roFstInfo.MyRODb.FolderPath + ", import of that ro.fst will not be done");
|
|
return;
|
|
}
|
|
Cursor = Cursors.WaitCursor;
|
|
|
|
using (DocVersion dv = DocVersion.Get(MyDVI.VersionID))
|
|
{
|
|
ROFst newrofst = ROFstInfo.UpdateRoFst(roFstInfo.MyRODb, dv.DocVersionAssociations[0], dv, roFstInfo);
|
|
StepPanelTabDisplayEventArgs args = new StepPanelTabDisplayEventArgs("DisplayROUpdateROFST");
|
|
MyStepItem.MyStepPanel.OnTabDisplay(sender, args);
|
|
btnUpdROVal.Enabled = false;
|
|
}
|
|
Cursor = Cursors.Default;
|
|
}
|
|
|
|
private void rtabAdmin_Click(object sender, EventArgs e)
|
|
{
|
|
btnUpdROVal.Enabled = false;
|
|
if (MyDVI.DocVersionAssociations.Count < 1) return;
|
|
if (!NewerRoFst()) return;
|
|
btnUpdROVal.Enabled = true;
|
|
}
|
|
public bool NewerRoFst()
|
|
{
|
|
if (_MyDVI == null) return false;
|
|
ROFstInfo roFstInfo = _MyDVI.DocVersionAssociations[0].MyROFst;
|
|
RODbInfo rdi = RODbInfo.Get(roFstInfo.RODbID);
|
|
string rofstPath = rdi.FolderPath + @"\ro.fst";
|
|
if (!File.Exists(rofstPath)) return false;
|
|
FileInfo fiRofst = new FileInfo(rofstPath);
|
|
if (roFstInfo.DTS == fiRofst.LastWriteTime) return false;
|
|
if (roFstInfo.DTS > fiRofst.LastWriteTime) return false;
|
|
return true;
|
|
}
|
|
public void SetUpdRoValBtn(bool en)
|
|
{
|
|
btnUpdROVal.Enabled = en;
|
|
}
|
|
private void btnBookmarks_Click(object sender, EventArgs e)
|
|
{
|
|
StepPanelTabDisplayEventArgs args = new StepPanelTabDisplayEventArgs("Bookmarks");
|
|
MyStepItem.MyStepPanel.OnTabDisplay(sender, args);
|
|
}
|
|
|
|
private void btnSearch_Click(object sender, EventArgs e)
|
|
{
|
|
StepPanelTabDisplayEventArgs args = new StepPanelTabDisplayEventArgs("Global Search");
|
|
MyStepItem.MyStepPanel.OnTabDisplay(sender, args);
|
|
}
|
|
|
|
private void btnLibDocs_Click(object sender, EventArgs e)
|
|
{
|
|
StepPanelTabDisplayEventArgs args = new StepPanelTabDisplayEventArgs("LibDocs");
|
|
MyStepItem.MyStepPanel.OnTabDisplay(sender, args);
|
|
}
|
|
|
|
public void btnAnnots_Click(object sender, EventArgs e)
|
|
{
|
|
StepPanelTabDisplayEventArgs args = new StepPanelTabDisplayEventArgs("Annots");
|
|
MyStepItem.MyStepPanel.OnTabDisplay(sender, args);
|
|
}
|
|
|
|
public void btnDelStep_Click(object sender, EventArgs e)
|
|
{
|
|
bool surpressMessageBox = (e == null);
|
|
SectionInfo si = MyStepItem.MyItemInfo as SectionInfo;
|
|
if (si != null)
|
|
{
|
|
string msg = si.HasChildren ? "Are you sure you want to delete this section and its steps?" : "Are you sure you want to delete this section?";
|
|
DialogResult result = MessageBox.Show(msg, "Verify Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
|
|
if (result == DialogResult.Yes)
|
|
{
|
|
|
|
if (!si.IsStepSection)
|
|
{
|
|
WordSectionEventArgs args = new WordSectionEventArgs(si);
|
|
MyStepItem.MyStepPanel.OnWordSectionClose(sender, args);
|
|
}
|
|
MyStepItem.RemoveItem();
|
|
if (!si.IsStepSection)
|
|
{
|
|
WordSectionEventArgs args = new WordSectionEventArgs(si);
|
|
MyStepItem.MyStepPanel.OnWordSectionDeleted(sender, args);
|
|
}
|
|
}
|
|
return;
|
|
}
|
|
StepInfo stpi = MyStepItem.MyItemInfo as StepInfo;
|
|
if (stpi == null) // not sure that it will every get here!
|
|
{
|
|
MessageBox.Show("Unknown type, cannot delete!");
|
|
return;
|
|
}
|
|
if (!surpressMessageBox)
|
|
{
|
|
string msgs = stpi.HasChildren ? "Are you sure you want to delete this step and its substeps?" : "Are you sure you want to delete this step?";
|
|
DialogResult results = MessageBox.Show(msgs, "Verify Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
|
|
if (results == DialogResult.Yes)
|
|
MyStepItem.RemoveItem();
|
|
}
|
|
else
|
|
MyStepItem.RemoveItem();
|
|
}
|
|
|
|
private void btnCMIns_PopupClose(object sender, EventArgs e)
|
|
{
|
|
_ContextMenuBar.SetContextMenuEx(_MyStepRTB, _DefaultContextMenu);
|
|
}
|
|
|
|
public void ShortCutContextMenu(string menuName)
|
|
{
|
|
bool displayMenu = false;
|
|
E_AccStep? actable = 0;
|
|
StepData sd = MyItemInfo.FormatStepData;
|
|
if (sd != null) // will be null if section
|
|
{
|
|
actable = sd.StepEditData.AcTable;
|
|
if (actable == null) actable = 0;
|
|
}
|
|
//btnInsCaut.Enabled = (actable & E_AccStep.AddingCaution) > 0;
|
|
switch (menuName)
|
|
{
|
|
case "InsHLS":
|
|
displayMenu = true;
|
|
_ContextMenuBar.SetContextMenuEx(_MyStepRTB, btnCMInsHLS);
|
|
break;
|
|
case "InsRNO":
|
|
displayMenu = (actable & E_AccStep.AddingRNO) > 0;
|
|
_ContextMenuBar.SetContextMenuEx(_MyStepRTB, btnCMInsRNO);
|
|
break;
|
|
case "InsSubStps":
|
|
displayMenu = (actable & E_AccStep.AddingSub) > 0;
|
|
_ContextMenuBar.SetContextMenuEx(_MyStepRTB, btnCMInsSubStps);
|
|
break;
|
|
case "InsCaution":
|
|
displayMenu = (actable & E_AccStep.AddingCaution) > 0;
|
|
_ContextMenuBar.SetContextMenuEx(_MyStepRTB, btnCMInsCaution);
|
|
break;
|
|
case "InsNote":
|
|
displayMenu = (actable & E_AccStep.AddingNote) > 0;
|
|
_ContextMenuBar.SetContextMenuEx(_MyStepRTB, btnCMInsNote);
|
|
break;
|
|
case "InsTable":
|
|
displayMenu = (actable & E_AccStep.AddingTable) > 0;
|
|
_ContextMenuBar.SetContextMenuEx(_MyStepRTB, btnCMInsTable);
|
|
break;
|
|
case "InsFigure":
|
|
displayMenu = (actable & E_AccStep.AddingTable) > 0;
|
|
_ContextMenuBar.SetContextMenuEx(_MyStepRTB, btnCMInsFigure);
|
|
break;
|
|
case "StepPaste":
|
|
displayMenu = true;
|
|
_ContextMenuBar.SetContextMenuEx(_MyStepRTB, btnCMStepPaste);
|
|
break;
|
|
}
|
|
if (displayMenu)
|
|
{
|
|
SendKeys.Send("+{F10}{DOWN}"); // Display Context menu
|
|
}
|
|
}
|
|
|
|
private void btnSpell_Click(object sender, EventArgs e)
|
|
{
|
|
//MessageBox.Show("Functionality not available.", "Spell Check");
|
|
StepPanelTabDisplayEventArgs args = new StepPanelTabDisplayEventArgs("SpellChecker");
|
|
MyStepItem.MyStepPanel.OnTabDisplay(sender, args);
|
|
}
|
|
//private FindReplace dlgFindReplace = null;
|
|
private void btnFindRplDlg_Click(object sender, EventArgs e)
|
|
{
|
|
StepPanelTabDisplayEventArgs args = new StepPanelTabDisplayEventArgs("FndRpl");
|
|
MyStepItem.MyStepPanel.OnTabDisplay(sender, args);
|
|
}
|
|
|
|
private void InsertSiblingBeforeOrAfter(string b4aftr)
|
|
{
|
|
E_AccStep? actable = 0;
|
|
StepData sd = MyItemInfo.FormatStepData;
|
|
actable = sd.StepEditData.AcTable;
|
|
if (actable == null) actable = 0;
|
|
switch (b4aftr)
|
|
{
|
|
case "after":
|
|
if ((actable & E_AccStep.AddingNext) > 0)
|
|
MyStepItem.AddSiblingAfter();
|
|
break;
|
|
case "before":
|
|
if ((actable & E_AccStep.AddingPrev) > 0)
|
|
MyStepItem.AddSiblingBefore();
|
|
break;
|
|
}
|
|
}
|
|
public void ProcessEnterKey()
|
|
{
|
|
bool deletedEmpty = false;
|
|
bool deletedHLS = false;
|
|
bool deletedSubStep = false;
|
|
bool deletedRNO = false;
|
|
bool deletedNote = false;
|
|
bool deletedCaution = false;
|
|
if (MyStepRTB.Text.Length < 1) //empty step text
|
|
{
|
|
deletedEmpty = true;
|
|
deletedHLS = MyItemInfo.IsHigh;
|
|
deletedSubStep = MyItemInfo.IsStepPart;
|
|
deletedRNO = MyItemInfo.IsRNOPart;
|
|
deletedNote = MyItemInfo.IsNote;
|
|
deletedCaution = MyItemInfo.IsCaution;
|
|
|
|
btnDelStep_Click(MyStepRTB, null); // delete the empty step piece
|
|
}
|
|
|
|
if (MyItemInfo.IsHigh)
|
|
{
|
|
if (!deletedHLS)
|
|
{
|
|
if (deletedSubStep)
|
|
ShortCutContextMenu("InsHLS");
|
|
else if (MyStepItem.MyRNOStepItems != null && MyStepItem.MyRNOStepItems.Count > 0)
|
|
MyStepRTB.StepRTB_ArrowPressed(E_ArrowKeys.CtrlRight); // jump to RNO
|
|
else if (deletedRNO)
|
|
{
|
|
AddSubStep();
|
|
}
|
|
else if (!deletedHLS)
|
|
{
|
|
if (MyItemInfo.ColumnMode > 0)
|
|
CreateNewRNO();
|
|
else
|
|
AddSubStep();
|
|
}
|
|
}
|
|
}
|
|
else if (MyItemInfo.IsRNOPart)
|
|
{
|
|
MyStepRTB.StepRTB_ArrowPressed(E_ArrowKeys.CtrlLeft);
|
|
if (MyItemInfo.IsHigh)
|
|
{
|
|
if (MyStepItem.NextDownStepItem.MyItemInfo.MyParent.Equals(MyStepItem.MyItemInfo))
|
|
//if (MyStepItem.NextDownStepItem.MyItemInfo.MyParent.ItemID == MyStepItem.MyItemInfo.ItemID) //.Equals(MyStepItem.MyItemInfo))
|
|
{
|
|
MyStepRTB.StepRTB_ArrowPressed(E_ArrowKeys.CtrlDown);
|
|
InsertSiblingBeforeOrAfter("before");
|
|
}
|
|
else
|
|
ShortCutContextMenu("InsSubStps");
|
|
}
|
|
else
|
|
InsertSiblingBeforeOrAfter("after");
|
|
}
|
|
else if (MyItemInfo.IsInRNO && MyItemInfo.IsStepPart)
|
|
{
|
|
if (deletedEmpty)
|
|
{
|
|
MyStepRTB.StepRTB_ArrowPressed(E_ArrowKeys.CtrlLeft);
|
|
CreateNewRNO();
|
|
}
|
|
else
|
|
InsertSiblingBeforeOrAfter("after");
|
|
}
|
|
else if (MyItemInfo.IsStepPart)
|
|
{
|
|
if (deletedSubStep)
|
|
{
|
|
MyStepRTB.StepRTB_ArrowPressed(E_ArrowKeys.CtrlUp); // jump to HLS
|
|
ShortCutContextMenu("InsHLS"); // prompt for new HLS
|
|
}
|
|
else if (deletedRNO || MyItemInfo.IsEquipmentList)
|
|
InsertSiblingBeforeOrAfter("after");
|
|
else if (MyStepItem.MyRNOStepItems != null && MyStepItem.MyRNOStepItems.Count > 0)
|
|
MyStepRTB.StepRTB_ArrowPressed(E_ArrowKeys.CtrlRight); // jump to RNO
|
|
else
|
|
if (MyItemInfo.ColumnMode > 0)
|
|
CreateNewRNO();
|
|
else
|
|
InsertSiblingBeforeOrAfter("after");
|
|
}
|
|
else if (MyItemInfo.IsCaution)
|
|
{
|
|
if (deletedEmpty)
|
|
{
|
|
MyStepRTB.StepRTB_ArrowPressed(E_ArrowKeys.CtrlDown);
|
|
if (deletedCaution)
|
|
CreateNewNote();
|
|
}
|
|
else
|
|
InsertSiblingBeforeOrAfter("after");
|
|
}
|
|
else if (MyItemInfo.IsNote)
|
|
{
|
|
if (!deletedEmpty)
|
|
InsertSiblingBeforeOrAfter("after");
|
|
else
|
|
MyStepRTB.StepRTB_ArrowPressed(E_ArrowKeys.CtrlDown);
|
|
}
|
|
else if (MyItemInfo.IsTable || MyItemInfo.IsFigure)
|
|
{
|
|
MyStepRTB.StepRTB_ArrowPressed(E_ArrowKeys.CtrlUp);
|
|
if (MyItemInfo.IsHigh)
|
|
ShortCutContextMenu("InsHLS");
|
|
else
|
|
InsertSiblingBeforeOrAfter("after");
|
|
}
|
|
}
|
|
|
|
private void AddSubStep()
|
|
{
|
|
if (MyStepItem.NextDownStepItem.MyItemInfo.MyParent.ItemID == MyStepItem.MyID)
|
|
{
|
|
MyStepRTB.StepRTB_ArrowPressed(E_ArrowKeys.CtrlDown);
|
|
InsertSiblingBeforeOrAfter("before");
|
|
}
|
|
else
|
|
ShortCutContextMenu("InsSubStps");
|
|
}
|
|
|
|
private void CreateNewRNO()
|
|
{
|
|
if (btnInsRNO.SubItems.Count > 1)
|
|
ShortCutContextMenu("InsRNO");
|
|
else
|
|
btnInsRNO.RaiseClick();
|
|
}
|
|
|
|
private void CreateNewNote()
|
|
{
|
|
if (btnInsNote.SubItems.Count > 1)
|
|
ShortCutContextMenu("InsNote");
|
|
else
|
|
btnInsNote.RaiseClick();
|
|
}
|
|
private void btnPasteAfter_Click(object sender, EventArgs e)
|
|
{
|
|
StepTabPanel tmp = Parent as StepTabPanel;
|
|
if (tmp.MyDisplayTabControl.MyCopyStep == null) return;
|
|
MyStepItem.PasteSiblingAfter(tmp.MyDisplayTabControl.MyCopyStep.ItemID);
|
|
}
|
|
private void btnPasteBefore_Click(object sender, EventArgs e)
|
|
{
|
|
StepTabPanel tmp = Parent as StepTabPanel;
|
|
if (tmp.MyDisplayTabControl.MyCopyStep == null) return;
|
|
MyStepItem.PasteSiblingBefore(tmp.MyDisplayTabControl.MyCopyStep.ItemID);
|
|
}
|
|
private void btnStepPaste_Click(object sender, EventArgs e)
|
|
{
|
|
// just return
|
|
}
|
|
|
|
private void btnCpyStp_Click(object sender, EventArgs e)
|
|
{
|
|
DoCopyStep();
|
|
}
|
|
|
|
public void DoCopyStep()
|
|
{
|
|
// highlight selected step(s) and prompt to see if selection is what user wants:
|
|
MyStepItem.HighlightBackColor();
|
|
DialogResult dr = MessageBox.Show("Step as Marked?", "Identify Step To Be Copied", MessageBoxButtons.YesNo);
|
|
if (dr == DialogResult.Yes)
|
|
{
|
|
StepTabPanel tmp = Parent as StepTabPanel;
|
|
tmp.MyDisplayTabControl.MyCopyStep = MyItemInfo;
|
|
btnStepPaste.Enabled = true;
|
|
SetPasteButtonEnabled();
|
|
}
|
|
MyStepItem.SetBackColor();
|
|
}
|
|
|
|
private void btnPasteReplace_Click(object sender, EventArgs e)
|
|
{
|
|
StepTabPanel tmp = Parent as StepTabPanel;
|
|
if (tmp.MyDisplayTabControl.MyCopyStep==null) return;
|
|
StepItem oldStepItem = MyStepItem;
|
|
MyStepItem = MyStepItem.PasteReplace(tmp.MyDisplayTabControl.MyCopyStep.ItemID);
|
|
if (MyStepItem.MyItemInfo.ItemID != oldStepItem.MyItemInfo.ItemID) oldStepItem.Dispose();
|
|
}
|
|
}
|
|
public enum E_FieldToEdit { StepText, Text, Number };
|
|
}
|
|
|