This commit is contained in:
parent
768561ca7a
commit
f44e6162ec
@ -132,6 +132,10 @@ namespace Volian.Controls.Library
|
||||
value.MyContent.Changed += new ContentInfoEvent(MyContent_Changed);
|
||||
}
|
||||
}
|
||||
public StepItem ActiveParent
|
||||
{
|
||||
get { return _MyParentStepItem!=null ? _MyParentStepItem : _MyPreviousStepItem.ActiveParent; }
|
||||
}
|
||||
void MyContent_Changed(object sender)
|
||||
{
|
||||
// Update the text to reflect the content change
|
||||
@ -205,6 +209,7 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
break;
|
||||
case ChildRelation.RNO:
|
||||
TabFormat = "";
|
||||
if (RNOLevel <= _MyStepPanel.MaxRNO)
|
||||
{
|
||||
int colR = _MyStepPanel.ToDisplay(_MyStepSectionLayoutData.ColRTable, Convert.ToInt32(_MyStepSectionLayoutData.PMode) - 1);
|
||||
@ -216,7 +221,6 @@ namespace Volian.Controls.Library
|
||||
TextLocation = new Point(_MyParentStepItem.TextLeft, _MyParentStepItem.BottomMostStepItem.Bottom);
|
||||
}
|
||||
// Same size as the Parent
|
||||
TabFormat = "";
|
||||
TextWidth = _MyParentStepItem.TextWidth;
|
||||
break;
|
||||
case ChildRelation.Before:
|
||||
@ -437,9 +441,11 @@ namespace Volian.Controls.Library
|
||||
get
|
||||
{
|
||||
StepItem tmpr = null; // BottomMost RNO
|
||||
if ((MyExpandingStatus != ExpandingStatus.No || Expanded) && _MyRNOStepItems != null) tmpr = _MyRNOStepItems[_MyRNOStepItems.Count - 1].BottomMostStepItem;
|
||||
if ((MyExpandingStatus != ExpandingStatus.No || Expanded) && _MyRNOStepItems != null)
|
||||
tmpr = _MyRNOStepItems[_MyRNOStepItems.Count - 1].BottomMostStepItem;
|
||||
StepItem tmpa = this; // BottomMost After
|
||||
if ((MyExpandingStatus != ExpandingStatus.No || Expanded) & _MyAfterStepItems != null) tmpa = _MyAfterStepItems[_MyAfterStepItems.Count - 1].BottomMostStepItem;
|
||||
if ((MyExpandingStatus != ExpandingStatus.No || Expanded) & _MyAfterStepItems != null)
|
||||
tmpa = _MyAfterStepItems[_MyAfterStepItems.Count - 1].BottomMostStepItem;
|
||||
// return the bottom most of the two results
|
||||
if (tmpr == null)
|
||||
return tmpa;
|
||||
@ -579,6 +585,16 @@ namespace Volian.Controls.Library
|
||||
{
|
||||
//// TIMING: DisplayItem.TimeIt("CSLARTB Top");
|
||||
InitializeComponent();// TODO: Performance 25%
|
||||
SetupStepItem(itemInfo, myStepPanel, myParentStepItem, myChildRelation, expand, null);
|
||||
}
|
||||
public StepItem(ItemInfo itemInfo, StepPanel myStepPanel, StepItem myParentStepItem, ChildRelation myChildRelation, bool expand, StepItem nextStepItem)
|
||||
{
|
||||
//// TIMING: DisplayItem.TimeIt("CSLARTB Top");
|
||||
InitializeComponent();// TODO: Performance 25%
|
||||
SetupStepItem(itemInfo, myStepPanel, myParentStepItem, myChildRelation, expand, nextStepItem);
|
||||
}
|
||||
private void SetupStepItem(ItemInfo itemInfo, StepPanel myStepPanel, StepItem myParentStepItem, ChildRelation myChildRelation, bool expand, StepItem nextStepItem)
|
||||
{
|
||||
_MyStepRTB.MyStepItem = this;
|
||||
//// TIMING: DisplayItem.TimeIt("CSLARTB InitComp");
|
||||
BackColor = myStepPanel.PanelColor;
|
||||
@ -631,14 +647,14 @@ namespace Volian.Controls.Library
|
||||
switch (myChildRelation)
|
||||
{
|
||||
case ChildRelation.After:
|
||||
AddItem(myParentStepItem, ref myParentStepItem._MyAfterStepItems);
|
||||
AddItem(myParentStepItem, ref myParentStepItem._MyAfterStepItems,nextStepItem);
|
||||
break;
|
||||
case ChildRelation.Before:
|
||||
AddItem(myParentStepItem, ref myParentStepItem._MyBeforeStepItems);
|
||||
AddItem(myParentStepItem, ref myParentStepItem._MyBeforeStepItems, nextStepItem);
|
||||
break;
|
||||
case ChildRelation.RNO:
|
||||
RNOLevel = myParentStepItem.RNOLevel + 1;
|
||||
AddItem(myParentStepItem, ref myParentStepItem._MyRNOStepItems);
|
||||
AddItem(myParentStepItem, ref myParentStepItem._MyRNOStepItems, nextStepItem);
|
||||
break;
|
||||
case ChildRelation.None:
|
||||
break;
|
||||
@ -695,19 +711,34 @@ namespace Volian.Controls.Library
|
||||
/// </summary>
|
||||
/// <param name="parentStepItem">Parent Container</param>
|
||||
/// <param name="siblingStepItems">StepItem List</param>
|
||||
public void AddItem(StepItem parentStepItem, ref List<StepItem> siblingStepItems)
|
||||
public void AddItem(StepItem parentStepItem, ref List<StepItem> siblingStepItems, StepItem nextStepItem)
|
||||
{
|
||||
if (siblingStepItems == null)
|
||||
if (siblingStepItems == null) // Create a list of siblings
|
||||
{
|
||||
siblingStepItems = new List<StepItem>();
|
||||
siblingStepItems.Add(this);
|
||||
MyParentStepItem = parentStepItem;
|
||||
}
|
||||
else
|
||||
else // Add to the existing list
|
||||
{
|
||||
StepItem lastChild = LastChild(siblingStepItems);
|
||||
siblingStepItems.Add(this);
|
||||
MyPreviousStepItem = lastChild;
|
||||
if (nextStepItem == null) // Add to the end of the list
|
||||
{
|
||||
StepItem lastChild = LastChild(siblingStepItems);
|
||||
siblingStepItems.Add(this);
|
||||
MyPreviousStepItem = lastChild;
|
||||
}
|
||||
else // Add to the middle of the list before a particular item
|
||||
{
|
||||
StepItem prevChild = nextStepItem.MyPreviousStepItem;
|
||||
StepItem parent = nextStepItem.MyParentStepItem;
|
||||
siblingStepItems.Insert(siblingStepItems.IndexOf(nextStepItem), this);
|
||||
MyStepPanel.ItemMoving++;
|
||||
MyPreviousStepItem = prevChild;// If a previous exists - this will adjust the location and width of the StepItem
|
||||
nextStepItem.MyParentStepItem = null;
|
||||
MyParentStepItem = parent; // If a parent exists - this will adjust the location and width of the StepItem
|
||||
nextStepItem.MyPreviousStepItem = this;
|
||||
MyStepPanel.ItemMoving--;
|
||||
}
|
||||
}
|
||||
TabFormat = TemporaryFormat.TabFormat(this);
|
||||
}
|
||||
@ -770,21 +801,117 @@ namespace Volian.Controls.Library
|
||||
/// </summary>
|
||||
/// <param name="MyItemInfo"></param>
|
||||
/// <param name="expand"></param>
|
||||
public void AddChildAfter(ItemInfo MyItemInfo, bool expand)
|
||||
public StepItem AddChildAfter(ItemInfo MyItemInfo, bool expand)
|
||||
{
|
||||
StepItem child = new StepItem(MyItemInfo, _MyStepPanel, this, ChildRelation.After, expand);
|
||||
child.RNOLevel = this.RNOLevel;
|
||||
return child;
|
||||
}
|
||||
public StepItem AddChildAfter(ItemInfo MyItemInfo, StepItem nextStepItem)
|
||||
{
|
||||
StepItem child = new StepItem(MyItemInfo, _MyStepPanel, this, ChildRelation.After, true, nextStepItem);
|
||||
return child;
|
||||
}
|
||||
public StepItem AddChildBefore(ItemInfo MyItemInfo, StepItem nextStepItem)
|
||||
{
|
||||
StepItem child = new StepItem(MyItemInfo, _MyStepPanel, this, ChildRelation.Before, true, nextStepItem);
|
||||
return child;
|
||||
}
|
||||
public StepItem AddChildRNO(ItemInfo MyItemInfo, StepItem nextStepItem)
|
||||
{
|
||||
StepItem child = new StepItem(MyItemInfo, _MyStepPanel, this, ChildRelation.RNO, true, nextStepItem);
|
||||
return child;
|
||||
}
|
||||
/// <summary>
|
||||
/// Adds a sibling after the current StepItem
|
||||
/// </summary>
|
||||
public void AddSiblingAfter()
|
||||
{
|
||||
ItemInfo newItemInfo = MyItemInfo.InsertSiblingAfter("");
|
||||
StepItem newStepItem = null;
|
||||
switch (_MyChildRelation)
|
||||
{
|
||||
case ChildRelation.After:
|
||||
newStepItem = ActiveParent.AddChildAfter(newItemInfo, MyNextStepItem);
|
||||
break;
|
||||
case ChildRelation.Before:
|
||||
newStepItem = ActiveParent.AddChildBefore(newItemInfo, MyNextStepItem);
|
||||
break;
|
||||
case ChildRelation.RNO:
|
||||
newStepItem = ActiveParent.AddChildRNO(newItemInfo, MyNextStepItem);
|
||||
break;
|
||||
default: // Need debug
|
||||
break;
|
||||
}
|
||||
//StepItem newStepItem = ActiveParent.AddChildAfter(newItemInfo, );
|
||||
_MyStepPanel.SelectedStepRTB = newStepItem.MyStepRTB;//Update Screen
|
||||
}
|
||||
public void AddSiblingBefore()
|
||||
{
|
||||
ItemInfo newItemInfo = MyItemInfo.InsertSiblingBefore("");
|
||||
StepItem newStepItem=null;
|
||||
switch (_MyChildRelation)
|
||||
{
|
||||
case ChildRelation.After:
|
||||
newStepItem = ActiveParent.AddChildAfter(newItemInfo, this);
|
||||
break;
|
||||
case ChildRelation.Before:
|
||||
newStepItem = ActiveParent.AddChildBefore(newItemInfo, this);
|
||||
break;
|
||||
case ChildRelation.RNO:
|
||||
newStepItem = ActiveParent.AddChildRNO(newItemInfo, this);
|
||||
break;
|
||||
default: // Need debug
|
||||
break;
|
||||
}
|
||||
_MyStepPanel.SelectedStepRTB = newStepItem.MyStepRTB;//Update Screen
|
||||
}
|
||||
public void AddChild(E_FromType fromType, int type)
|
||||
{
|
||||
ItemInfo newItemInfo = MyItemInfo.InsertChild(fromType,type,"");
|
||||
// TODO: We need to determine where this will go in the stack of children
|
||||
StepItem nextItem = MyStepPanel.FindItem(newItemInfo.NextItem);
|
||||
StepItem newStepItem;
|
||||
switch (fromType)
|
||||
{
|
||||
case E_FromType.Caution:
|
||||
newStepItem = this.AddChildBefore(newItemInfo, nextItem);
|
||||
break;
|
||||
case E_FromType.Note:
|
||||
newStepItem = this.AddChildBefore(newItemInfo, nextItem);
|
||||
break;
|
||||
case E_FromType.Procedure:
|
||||
newStepItem = this.AddChildAfter(newItemInfo, nextItem);
|
||||
break;
|
||||
case E_FromType.RNO:
|
||||
newStepItem = this.AddChildRNO(newItemInfo, nextItem);
|
||||
break;
|
||||
case E_FromType.Section:
|
||||
newStepItem = this.AddChildAfter(newItemInfo, nextItem);
|
||||
break;
|
||||
case E_FromType.Step:
|
||||
newStepItem = this.AddChildAfter(newItemInfo, nextItem);
|
||||
break;
|
||||
case E_FromType.Table:
|
||||
newStepItem = this.AddChildAfter(newItemInfo, nextItem);
|
||||
break;
|
||||
default:
|
||||
newStepItem = this.AddChildAfter(newItemInfo, nextItem);
|
||||
break;
|
||||
}
|
||||
_MyStepPanel.SelectedStepRTB = newStepItem.MyStepRTB;//Update Screen
|
||||
}
|
||||
/// <summary>
|
||||
/// Add a list of children after
|
||||
/// </summary>
|
||||
/// <param name="myItemInfoList"></param>
|
||||
/// <param name="expand"></param>
|
||||
public void AddChildAfter(ItemInfoList myItemInfoList, bool expand)
|
||||
public StepItem AddChildAfter(ItemInfoList myItemInfoList, bool expand)
|
||||
{
|
||||
StepItem child = null;
|
||||
if (myItemInfoList != null)
|
||||
foreach (ItemInfo item in myItemInfoList)
|
||||
AddChildAfter(item, expand);
|
||||
child = AddChildAfter(item, expand);
|
||||
return child;
|
||||
}
|
||||
#endregion
|
||||
#region Event Handlers
|
||||
@ -854,7 +981,10 @@ namespace Volian.Controls.Library
|
||||
/// <param name="e"></param>
|
||||
private void StepItem_Resize(object sender, EventArgs e)
|
||||
{
|
||||
if (MyStepRTB.Text.EndsWith("\n"))
|
||||
Console.WriteLine("Added a new line to {0}", MyID);
|
||||
if (_MyItemInfo == null) return;
|
||||
//Console.WriteLine("{0} Resize - {1}, BottomMost {2}", MyID, MyPath,BottomMostStepItem.MyPath);
|
||||
AdjustLocation();
|
||||
}
|
||||
/// <summary>
|
||||
@ -897,8 +1027,17 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
_Moving = false;
|
||||
StepItem btm = BottomMostStepItem;
|
||||
if(this != btm)btm.AdjustLocation();
|
||||
if(this != btm)
|
||||
btm.AdjustLocation();
|
||||
}
|
||||
|
||||
//private StepItem FindBottomMost()
|
||||
//{
|
||||
// StepItem btm = BottomMostStepItem;
|
||||
// //if(btm.MyID != MyID)
|
||||
// // Console.WriteLine("Item {0} - BottomMost {1}", MyPath, btm.MyPath);
|
||||
// return btm;
|
||||
//}
|
||||
/// <summary>
|
||||
/// Handle the LinkGoTO event
|
||||
/// </summary>
|
||||
@ -1174,17 +1313,16 @@ namespace Volian.Controls.Library
|
||||
/// <summary>
|
||||
/// Adjust the Location of all items below the current item.
|
||||
/// </summary>
|
||||
private void AdjustLocation()
|
||||
internal void AdjustLocation()
|
||||
{
|
||||
StepItem tmp = NextDownStepItem;
|
||||
if (tmp == null) return;
|
||||
// Debug to show when this is called
|
||||
// vlnStackTrace.ShowStack("{0} From {1} to {2}", tmp.MyPath, tmp.Top, Bottom);
|
||||
// Console.WriteLine("{0} From {1} to {2}", tmp.MyPath, tmp.Top, Bottom);
|
||||
if (tmp != null && !tmp.Moving && tmp.Top != Bottom)
|
||||
//int bottom = BottomMostStepItem.Bottom;
|
||||
int bottom = Bottom;
|
||||
if (tmp != null && !tmp.Moving && tmp.Top != bottom)
|
||||
{
|
||||
_MyStepPanel.ItemMoving++;
|
||||
tmp.Top = Bottom;
|
||||
tmp.Top = bottom;
|
||||
_MyStepPanel.ItemMoving--;
|
||||
}
|
||||
}
|
||||
@ -1273,34 +1411,40 @@ namespace Volian.Controls.Library
|
||||
{
|
||||
get
|
||||
{
|
||||
StepItem tmp = this;
|
||||
if (tmp.MyNextStepItem == null && FirstSiblingStepItem._MyChildRelation == ChildRelation.Before && tmp._MyAfterStepItems == null)
|
||||
StepItem stepItem = this;
|
||||
// If this item appears before it's parent, and it doesn't have anything below it, return the parent
|
||||
if (MyNextStepItem == null && MyAfterStepItems == null && FirstSiblingStepItem._MyChildRelation == ChildRelation.Before)
|
||||
return UpOneStepItem;
|
||||
if (Expanded && tmp._MyAfterStepItems != null)// check to see if there is a _After
|
||||
return tmp._MyAfterStepItems[0].TopMostStepItem;// if there is go that way
|
||||
while (tmp != null && tmp.MyNextStepItem == null) // if no Next walk up the parent path
|
||||
if (Expanded && _MyAfterStepItems != null)// check to see if there is a _After
|
||||
return MyAfterStepItems[0].TopMostStepItem;// if there is go that way
|
||||
if (Expanded && MyRNOStepItems != null && MyItemInfo.RNOLevel >= MyItemInfo.Columns - 1)// check to see if there is a _After
|
||||
return MyRNOStepItems[0].TopMostStepItem;// if there is go that way
|
||||
while (stepItem != null && stepItem.MyNextStepItem == null) // if no Next walk up the parent path
|
||||
{
|
||||
tmp = tmp.UpOneStepItem;
|
||||
if (tmp == null) // No Parent
|
||||
stepItem = stepItem.UpOneStepItem;
|
||||
if (stepItem == null) // No Parent
|
||||
return null;
|
||||
if (tmp.MyExpandingStatus == ExpandingStatus.Expanding || tmp.Moving) // Parent Expanding or Moving - Wait
|
||||
if (stepItem.MyExpandingStatus == ExpandingStatus.Expanding || stepItem.Moving) // Parent Expanding or Moving - Wait
|
||||
return null;
|
||||
if (tmp.MyNextStepItem == null && tmp.FirstSiblingStepItem._MyChildRelation == ChildRelation.Before)
|
||||
return tmp.UpOneStepItem;
|
||||
StepItem btm = tmp.BottomMostStepItem;
|
||||
if (this != btm)
|
||||
if (stepItem.MyNextStepItem == null && stepItem.FirstSiblingStepItem._MyChildRelation == ChildRelation.Before)
|
||||
return stepItem.UpOneStepItem;
|
||||
StepItem btm = stepItem.BottomMostStepItem; // Find the Bottom StepItem of this ancestor
|
||||
if (this != btm) // If this is not the bottom, then just adjust things with respect to the bottom
|
||||
{
|
||||
if (tmp.MyNextStepItem != null && tmp.MyNextStepItem.TopMostStepItem.Top != btm.Bottom)
|
||||
StepItem btmNext = btm.NextDownStepItem;
|
||||
//if (stepItem.MyNextStepItem != null && stepItem.MyNextStepItem.TopMostStepItem.Top != btm.Bottom)
|
||||
if (btmNext != null && btmNext.Top != btm.Bottom)
|
||||
{
|
||||
_MyStepPanel.ItemMoving++;
|
||||
tmp.MyNextStepItem.TopMostStepItem.Top = btm.Bottom;
|
||||
//stepItem.MyNextStepItem.TopMostStepItem.Top = btm.Bottom;
|
||||
btmNext.Top = btm.Bottom;
|
||||
_MyStepPanel.ItemMoving--;
|
||||
}
|
||||
return null; // Not the bottom - don't adjust anything else
|
||||
}
|
||||
}
|
||||
if (tmp != null)
|
||||
return tmp.MyNextStepItem.TopMostStepItem;// if no _After - check to see if there is a Next
|
||||
if (stepItem != null)
|
||||
return stepItem.MyNextStepItem.TopMostStepItem;// if no _After - check to see if there is a Next
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -59,6 +59,11 @@ namespace Volian.Controls.Library
|
||||
get { return _vwMode; }
|
||||
set { _vwMode = value; }
|
||||
}
|
||||
private VE_Font _MyStyleFont;
|
||||
public VE_Font MyStyleFont
|
||||
{
|
||||
get { return _origDisplayText.TextFont; }
|
||||
}
|
||||
private ItemInfo _MyItemInfo;
|
||||
public ItemInfo MyItemInfo
|
||||
{
|
||||
@ -71,12 +76,28 @@ namespace Volian.Controls.Library
|
||||
//_InitializingRTB = true;
|
||||
DisplayText vlntxt = new DisplayText(_MyItemInfo, EpMode, VwMode);
|
||||
_origDisplayText = vlntxt;
|
||||
Font = _origDisplayText.TextFont.WindowsFont;
|
||||
//Font = _origDisplayText.TextFont.WindowsFont;
|
||||
|
||||
Text = ""; // Initialize text before add text
|
||||
//if (_MyStepItem.MyID == 168)
|
||||
// IMPORTANT: SetLineSpacing must be set before Link/protect, otherwise it
|
||||
// was confusing the 'handle' of the rtf box.
|
||||
RTBAPI.SetLineSpacing(this, RTBAPI.ParaSpacing.PFS_EXACT);
|
||||
|
||||
//SelectionStart = 1;
|
||||
AddRtfText(vlntxt);
|
||||
//AddRtfStyles();
|
||||
ReadOnly = !(EpMode == E_EditPrintMode.Edit && VwMode == E_ViewMode.Edit);
|
||||
RTBAPI.SetLineSpacing(this, RTBAPI.ParaSpacing.PFS_EXACT);
|
||||
if (_MyStepItem.MyID == 168)
|
||||
RTBAPI.SetLineSpacing(this, RTBAPI.ParaSpacing.PFS_EXACT);
|
||||
if (_MyStepItem.MyID == 168)
|
||||
Console.WriteLine("After Linespacing\r\n {0}", Rtf);
|
||||
//if (((_origDisplayText.TextFont.Style & E_Style.Bold) != 0) || ((_origDisplayText.TextFont.Style & E_Style.MmBold) != 0))
|
||||
// RTBAPI.ToggleBold(true, this, RTBAPI.RTBSelection.SCF_ALL);
|
||||
//if ((_origDisplayText.TextFont.Style & E_Style.Italics) != 0)
|
||||
// RTBAPI.ToggleItalic(true, this, RTBAPI.RTBSelection.SCF_ALL);
|
||||
//if ((_origDisplayText.TextFont.Style & E_Style.Underline) != 0)
|
||||
// RTBAPI.ToggleUnderline(true, this, RTBAPI.RTBSelection.SCF_ALL);
|
||||
//_InitializingRTB = false;
|
||||
_IsDirty = false;
|
||||
ClearUndo();
|
||||
@ -213,6 +234,7 @@ namespace Volian.Controls.Library
|
||||
if (inRoAdd)
|
||||
Console.WriteLine("SelectionStart {0}, SelectionLength {1}", SelectionStart, SelectionLength);
|
||||
if (!SelectionProtected && MyLinkText != null) MyLinkText = null;
|
||||
|
||||
}
|
||||
#endregion
|
||||
#region ApplicationSupport
|
||||
@ -281,6 +303,7 @@ namespace Volian.Controls.Library
|
||||
#region AddRtfTextAndStyles
|
||||
private void AddRtfText(DisplayText myDisplayText)
|
||||
{
|
||||
AddFontTable();
|
||||
foreach (displayTextElement vte in myDisplayText.DisplayTextElementList)
|
||||
{
|
||||
if (vte.Type == E_TextElementType.Text)
|
||||
@ -290,41 +313,142 @@ namespace Volian.Controls.Library
|
||||
else
|
||||
AddRtfLink((displayLinkElement)vte);
|
||||
}
|
||||
if (_MyStepItem.MyID == 168)
|
||||
Console.WriteLine("_SelectedRtbSB\r\n {0}", _SelectedRtfSB.ToString());
|
||||
SelectedRtf = _SelectedRtfSB.ToString() + "}";
|
||||
if (_MyStepItem.MyID == 168)
|
||||
Console.WriteLine("Rtf\r\n {0}", Rtf);
|
||||
//if (_LinkPosition > -1)
|
||||
FormatLinks();
|
||||
}
|
||||
|
||||
private void FormatLinks()
|
||||
{
|
||||
if (_LinkLocations != null)
|
||||
{
|
||||
foreach (LinkLocation ll in _LinkLocations)
|
||||
{
|
||||
Select(ll.Position, ll.Length);
|
||||
|
||||
RTBAPI.CharFormatTwo charFormat = RTBAPI.GetCharFormat(this, RTBAPI.RTBSelection.SCF_SELECTION);
|
||||
// Protect the link text to avoid manual changes
|
||||
charFormat.dwMask = RTBAPI.CharFormatMasks.CFM_LINK | RTBAPI.CharFormatMasks.CFM_PROTECTED;
|
||||
charFormat.dwEffects = RTBAPI.CharFormatEffects.CFE_LINK | RTBAPI.CharFormatEffects.CFE_PROTECTED;
|
||||
RTBAPI.SetCharFormat((RichTextBox)this, RTBAPI.RTBSelection.SCF_SELECTION, charFormat);
|
||||
//charFormat.dwMask = /* RTBAPI.CharFormatMasks.CFM_LINK | */ RTBAPI.CharFormatMasks.CFM_PROTECTED;
|
||||
//charFormat.dwEffects = /* RTBAPI.CharFormatEffects.CFE_LINK | */ RTBAPI.CharFormatEffects.CFE_PROTECTED;
|
||||
//RTBAPI.SetCharFormat((RichTextBox)this, RTBAPI.RTBSelection.SCF_SELECTION, charFormat);
|
||||
}
|
||||
}
|
||||
}
|
||||
private StringBuilder _SelectedRtfSB = new StringBuilder();
|
||||
|
||||
private void AddFontTable()
|
||||
{
|
||||
StringBuilder sbbeg = new StringBuilder();
|
||||
StringBuilder sbend = new StringBuilder();
|
||||
if (Font.Bold)
|
||||
{
|
||||
sbbeg.Append(@"\b");
|
||||
sbend.Append(@"\b0");
|
||||
}
|
||||
if (Font.Underline)
|
||||
{
|
||||
sbbeg.Append(@"\ul");
|
||||
sbend.Insert(0, @"\ulnone");
|
||||
}
|
||||
if (Font.Italic)
|
||||
{
|
||||
sbbeg.Append(@"\i");
|
||||
sbend.Insert(0, @"\i0");
|
||||
}
|
||||
_SelectedRtfSB.Append(@"{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset2 " + this.Font.FontFamily.Name + @";}"); //}\f0\fs" + this.Font.SizeInPoints * 2 + @" " + myDisplayTextElement.Text + @"}}";
|
||||
_SelectedRtfSB.Append(@"{\f1\fnil\fcharset0 Arial Unicode MS;}}");
|
||||
_SelectedRtfSB.Append("\r\n");
|
||||
// use styles to construct rtf commands to insert into next line (where \b is)
|
||||
_SelectedRtfSB.Append(@"\viewkind4\uc1\pard\sl-240\slmult0" + sbbeg.ToString() + @"\fs" + this.Font.SizeInPoints * 2 + @" "); // \f0\fs" + this.Font.SizeInPoints * 2 + @" " + myDisplayTextElement.Text + @"}";
|
||||
//SelectedRtf = _SelectedRtfSB.ToString();
|
||||
}
|
||||
private void AddRtf(displayTextElement myDisplayTextElement)
|
||||
{
|
||||
SelectedRtf = @"{\rtf1{\fonttbl{\f0\fcharset2 "+this.Font.FontFamily.Name+@";}}\f0\fs" + this.Font.SizeInPoints*2 + " " + myDisplayTextElement.Text + @"}}";
|
||||
// try later, i.e. adding bold to font name: SelectedRtf = @"{\rtf1{\fonttbl{\f0\fcharset2 " + this.Font.FontFamily.Name + @",Bold;}}\f0\fs" + this.Font.SizeInPoints * 2 + @" " + myDisplayTextElement.Text + @"}}";
|
||||
//SelectedRtf = @"{\rtf1{\fonttbl{\f0\fcharset2 " + this.Font.FontFamily.Name + @";}}\f0\fs" + this.Font.SizeInPoints * 2 + @" " + myDisplayTextElement.Text + @"}}";
|
||||
//_SelectedRtfSB.Append(@"\f0\fs" + this.Font.SizeInPoints * 2 + @" " + myDisplayTextElement.Text); // + @"}");
|
||||
_SelectedRtfSB.Append(@"\f0 " + myDisplayTextElement.Text); // + @"}");
|
||||
}
|
||||
private void AddRtf(string str)
|
||||
{
|
||||
SelectedRtf = @"{\rtf1{\fonttbl{\f0\fcharset2 " + this.Font.FontFamily.Name + @";}}\f0\fs" + this.Font.SizeInPoints * 2 + " " + str + @"}}";
|
||||
SelectedText = str;
|
||||
// SelectedRtf = @"{\rtf1{\fonttbl{\f0\fcharset2 " + this.Font.FontFamily.Name + @";}}\f0\fs" + this.Font.SizeInPoints * 2 + @" " + str + @"}}";
|
||||
}
|
||||
private void AddSymbol(displayTextElement myDisplayTextElement)
|
||||
{
|
||||
SelectedRtf = @"{\rtf1{\fonttbl{\f0\fcharset0 Arial Unicode MS;}}\f0\fs" + this.Font.SizeInPoints * 2 + " " + myDisplayTextElement.Text + @"}";
|
||||
//_SelectedRtfSB.Append(@"\f1\fs" + this.Font.SizeInPoints * 2 + @" " + myDisplayTextElement.Text);
|
||||
_SelectedRtfSB.Append(@"\f1 " + myDisplayTextElement.Text);
|
||||
//SelectedRtf = @"{\rtf1{\fonttbl{\f0\fcharset0 Arial Unicode MS;}}\f0\fs" + this.Font.SizeInPoints * 2 + @" " + myDisplayTextElement.Text + @"}";
|
||||
}
|
||||
private void AddSymbol(string str)
|
||||
{
|
||||
//MessageBox.Show(SelectedRtf);
|
||||
SelectedRtf = @"{\rtf1{\fonttbl{\f0\fcharset0 Arial Unicode MS;}}\f0\fs" + this.Font.SizeInPoints * 2 + " " + /* ConvertUnicodeChar(str) */ str + @"}";
|
||||
Font selfont = this.SelectionFont;
|
||||
StringBuilder sbbeg = new StringBuilder();
|
||||
StringBuilder sbend = new StringBuilder();
|
||||
if (selfont.Bold)
|
||||
{
|
||||
sbbeg.Append(@"\b");
|
||||
sbend.Append(@"\b0");
|
||||
}
|
||||
if (selfont.Underline)
|
||||
{
|
||||
sbbeg.Append(@"\ul");
|
||||
sbend.Insert(0,@"\ulnone");
|
||||
}
|
||||
if (selfont.Italic)
|
||||
{
|
||||
sbbeg.Append(@"\i");
|
||||
sbend.Insert(0, @"\i0");
|
||||
}
|
||||
if (sbend.Length > 0) sbbeg.Append(" ");
|
||||
|
||||
// sub/superscript???
|
||||
SelectedRtf = @"{\rtf1{\fonttbl{\f0\fcharset0 Arial Unicode MS;}}\f0\fs" + this.Font.SizeInPoints * 2 + @" " + sbbeg.ToString() + str + sbend.ToString() + @"}";
|
||||
}
|
||||
private List<LinkLocation> _LinkLocations = null;
|
||||
private void AddLinkLocation(string location, string url)
|
||||
{
|
||||
SelectedRtf = _SelectedRtfSB.ToString() + "}";
|
||||
int linkPosition = this.TextLength;
|
||||
this.Text = "";
|
||||
if (_LinkLocations == null) _LinkLocations = new List<LinkLocation>();
|
||||
_LinkLocations.Add(new LinkLocation(linkPosition, location.Length + url.Length));
|
||||
}
|
||||
private int _LinkPosition = -1;
|
||||
private int _LinkLength;
|
||||
private void AddRtfLink(displayLinkElement myDisplayLinkElement)
|
||||
{
|
||||
if (CreateParams.ClassName == "RICHEDIT50W")
|
||||
|
||||
AddLink50(myDisplayLinkElement.Text, myDisplayLinkElement.Link);
|
||||
else
|
||||
|
||||
AddLink20(myDisplayLinkElement.Text, myDisplayLinkElement.Link);
|
||||
{
|
||||
AddLinkLocation(myDisplayLinkElement.Text, myDisplayLinkElement.Link);
|
||||
_SelectedRtfSB.Append(@"\f0\fs20 ");
|
||||
_SelectedRtfSB.Append(myDisplayLinkElement.Text);
|
||||
_SelectedRtfSB.Append(@"\v ");
|
||||
_SelectedRtfSB.Append(myDisplayLinkElement.Link);
|
||||
_SelectedRtfSB.Append(@"\v0 ");
|
||||
//_SelectedRtfSB.Append(@"\sl-240\slmult0\f0\fs20 0POP05-EO-ES00, REDIAGNOSIS, COVER\v #Link:Transition:5 7 198\v0");
|
||||
//AddLink20(myDisplayLinkElement.Text, myDisplayLinkElement.Link);
|
||||
}
|
||||
}
|
||||
public void AddRtfLink(string linkUrl, string linkValue)
|
||||
{
|
||||
if (CreateParams.ClassName == "RICHEDIT50W")
|
||||
//if (CreateParams.ClassName == "RICHEDIT50W")
|
||||
|
||||
AddLink50(linkUrl, linkValue);
|
||||
else
|
||||
//AddLink50(linkUrl, linkValue);
|
||||
//else
|
||||
|
||||
AddLink20(linkUrl, linkValue);
|
||||
//AddLink20(linkUrl, linkValue);
|
||||
}
|
||||
private void AddLink20(string linkValue, string linkUrl)
|
||||
{
|
||||
@ -332,13 +456,15 @@ namespace Volian.Controls.Library
|
||||
RTBAPI.CharFormatTwo charFormat = RTBAPI.GetCharFormat(this, RTBAPI.RTBSelection.SCF_SELECTION);
|
||||
int position = SelectionStart; // before inserttran = this.TextLength;
|
||||
SelectionLength = 0;
|
||||
SelectedRtf = @"{\rtf1\ansi " + linkValue + @"\v " + linkUrl + @"\v0}";
|
||||
//SelectedRtf = @"{\rtf1\ansi " + linkValue + @"\v " + linkUrl + @"\v0}";
|
||||
SelectedRtf = linkValue + @"\v " + linkUrl + @"\v0";
|
||||
Select(position, linkValue.Length + linkUrl.Length);
|
||||
// Protect the link text to avoid manual changes
|
||||
charFormat.dwMask = RTBAPI.CharFormatMasks.CFM_LINK | RTBAPI.CharFormatMasks.CFM_PROTECTED;
|
||||
charFormat.dwEffects = RTBAPI.CharFormatEffects.CFE_LINK | RTBAPI.CharFormatEffects.CFE_PROTECTED;
|
||||
RTBAPI.SetCharFormat((RichTextBox)this, RTBAPI.RTBSelection.SCF_SELECTION, charFormat);
|
||||
this.SelectionStart = this.TextLength;
|
||||
// \protect\fs20 0POP05-EO-ES00, REDIAGNOSIS, COVER\v #Link:Transition:5 7 198\protect0\v0
|
||||
this.SelectionLength = 0;
|
||||
}
|
||||
private void AddLink50(string linkValue, string linkUrl)
|
||||
@ -355,7 +481,6 @@ namespace Volian.Controls.Library
|
||||
if ((_origDisplayText.TextFont.Style & E_Style.Bold) > 0)
|
||||
{
|
||||
this.SelectAll();
|
||||
|
||||
RTBAPI.ToggleBold(true, this, RTBAPI.RTBSelection.SCF_SELECTION);
|
||||
this.Select(0, 0);
|
||||
}
|
||||
@ -662,8 +787,14 @@ namespace Volian.Controls.Library
|
||||
if (e.KeyChar == '\b') return; // return on backspace otherwise, get a block char
|
||||
if (e.KeyChar == '-')
|
||||
AddSymbol(@"\u8209?");
|
||||
else if (e.KeyChar == '{')
|
||||
AddRtf("\\{");
|
||||
else if (e.KeyChar == '}')
|
||||
AddRtf("\\}");
|
||||
else if (e.KeyChar == '[')
|
||||
AddRtf(@"\b ");
|
||||
else
|
||||
AddRtf(e.KeyChar.ToString());
|
||||
return; // AddRtf(e.KeyChar.ToString());
|
||||
e.Handled = true; // flag that it's been handled, otherwise, will get 2 chars.
|
||||
}
|
||||
IsControlChar = false;
|
||||
@ -801,4 +932,27 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
#region LinkLocation Class
|
||||
internal class LinkLocation
|
||||
{
|
||||
private int _Position;
|
||||
public int Position
|
||||
{
|
||||
get { return _Position; }
|
||||
set { _Position = value; }
|
||||
}
|
||||
private int _Length;
|
||||
public int Length
|
||||
{
|
||||
get { return _Length; }
|
||||
set { _Length = value; }
|
||||
}
|
||||
|
||||
public LinkLocation(int position, int length)
|
||||
{
|
||||
_Position = position;
|
||||
_Length = length;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
BIN
PROMS/Volian.Controls.Library/StepTabRibbon.designer.cs
generated
BIN
PROMS/Volian.Controls.Library/StepTabRibbon.designer.cs
generated
Binary file not shown.
@ -128,6 +128,15 @@
|
||||
t0ekztKvaA7ibixOyvoLADqYiGMXHIUWy7uQa+cSuZGUDb7FswWYwclx9oES/hqzGAmV1UTdSPiQ8Uqw
|
||||
DCdiNtgFHwAtVpjbIvESaA4ZqUrP2xELFPEBUMwlqmH7iDiNNQAph2DskIMaIF16YfCVIoZOmtyveQF9
|
||||
2CVVWYKhQwAAAABJRU5ErkJggg==
|
||||
</value>
|
||||
</data>
|
||||
<data name="btnInsRO.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
|
||||
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAlwSFlzAAAScQAA
|
||||
EnEB89x6jgAAAIBJREFUOE/FU9ESgCAIy///aAMU0DDYSxecV6KOObB1squRs3VyNY1Z4OWHATYTFHI1
|
||||
gp0RXdm+vlGoLC5zPowCHDeiAGkmhMHnAEFpDwwRjcFKV++/6xyLVgEk2UfhnuVTNsVBa5Njk8xV6c1k
|
||||
hNwGBmaHAP5n4G8q6gFdoZLjBpE7j5KJdaRlAAAAAElFTkSuQmCC
|
||||
</value>
|
||||
</data>
|
||||
<data name="btnListUsers.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
@ -178,15 +187,6 @@
|
||||
EnEB89x6jgAAAIBJREFUOE/FU9ESgCAIy///aAMU0DDYSxecV6KOObB1squRs3VyNY1Z4OWHATYTFHI1
|
||||
gp0RXdm+vlGoLC5zPowCHDeiAGkmhMHnAEFpDwwRjcFKV++/6xyLVgEk2UfhnuVTNsVBa5Njk8xV6c1k
|
||||
hNwGBmaHAP5n4G8q6gFdoZLjBpE7j5KJdaRlAAAAAElFTkSuQmCC
|
||||
</value>
|
||||
</data>
|
||||
<data name="btnInsRO.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
|
||||
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAlwSFlzAAAScQAA
|
||||
EnEB89x6jgAAAIBJREFUOE/FU9ESgCAIy///aAMU0DDYSxecV6KOObB1squRs3VyNY1Z4OWHATYTFHI1
|
||||
gp0RXdm+vlGoLC5zPowCHDeiAGkmhMHnAEFpDwwRjcFKV++/6xyLVgEk2UfhnuVTNsVBa5Njk8xV6c1k
|
||||
hNwGBmaHAP5n4G8q6gFdoZLjBpE7j5KJdaRlAAAAAElFTkSuQmCC
|
||||
</value>
|
||||
</data>
|
||||
<data name="btnCMCut.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
|
Loading…
x
Reference in New Issue
Block a user