support for StepRTB on property pages
This commit is contained in:
@@ -25,6 +25,9 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
}
|
||||
}
|
||||
private ItemInfo MyItemInfo
|
||||
{ get { return _MyStepRTB.MyItemInfo; } }
|
||||
|
||||
private int _MyLastFormatID = -1;
|
||||
private StepRTB _MyStepRTB;
|
||||
public StepRTB MyStepRTB
|
||||
@@ -36,7 +39,18 @@ namespace Volian.Controls.Library
|
||||
if (value != null)
|
||||
{
|
||||
//Console.WriteLine(string.Format("StepTabRibbon: In set of MyStepRTB, Selected Text = {0}", MyStepRTB.SelectedText));
|
||||
_ContextMenuBar.SetContextMenuEx(_MyStepRTB, btnCMRtfEdit);
|
||||
switch (_MyStepRTB.FieldToEdit)
|
||||
{
|
||||
case E_FieldToEdit.StepText:
|
||||
_ContextMenuBar.SetContextMenuEx(_MyStepRTB, btnCMRtfEdit);
|
||||
break;
|
||||
case E_FieldToEdit.Text:
|
||||
case E_FieldToEdit.Number:
|
||||
_ContextMenuBar.SetContextMenuEx(_MyStepRTB, btnCMRtfEdit3);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
//_MyStepRTB.KeyDown += new KeyEventHandler(MyStepRTB_SelectionChanged);
|
||||
_MyStepRTB.KeyUp += new KeyEventHandler(MyStepRTB_SelectionChanged);
|
||||
_MyStepRTB.ModeChange += new StepRTBModeChangeEvent(_MyStepRTB_ModeChange);
|
||||
@@ -46,48 +60,54 @@ namespace Volian.Controls.Library
|
||||
// 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)
|
||||
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 = _MyStepRTB.MyStepItem.MyItemInfo.ActiveFormat;
|
||||
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;
|
||||
}
|
||||
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);
|
||||
galleryContainerSymbolsCM.SubItems.Add(btnCM);
|
||||
}
|
||||
BuildSymbolGallery(sl, galleryContainerSymbolsCM);
|
||||
BuildSymbolGallery(sl, galleryContainerSymbolsCM3);
|
||||
}
|
||||
SetButtonAndMenuEnabling();
|
||||
SetStepButtonAndMenuEnabling();
|
||||
_MyLastFormatID = _MyStepRTB.MyStepItem.MyItemInfo.ActiveFormat.FormatID;
|
||||
_MyLastFormatID = MyItemInfo.ActiveFormat.FormatID;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
@@ -156,9 +176,33 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
else
|
||||
{
|
||||
_MyStepItem.AddChild((E_FromType)fromtype, contenttype);
|
||||
// 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();
|
||||
@@ -200,6 +244,8 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
private void SetButtonAndMenuEnabling()
|
||||
{
|
||||
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;
|
||||
@@ -245,15 +291,15 @@ namespace Volian.Controls.Library
|
||||
private void SetStepButtonAndMenuEnabling()
|
||||
{
|
||||
// see if manual page break - only available on HLS
|
||||
if (_MyStepItem.MyItemInfo.IsHigh)
|
||||
if (MyItemInfo.IsHigh)
|
||||
{
|
||||
StepConfig cfg = _MyStepItem.MyItemInfo.MyConfig as StepConfig;
|
||||
StepConfig cfg = MyItemInfo.MyConfig as StepConfig;
|
||||
btnInsPgBrk.Checked = cfg == null ? false : cfg.Step_ManualPagebreak;
|
||||
}
|
||||
btnInsPgBrk.Enabled = _MyStepItem.MyItemInfo.IsHigh;
|
||||
btnInsPgBrk.Enabled = MyItemInfo.IsHigh;
|
||||
|
||||
// if on procedure or section 'change type' & 'insert' buttons should be disabled.
|
||||
if (_MyStepItem.MyItemInfo.IsProcedure || _MyStepItem.MyItemInfo.IsSection)
|
||||
if (MyItemInfo.IsProcedure || MyItemInfo.IsSection)
|
||||
{
|
||||
btnChgTyp.Enabled = false;
|
||||
btnInsHLS.Enabled = btnInsCaut.Enabled = btnInsNote.Enabled = btnInsRNO.Enabled = btnInsFig.Enabled =
|
||||
@@ -268,7 +314,7 @@ namespace Volian.Controls.Library
|
||||
|
||||
// set up insert buttons based on format
|
||||
E_AccStep? actable = 0;
|
||||
StepData sd = _MyStepItem.MyItemInfo.FormatStepData;
|
||||
StepData sd = MyItemInfo.FormatStepData;
|
||||
actable = sd.StepEditData.AcTable;
|
||||
if (actable == null) actable = 0;
|
||||
btnInsHLS.Enabled = true;
|
||||
@@ -294,12 +340,12 @@ namespace Volian.Controls.Library
|
||||
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);
|
||||
if (btnInsHLS.Enabled) GalleryForSubTypes(MyItemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList.HLS, sd, btnInsHLS, 0);
|
||||
if (btnInsCaut.Enabled) GalleryForSubTypes(MyItemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList.Caution, sd, btnInsCaut, (int)E_FromType.Caution);
|
||||
if (btnInsNote.Enabled) GalleryForSubTypes(MyItemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList.Note, sd, btnInsNote, (int)E_FromType.Note);
|
||||
if (btnInsFig.Enabled) GalleryForSubTypes(MyItemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList.Fig, sd, btnInsFig, (int)E_FromType.Table);
|
||||
if (btnInsTable.Enabled) GalleryForSubTypes(MyItemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList.Table, sd, btnInsTable, (int)E_FromType.Table);
|
||||
if (btnInsSubstep.Enabled) GalleryForSubTypes(MyItemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList.Substep, sd, btnInsSubstep, (int)E_FromType.Step);
|
||||
|
||||
btnInsTrans.Enabled = btnCMTransition.Enabled = btnInsRO.Enabled = btnCMRO.Enabled = true;
|
||||
}
|
||||
@@ -318,17 +364,17 @@ namespace Volian.Controls.Library
|
||||
// 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);
|
||||
List<StepDataRetval> sdl = MyItemInfo.ActiveFormat.PlantFormat.FormatData.StepGetLevelTypes(getall, sdc, ref cursel, selType.Type, MyItemInfo);
|
||||
if (sdl != null && sdl.Count > 0)
|
||||
{
|
||||
foreach (StepDataRetval sdr in sdl)
|
||||
{
|
||||
bool addit = true;
|
||||
StepData sd = _MyStepItem.MyItemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList[sdr.Index];
|
||||
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 (_MyStepItem.MyItemInfo.IsHigh && _MyStepItem.MyItemInfo.Steps != null)
|
||||
if (MyItemInfo.IsHigh && MyItemInfo.Steps != null)
|
||||
{
|
||||
hlsSubType = (int)_MyStepItem.MyItemInfo.Steps[0].MyContent.Type - 20000;
|
||||
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
|
||||
@@ -343,7 +389,7 @@ namespace Volian.Controls.Library
|
||||
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;
|
||||
if (MyItemInfo.IsHigh && hlsSubType != -1 && sdr.Index == hlsSubType) bi.Checked = true;
|
||||
bi.Click += new System.EventHandler(btnInsStep_Click);
|
||||
btn.SubItems.Add(bi);
|
||||
}
|
||||
@@ -370,10 +416,10 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
private void btnInsPgBrk_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_MyStepItem.MyItemInfo.IsProcedure || _MyStepItem.MyItemInfo.IsSection) return;
|
||||
if (MyItemInfo.IsProcedure || MyItemInfo.IsSection) return;
|
||||
|
||||
// toggle manual page break
|
||||
StepConfig cfg = _MyStepItem.MyItemInfo.MyConfig as StepConfig;
|
||||
StepConfig cfg = MyItemInfo.MyConfig as StepConfig;
|
||||
cfg.Step_ManualPagebreak = !cfg.Step_ManualPagebreak;
|
||||
btnInsPgBrk.Checked = cfg.Step_ManualPagebreak;
|
||||
}
|
||||
@@ -561,4 +607,6 @@ namespace Volian.Controls.Library
|
||||
#endif
|
||||
#endregion
|
||||
}
|
||||
public enum E_FieldToEdit { StepText, Text, Number };
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user