This commit is contained in:
2009-02-04 13:18:19 +00:00
parent c3ea5c84f9
commit 408ba2ff26
2 changed files with 257 additions and 46 deletions

View File

@@ -581,6 +581,151 @@ namespace Volian.Controls.Library
}
}
#endregion
#region Cursor Movement Methods
/// <summary>
/// Finds the Displayed 'top' child for a given item. Used for down arrow.
/// </summary>
/// <param name="ii">ItemInfo</param>
/// <returns></returns>
private ItemInfo TopPart(ItemInfo ii)
{
ExpandAsNeeded(ii);
if (ii.Cautions != null) return TopPart(ii.Cautions[0]);
if (ii.Notes != null) return TopPart(ii.Notes[0]);
return (ii);
}
/// <summary>
/// Finds the Displayed 'bottom' child for a given item. Used for up arrow.
/// </summary>
/// <param name="ii">ItemInfo</param>
/// <returns></returns>
private ItemInfo BottomPart(ItemInfo ii)
{
ExpandAsNeeded(ii);
if (ii.RNOs != null && ii.RNOLevel >= ii.Columns - 1) return BottomPart(ii.RNOs[0]);
if (ii.Sections != null) return BottomPart(ii.Sections[0].LastSibling);
if (ii.Steps != null) return BottomPart(ii.Steps[0].LastSibling);
return ii;
}
/// <summary>
/// Supports cursor movement between richtext boxes, including arrow keys/page up,down/
/// ctrl Home,End
/// </summary>
/// <param name="rtb">StepRTB</param>
/// <param name="position">Point</param>
/// <param name="arrow">E_ArrowKeys</param>
public void CursorMovement(StepRTB rtb, Point position, E_ArrowKeys arrow)
{
ItemInfo ii = null;
switch (arrow)
{
case E_ArrowKeys.Up:
case E_ArrowKeys.CtrlUp:
ii = ArrowUp(rtb.MyItemInfo);
if (ii != null) SelectedStepRTB = _LookupStepItems[ii.ItemID].MyStepRTB;
break;
case E_ArrowKeys.Down:
case E_ArrowKeys.CtrlDown:
ii = ArrowDown(rtb.MyItemInfo);
if (ii != null) SelectedStepRTB = _LookupStepItems[ii.ItemID].MyStepRTB;
break;
case E_ArrowKeys.Right:
case E_ArrowKeys.CtrlRight:
if (rtb.MyItemInfo.RNOs != null)
SelectedStepRTB = _LookupStepItems[rtb.MyItemInfo.RNOs[0].ItemID].MyStepRTB;
break;
case E_ArrowKeys.Left:
case E_ArrowKeys.CtrlLeft:
if (!rtb.MyItemInfo.IsProcedure)
SelectedStepRTB = _LookupStepItems[rtb.MyItemInfo.MyParent.ItemID].MyStepRTB;
break;
default:
break;
}
}
private ItemInfo ArrowUp(ItemInfo ii)
{
// if on RNO, check display mode (1 column/2 column, etc) and how deep RNO is before going to
// parents substeps.
if (ii.IsRNO && ii.MyParent.Steps != null && ii.RNOLevel >= ii.Columns) return BottomPart(ii.MyParent.Steps[0].LastSibling);
// If on top note and parent has cautions - go to bottom caution
if (ii.IsNoteStructure && ii.MyParent != null && ii.MyParent.Cautions != null) return BottomPart(ii.MyParent.Cautions[0].LastSibling);
if (ii.IsCautionStructure || ii.IsNoteStructure)
{
if (ii.MyParent.MyPrevious != null) return BottomPart(ii.MyParent.MyPrevious);
return ii.MyParent.MyParent;
}
// If has note, BottomPart of last sibling of the note
if (ii.Notes != null) return BottomPart(ii.Notes[0].LastSibling);
// If has caution, BottomPart of last sibling of the caution
if (ii.Cautions != null) return BottomPart(ii.Cautions[0].LastSibling);
// If previous sibling, BottomPart of previous sibling
if (ii.MyPrevious != null) return BottomPart(ii.MyPrevious);
// Go to parent until at procedure
if (!ii.IsProcedure) return (ii.MyParent);
return null;
}
private ItemInfo ArrowDown(ItemInfo ii)
{
return ArrowDown(ii, true, true);
}
private ItemInfo ArrowDown(ItemInfo ii, bool lookAtSub, bool lookAtRNO)
{
if (ii.IsSection || ii.IsProcedure)
{
if (lookAtSub && ii.Sections != null) return TopPart(ii.Sections[0]);
if (lookAtSub && ii.Steps != null) return TopPart(ii.Steps[0]);
if (ii.IsSection && ii.NextItems != null) return TopPart(ii.NextItems[0]);
}
else
{
// Subitems - go to top part of subitem
// (the lookAtSub prevented looping within a substep group at same level)
if (lookAtSub && ii.Steps != null) return TopPart(ii.Steps[0]);
// RNOs: Use PMode (column)
if (lookAtRNO && ii.RNOs != null && ii.RNOLevel >= ii.Columns - 1) return TopPart(ii.RNOs[0]);
// Nextsibling - go to top part of sibling
if (ii.NextItems != null) return TopPart(ii.NextItems[0]);
// If on caution, if parent has note - go to note
if (ii.IsCautionStructureFirstSib && ii.MyParent.Notes != null) return ii.MyParent.Notes[0];
// If on caution, if parent !has note or if on note go to parent
if ((ii.IsCautionStructureFirstSib && ii.MyParent.Notes == null) || ii.IsNoteStructureFirstSib) return ii.MyParent;
// Recursively call with parent until at procedure
if (!ii.IsProcedure) return (ArrowDown(ii.MyParent, false, ii.MyParent.RNOLevel==ii.RNOLevel));
}
return null;
}
internal void StepCursorKeys(StepRTB rtb, KeyEventArgs keyargs)
{
ItemInfo ii = rtb.MyItemInfo;
if (ii.IsSection || ii.IsProcedure) return;
while (!ii.IsHigh)
{
ii = ii.MyParent;
}
switch (keyargs.KeyCode)
{
// for home/end, control key must be pressed too, but this is checked
// before here.
case Keys.Home:
ii = ii.FirstSibling;
break;
case Keys.End:
ii = ii.LastSibling;
break;
case Keys.PageDown:
ii = ii.NextItems == null ? null : ii.NextItems[0];
break;
case Keys.PageUp:
ii = ii.MyPrevious;
break;
}
if (ii == null) return;
SelectedStepRTB = _LookupStepItems[ii.ItemID].MyStepRTB;
}
#endregion
}
[TypeConverter(typeof(ExpandableObjectConverter))]
public partial class StepPanelSettings
@@ -813,7 +958,7 @@ namespace Volian.Controls.Library
private LinkText _MyLinkText;
public LinkText MyLinkText
{
get { return _MyLinkText; }
get { return _MyLinkText;}
}
public StepPanelLinkEventArgs(StepItem linkedStepItem, string linkInfoText)
{