Fixed code to correctly position Tables

Fixed code that inserts a table to point to existing substeps
This commit is contained in:
Rich 2010-10-12 19:54:48 +00:00
parent a62793b1d5
commit c9ab8919f0

View File

@ -318,57 +318,17 @@ namespace Volian.Controls.Library
{ {
get { return _LastMethods.Count == 0; } get { return _LastMethods.Count == 0; }
} }
private void ShowMe(string method)
{
//if (MyID < _StartingID) return;
//if (MyID == 2129)
// Console.WriteLine("2129");
if ((LastMethodsEmpty || _LookForID.Contains(MyID)) && _MyStepPanel != null) // jsj added check for null _MyStepPanel
{
Console.WriteLine("{0}{1}\t\"{2}\"\t{3}\t{4}\t{5}\t{6}\t\"{7}\"\t\"{8}\"\t\"{9}\""
, "", MyID, method, Top, Bottom
, FindTop(0), FindRight()
, LastMethodsEmpty ? _MyStepPanel._LastAdjust : _LastMethods.Peek(), this
, _NextDownStepItemPath);
//vlnStackTrace.ShowStackLocal(string.Format("ShowMe {0}",MyID),3, 8);
//vlnStackTrace.ShowStack();
//vlnStackTrace.ScrollInStack();
}
}
/// <summary> /// <summary>
/// This should find the item that precedes the current item vertically /// This should find the item that precedes the current item vertically
/// and then return the Bottom of that item. /// and then return the Bottom of that item.
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
private int FindTop()
{
//if (MyStepPanel._LookupStepItems.ContainsKey(2118))
//{
// StepItem MyPrevious = MyStepPanel._LookupStepItems[2118];
// if (MyID >= 2120) return MyPrevious.Bottom;
//}
int? bottomRNO = BottomOfParentRNO();
if (bottomRNO != null) return (int)bottomRNO;
if(_MyNextStepItem == null)return _MyParentStepItem.Top;
return min(MyParentStepItem.Top,_MyNextStepItem.Top);
}
private int FindTop(int bottom) private int FindTop(int bottom)
{ {
int lastBottomPrev = bottom; // This is necessary if the value of bottom can be negative. int lastBottomPrev = bottom; // This is necessary if the value of bottom can be negative.
//int lastBottomPrev = 0;
//int lastBottomParent = 0;
if (_MyPreviousStepItem != null) if (_MyPreviousStepItem != null)
lastBottomPrev = _MyPreviousStepItem.BottomMostStepItem.Bottom; lastBottomPrev = _MyPreviousStepItem.BottomMostStepItem.Bottom;
//else if(_MyParentStepItem != null) int? bottomRNO = BottomOfParentRNO();
// lastBottomParent = MyParentStepItem.BottomMostStepItem.Bottom;
int? bottomRNO = BottomOfParentRNO();
//if (MyID == 2123)
// Console.WriteLine("Oops! {0},{1}", bottomRNO, bottom);
//if (lastBottom != bottom)
//if(MyID > _StartingID)
// Console.WriteLine("{0}\t{1}\t{2}\t{3}\t{4}", MyID, lastBottomPrev,lastBottomParent, bottom, bottomRNO);
//if (MyID == 2125)
// Console.WriteLine("Oops!");
if (lastBottomPrev > bottom) bottom = (int)(lastBottomPrev); // RHM 20090615 ES02 Step8 if (lastBottomPrev > bottom) bottom = (int)(lastBottomPrev); // RHM 20090615 ES02 Step8
// Moving from Step 8 to the Note preceeding step 8 caused the step 9 to be positioned in the wrong place. // Moving from Step 8 to the Note preceeding step 8 caused the step 9 to be positioned in the wrong place.
//if (lastBottomParent > bottom) bottom = lastBottomParent; //if (lastBottomParent > bottom) bottom = lastBottomParent;
@ -1322,10 +1282,12 @@ namespace Volian.Controls.Library
ItemInfo newItemInfo = MyItemInfo.InsertChild(fromType, type, text); ItemInfo newItemInfo = MyItemInfo.InsertChild(fromType, type, text);
// TODO: We need to determine where this will go in the stack of children // TODO: We need to determine where this will go in the stack of children
StepItem nextItem = null; StepItem nextItem = null;
if(newItemInfo.NextItem != null) if (newItemInfo.NextItem != null)
nextItem = MyStepPanel.FindItem(newItemInfo.NextItem); nextItem = MyStepPanel.FindItem(newItemInfo.NextItem);
else if (fromType == E_FromType.Table && MyAfterStepItems != null)
nextItem = MyAfterStepItems[0];
// Cautions come before notes, so if this is a Caution and there are Notes, put this first // Cautions come before notes, so if this is a Caution and there are Notes, put this first
else if(fromType == E_FromType.Caution && ((ItemInfo)newItemInfo.ActiveParent).Notes != null else if (fromType == E_FromType.Caution && ((ItemInfo)newItemInfo.ActiveParent).Notes != null
&& ((ItemInfo)newItemInfo.ActiveParent).Notes.Count > 0) && ((ItemInfo)newItemInfo.ActiveParent).Notes.Count > 0)
nextItem = MyStepPanel.FindItem(((ItemInfo)newItemInfo.ActiveParent).Notes[0]); nextItem = MyStepPanel.FindItem(((ItemInfo)newItemInfo.ActiveParent).Notes[0]);
// TODO: May need similar logic if a Table is being added to a step that has substeps // TODO: May need similar logic if a Table is being added to a step that has substeps
@ -1628,10 +1590,6 @@ namespace Volian.Controls.Library
/// <param name="e"></param> /// <param name="e"></param>
private void StepItem_Resize(object sender, EventArgs e) private void StepItem_Resize(object sender, EventArgs e)
{ {
//ShowMe("Resize");
if (MyStepRTB.Text.EndsWith("\n"))
if (!_LookForID.Contains(MyID))
_LookForID.Add(MyID);
if (_MyItemInfo == null) return; if (_MyItemInfo == null) return;
if (_IgnoreResize) return; if (_IgnoreResize) return;
AdjustLocation(); AdjustLocation();
@ -1902,10 +1860,10 @@ namespace Volian.Controls.Library
// Calulate the x location // Calulate the x location
//int x = myParentStepItem.TextLeft; //int x = myParentStepItem.TextLeft;
int x = center - width / 2; int x = center - width / 2;
int y = FindTop(myParentStepItem.Bottom);
if (x + width > rightLimit) x = rightLimit - width; if (x + width > rightLimit) x = rightLimit - width;
int colT = _MyStepPanel.ToDisplay(myStepSectionLayoutData.ColT); int colT = _MyStepPanel.ToDisplay(myStepSectionLayoutData.ColT);
if (x < colT) x = colT; if (x < colT) x = colT;
int y = FindTop(myParentStepItem.Bottom);
return new Point(x, y); return new Point(x, y);
} }
/// <summary> /// <summary>
@ -2255,8 +2213,6 @@ namespace Volian.Controls.Library
} }
public int? BottomOfParentRNO() public int? BottomOfParentRNO()
{ {
//if (MyID > 2124) return null;
// Console.WriteLine("Ooops!!!");
int? bottom = null; int? bottom = null;
StepItem stepItem = this; StepItem stepItem = this;
if (!MyItemInfo.IsTablePart) if (!MyItemInfo.IsTablePart)
@ -2271,15 +2227,13 @@ namespace Volian.Controls.Library
if (stepItem == null || stepItem._MyChildRelation == ChildRelation.None) if (stepItem == null || stepItem._MyChildRelation == ChildRelation.None)
return null; return null;
StepItem parent = stepItem.UpOneStepItem; StepItem parent = stepItem.UpOneStepItem;
//if (parent != null) parent = parent.UpOneStepItem;
//if (_WatchThis > 0)
// Console.WriteLine("watch this");
int right = FindRight(); int right = FindRight();
bool centeredTable = (MyItemInfo.IsTablePart && MyItemInfo.FormatStepData.Type.Contains("AER") == false && MyItemInfo.RNOLevel == 0);
while (parent != null && parent.MyItemInfo.IsSection == false) while (parent != null && parent.MyItemInfo.IsSection == false)
{ {
if (parent._MyRNOStepItems != null) if (parent._MyRNOStepItems != null)
{ {
if (right > parent._MyRNOStepItems[0].Left) if (centeredTable || right > parent._MyRNOStepItems[0].Left)
{ {
if(parent._MyRNOStepItems[0].BottomMostStepItem.RNOLevel > RNOLevel && RNOLevel < _MyItemInfo.ColumnMode) if(parent._MyRNOStepItems[0].BottomMostStepItem.RNOLevel > RNOLevel && RNOLevel < _MyItemInfo.ColumnMode)
bottom = max(bottom, parent._MyRNOStepItems[0].BottomMostStepItem.Bottom); bottom = max(bottom, parent._MyRNOStepItems[0].BottomMostStepItem.Bottom);
@ -2289,8 +2243,6 @@ namespace Volian.Controls.Library
} }
return bottom; return bottom;
} }
private static List<int> _LookForID = new List<int>();
private static int _StartingID = 2114;
private string _NextDownStepItemPath = "None"; private string _NextDownStepItemPath = "None";
/// <summary> /// <summary>
/// This finds the next StepItem down. /// This finds the next StepItem down.
@ -2299,8 +2251,6 @@ namespace Volian.Controls.Library
{ {
get get
{ {
//if (_WatchThis > 0 && MyID == _LookForID)
// Console.WriteLine("{0}NextDownStepID {1} {2}",WatchThisIndent, MyID, this);
StepItem stepItem = this; StepItem stepItem = this;
_NextDownStepItemPath = "Path 1"; _NextDownStepItemPath = "Path 1";
// If this item appears before it's parent, and it doesn't have anything below it, return the parent // If this item appears before it's parent, and it doesn't have anything below it, return the parent