This commit is contained in:
@@ -11,6 +11,7 @@ namespace Volian.Controls.Library
|
||||
{
|
||||
public partial class StepTabRibbon : UserControl
|
||||
{
|
||||
#region Properties
|
||||
private StepItem _MyStepItem;
|
||||
public StepItem MyStepItem
|
||||
{
|
||||
@@ -24,6 +25,7 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
}
|
||||
}
|
||||
private int _MyLastFormatID = -1;
|
||||
private StepRTB _MyStepRTB;
|
||||
public StepRTB MyStepRTB
|
||||
{
|
||||
@@ -33,14 +35,64 @@ namespace Volian.Controls.Library
|
||||
_MyStepRTB = value;
|
||||
if (value != null)
|
||||
{
|
||||
Console.WriteLine(string.Format("StepTabRibbon: In set of MyStepRTB, Selected Text = {0}", MyStepRTB.SelectedText));
|
||||
_ContextMenuBar.SetContextMenuEx(_MyStepRTB, btnCMRtfEdit);
|
||||
_MyStepRTB.SelectionChanged += new EventHandler(MyStepRTB_SelectionChanged);
|
||||
//_MyStepRTB.SelectionChanged += new EventHandler(MyStepRTB_SelectionChanged);
|
||||
_MyStepRTB.MouseUp += new MouseEventHandler(MyStepRTB_SelectionChanged);
|
||||
_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 (_MyStepRTB.MyStepItem.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 = _MyStepRTB.MyStepItem.MyItemInfo.ActiveFormat;
|
||||
SymbolList sl = fmt.PlantFormat.FormatData.SymbolList;
|
||||
if (sl == null || sl.Count <= 0)
|
||||
{
|
||||
MessageBox.Show("No symbols are available, check with administrator");
|
||||
return;
|
||||
}
|
||||
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(@"\u{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(@"\u{0}", sym.Unicode);
|
||||
btnCM.FontBold = true;
|
||||
btnCM.Click += new System.EventHandler(btnSym_Click);
|
||||
galleryContainerSymbolsCM.SubItems.Add(btnCM);
|
||||
}
|
||||
}
|
||||
SetButtonAndMenuEnabling();
|
||||
SetStepButtonAndMenuEnabling();
|
||||
_MyLastFormatID = _MyStepRTB.MyStepItem.MyItemInfo.ActiveFormat.FormatID;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#region Constructor
|
||||
public StepTabRibbon()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
#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.
|
||||
@@ -58,14 +110,58 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
void MyStepRTB_Leave(object sender, EventArgs e)
|
||||
{
|
||||
_MyStepRTB.SelectionChanged -= new EventHandler(MyStepRTB_SelectionChanged);
|
||||
//_MyStepRTB.SelectionChanged -= new EventHandler(MyStepRTB_SelectionChanged);
|
||||
_MyStepRTB.MouseUp -= new MouseEventHandler(MyStepRTB_SelectionChanged);
|
||||
_MyStepRTB.Leave -= new EventHandler(MyStepRTB_Leave);
|
||||
_MyStepRTB.LinkChanged -= new StepRTBLinkEvent(_MyStepRTB_LinkChanged);
|
||||
}
|
||||
void MyStepRTB_SelectionChanged(object sender, EventArgs e)
|
||||
{
|
||||
Console.WriteLine(string.Format("StepTabRibbon: In MyStepRTB_SelectionChanged, Selected Text = {0}",MyStepRTB.SelectedText));
|
||||
SetButtonAndMenuEnabling();
|
||||
}
|
||||
void btnInsStep_Click(object sender, EventArgs e)
|
||||
{
|
||||
DevComponents.DotNetBar.ButtonItem b = (DevComponents.DotNetBar.ButtonItem)sender;
|
||||
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, do a after from current HLS
|
||||
// if not at HLS, go up parents until find it.
|
||||
if (fromtype == 0)
|
||||
{
|
||||
StepItem hlsStepItem = _MyStepItem;
|
||||
|
||||
while (!hlsStepItem.MyItemInfo.IsHigh)
|
||||
hlsStepItem = hlsStepItem.MyParentStepItem;
|
||||
hlsStepItem.AddSiblingAfter(); // (contenttype);
|
||||
}
|
||||
else
|
||||
{
|
||||
_MyStepItem.AddChild((E_FromType)fromtype, contenttype);
|
||||
}
|
||||
}
|
||||
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 = !((_MyStepRTB.MyStyleFont.Style & E_Style.Bold) == E_Style.Bold || (_MyStepRTB.MyStyleFont.Style & E_Style.MmBold) == E_Style.MmBold);
|
||||
btnUnderline.Enabled = !((_MyStepRTB.MyStyleFont.Style & E_Style.Underline) == E_Style.Underline);
|
||||
btnItalics.Enabled = !((_MyStepRTB.MyStyleFont.Style & E_Style.Italics) == E_Style.Italics);
|
||||
}
|
||||
private void SetButtonAndMenuEnabling()
|
||||
{
|
||||
if (_MyStepRTB == null) return;
|
||||
@@ -77,6 +173,9 @@ namespace Volian.Controls.Library
|
||||
btnCMSubscript.Checked = btnSubscript.Checked = RTBAPI.IsSubScript(_MyStepRTB);
|
||||
btnCMSuperscript.Checked = btnSuperscript.Checked = RTBAPI.IsSuperScript(_MyStepRTB);
|
||||
}
|
||||
//if (_MyStepItem.MyItemInfo.MyContent.Type == 20006 || _MyStepItem.MyItemInfo.MyContent.Type == 20007)
|
||||
// Console.WriteLine("debug");
|
||||
//SetButtonForStyle();
|
||||
btnCMCut.Enabled = btnCMCopy.Enabled = btnCut.Enabled = btnCopy.Enabled = _MyStepRTB.SelectionLength > 0;
|
||||
btnCMUndo.Enabled = btnUndo.Enabled = _MyStepRTB.CanUndo;
|
||||
btnCMRedo.Enabled = btnRedo.Enabled = _MyStepRTB.CanRedo;
|
||||
@@ -98,48 +197,138 @@ namespace Volian.Controls.Library
|
||||
btnCMEditRO.Enabled = false;
|
||||
}
|
||||
}
|
||||
public StepTabRibbon()
|
||||
private void SetStepButtonAndMenuEnabling()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
// 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!!!!
|
||||
Format fmt = VEPROMS.CSLA.Library.Format.Get(1); //base for now - TO DO KBR:
|
||||
SymbolList sl = fmt.PlantFormat.FormatData.SymbolList;
|
||||
if (sl == null || sl.Count <= 0)
|
||||
// see if manual page break - only available on HLS
|
||||
if (_MyStepItem.MyItemInfo.IsHigh)
|
||||
{
|
||||
MessageBox.Show("No symbols are available, check with administrator");
|
||||
StepConfig cfg = _MyStepItem.MyItemInfo.MyConfig as StepConfig;
|
||||
btnInsPgBrk.Checked = cfg == null ? false : cfg.Step_ManualPagebreak;
|
||||
}
|
||||
btnInsPgBrk.Enabled = _MyStepItem.MyItemInfo.IsHigh;
|
||||
|
||||
// if on procedure or section 'change type' & 'insert' buttons should be disabled.
|
||||
if (_MyStepItem.MyItemInfo.IsProcedure || _MyStepItem.MyItemInfo.IsSection)
|
||||
{
|
||||
btnChgTyp.Enabled = false;
|
||||
btnInsHLS.Enabled = btnInsCaut.Enabled = btnInsNote.Enabled = btnInsRNO.Enabled = btnInsFig.Enabled =
|
||||
btnInsTable.Enabled = btnInsSubstep.Enabled = btnInsBefore.Enabled = btnInsAfter.Enabled = false;
|
||||
return;
|
||||
}
|
||||
foreach (Symbol sym in sl)
|
||||
|
||||
btnChgTyp.Enabled = true;
|
||||
|
||||
// set up insert buttons based on format
|
||||
E_AccStep? actable = 0;
|
||||
StepData sd = _MyStepItem.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 = (actable & E_AccStep.AddingPrev) > 0;
|
||||
btnInsAfter.Enabled = (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 (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(_MyStepItem.MyItemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList.HLS, sd, btnInsHLS, 0);
|
||||
if (btnInsCaut.Enabled) GalleryForSubTypes(_MyStepItem.MyItemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList.Caution, sd, btnInsCaut, (int)E_FromType.Caution);
|
||||
if (btnInsNote.Enabled) GalleryForSubTypes(_MyStepItem.MyItemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList.Note, sd, btnInsNote, (int)E_FromType.Note);
|
||||
if (btnInsFig.Enabled) GalleryForSubTypes(_MyStepItem.MyItemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList.Fig, sd, btnInsFig, (int)E_FromType.Table);
|
||||
if (btnInsTable.Enabled) GalleryForSubTypes(_MyStepItem.MyItemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList.Table, sd, btnInsTable, (int)E_FromType.Table);
|
||||
if (btnInsSubstep.Enabled) GalleryForSubTypes(_MyStepItem.MyItemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList.Substep, sd, btnInsSubstep, (int)E_FromType.Step);
|
||||
}
|
||||
/// <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>
|
||||
private void GalleryForSubTypes(StepData sdc, StepData selType, DevComponents.DotNetBar.ButtonItem btn, int fromtype)
|
||||
{
|
||||
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 = _MyStepItem.MyItemInfo.ActiveFormat.PlantFormat.FormatData.StepGetLevelTypes(getall, sdc, ref cursel, selType.Type, _MyStepItem.MyItemInfo);
|
||||
if (sdl != null && sdl.Count > 0)
|
||||
{
|
||||
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(@"\u{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(@"\u{0}", sym.Unicode);
|
||||
btnCM.FontBold = true;
|
||||
btnCM.Click += new System.EventHandler(btnSym_Click);
|
||||
galleryContainerSymbolsCM.SubItems.Add(btnCM);
|
||||
foreach (StepDataRetval sdr in sdl)
|
||||
{
|
||||
bool addit = true;
|
||||
StepData sd = _MyStepItem.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 (_MyStepItem.MyItemInfo.IsHigh && _MyStepItem.MyItemInfo.Steps != null)
|
||||
{
|
||||
hlsSubType = (int)_MyStepItem.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 (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 (_MyStepItem.MyItemInfo.IsHigh && hlsSubType != -1 && sdr.Index == hlsSubType) bi.Checked = true;
|
||||
bi.Click += new System.EventHandler(btnInsStep_Click);
|
||||
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.
|
||||
btn.Click -= new System.EventHandler(btnInsStep_Click);
|
||||
if (btn.SubItems.Count == 1)
|
||||
{
|
||||
btn.SubItems.Clear();
|
||||
btn.Tag = string.Format("{0} {1}", fromtype, sdc.Index);
|
||||
btn.Click += new System.EventHandler(btnInsStep_Click);
|
||||
}
|
||||
//else
|
||||
// btn.Click -= new System.EventHandler(btnInsStep_Click);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#region Insert Tab
|
||||
private void btnSym_Click(object sender, EventArgs e)
|
||||
{
|
||||
DevComponents.DotNetBar.ButtonItem b = (DevComponents.DotNetBar.ButtonItem)sender;
|
||||
_MyStepRTB.InsertSymbol((string)b.Tag);
|
||||
}
|
||||
private void btnInsPgBrk_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_MyStepItem.MyItemInfo.IsProcedure || _MyStepItem.MyItemInfo.IsSection) return;
|
||||
|
||||
// toggle manual page break
|
||||
StepConfig cfg = _MyStepItem.MyItemInfo.MyConfig as StepConfig;
|
||||
cfg.Step_ManualPagebreak = !cfg.Step_ManualPagebreak;
|
||||
btnInsPgBrk.Checked = cfg.Step_ManualPagebreak;
|
||||
}
|
||||
#endregion
|
||||
#region Home Tab
|
||||
private void btnPaste_Click(object sender, EventArgs e)
|
||||
{
|
||||
IDataObject myDO = Clipboard.GetDataObject();
|
||||
@@ -243,15 +432,15 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
else
|
||||
{
|
||||
// bring up ro editor - for now just do a messagebox.
|
||||
MessageBox.Show("Bring up ro editor");
|
||||
_MyStepItem.MyStepPanel.OnLinkClicked(sender, new StepPanelLinkEventArgs(_MyStepItem, _MyStepRTB.MyLinkText));
|
||||
// for now bring up ro window. Later bring up ro editor!
|
||||
}
|
||||
}
|
||||
|
||||
private void rpanInsert_Click(object sender, EventArgs e)
|
||||
private void btnChgTyp_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
#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)
|
||||
@@ -291,5 +480,6 @@ namespace Volian.Controls.Library
|
||||
OutputAllChildren(itm);
|
||||
}
|
||||
#endif
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user