This commit is contained in:
2009-03-05 16:06:24 +00:00
parent 768561ca7a
commit f44e6162ec
5 changed files with 588 additions and 100 deletions

View File

@@ -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;
}
}