Update to logic to position step items
This commit is contained in:
parent
fe2cd765f0
commit
5fe81af184
@ -170,6 +170,7 @@ namespace Volian.Controls.Library
|
||||
get { return _MyParentStepItem; }
|
||||
set
|
||||
{
|
||||
LastMethodsPush("set_MyParentStepItem");
|
||||
_MyParentStepItem = value;
|
||||
if (_MyParentStepItem != null)
|
||||
{
|
||||
@ -210,31 +211,125 @@ namespace Volian.Controls.Library
|
||||
break;
|
||||
case ChildRelation.RNO:
|
||||
TabFormat = "";
|
||||
if (RNOLevel <= _MyStepPanel.MaxRNO)
|
||||
_IgnoreResize = true;
|
||||
TextWidth = _MyParentStepItem.TextWidth;
|
||||
_IgnoreResize = false;
|
||||
if (RNOLevel <= _MyItemInfo.ColumnMode)
|
||||
{
|
||||
int colR = _MyStepPanel.ToDisplay(_MyStepSectionLayoutData.ColRTable, Convert.ToInt32(_MyStepSectionLayoutData.PMode) - 1);
|
||||
if (colR - _MyParentStepItem.Width < 0) colR = _MyParentStepItem.Width + 0;
|
||||
_MyStepPanel.ItemMoving++;
|
||||
//Left = _MyParentStepItem.ItemLeft + RNOLevel * colR;
|
||||
//ItemLocation = new Point(_MyParentStepItem.ItemLeft + RNOLevel * colR, _MyParentStepItem.Top);
|
||||
ItemLocation = new Point(_MyParentStepItem.ItemLeft + RNOLevel * colR, _MyParentStepItem.Top);
|
||||
int top = _MyParentStepItem.FindTop(_MyParentStepItem.Top);
|
||||
if (top != _MyParentStepItem.Top)
|
||||
{
|
||||
_MyParentStepItem.LastMethodsPush(string.Format("set_MyParentStepItem RNO {0}", MyID));
|
||||
_MyParentStepItem.Top = top;
|
||||
Top = top;
|
||||
_MyParentStepItem.LastMethodsPop();
|
||||
}
|
||||
_MyStepPanel.ItemMoving--;
|
||||
}
|
||||
else
|
||||
{
|
||||
_MyStepPanel.ItemMoving++;
|
||||
TextLocation = new Point(_MyParentStepItem.TextLeft, _MyParentStepItem.BottomMostStepItem.Bottom);
|
||||
//TextLocation = new Point(_MyParentStepItem.TextLeft, FindTop(_MyParentStepItem.Top));
|
||||
_MyStepPanel.ItemMoving--;
|
||||
}
|
||||
// Same size as the Parent
|
||||
TextWidth = _MyParentStepItem.TextWidth;
|
||||
break;
|
||||
case ChildRelation.Before:
|
||||
Location = new Point(_MyParentStepItem.Left + 20, _MyParentStepItem.Top);
|
||||
_MyStepPanel.ItemMoving++;
|
||||
_MyParentStepItem.Top = Bottom;
|
||||
_MyStepPanel.ItemMoving--;
|
||||
// Could be a Caution or Note - Need to get WidT
|
||||
//if(_WatchThis > 0 && MyID > 2111)
|
||||
// Console.WriteLine("Setting MyParent: \r\n\tParent {0},{1} \r\n\tTopMostItem {2},{3} \r\n\tNext {4}, {5}", _MyParentStepItem.MyID, _MyParentStepItem
|
||||
// ,_MyParentStepItem.TopMostStepItem.MyID,_MyParentStepItem.TopMostStepItem
|
||||
// , _MyNextStepItem == null ? 0 : _MyNextStepItem.MyID, _MyNextStepItem == null ? "None" : _MyNextStepItem.ToString());
|
||||
|
||||
//Location = new Point(_MyParentStepItem.Left + 20, max(_MyParentStepItem.Top, (_MyNextStepItem == null ? 0 : _MyNextStepItem.Top )) ?? 0);
|
||||
_IgnoreResize = true;
|
||||
Width = _MyStepPanel.ToDisplay(_MyStepSectionLayoutData.WidT);
|
||||
_IgnoreResize = false;
|
||||
_MyStepPanel.ItemMoving++;
|
||||
Location = new Point(_MyParentStepItem.Left + 20, FindTop(_MyParentStepItem.Top));
|
||||
_MyStepPanel.ItemMoving--;
|
||||
//_MyParentStepItem.Top = Bottom;
|
||||
// Could be a Caution or Note - Need to get WidT
|
||||
break;
|
||||
}
|
||||
}
|
||||
LastMethodsPop();
|
||||
}
|
||||
}
|
||||
private Stack<string> _LastMethods= new Stack<string>();
|
||||
//private string _LastMethod = "";
|
||||
private void LastMethodsPush(string str)
|
||||
{
|
||||
_MyStepPanel._LastAdjust = str;
|
||||
_LastMethods.Push(str);
|
||||
}
|
||||
private string LastMethodsPop()
|
||||
{
|
||||
//_MyStepPanel._LastAdjust = "";
|
||||
return _LastMethods.Pop();
|
||||
}
|
||||
private bool LastMethodsEmpty
|
||||
{
|
||||
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))
|
||||
{
|
||||
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.ShowStack();
|
||||
//vlnStackTrace.ScrollInStack();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// This should find the item that precedes the current item vertically
|
||||
/// and then return the Bottom of that item.
|
||||
/// </summary>
|
||||
/// <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)
|
||||
{
|
||||
int? lastBottomPrev = 0;
|
||||
int? lastBottomParent = 0;
|
||||
if (_MyPreviousStepItem != null)
|
||||
lastBottomPrev = _MyPreviousStepItem.BottomMostStepItem.Bottom;
|
||||
else if(_MyParentStepItem != null)
|
||||
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 (bottomRNO == null) return bottom;
|
||||
return (int) max(bottomRNO, bottom);
|
||||
}
|
||||
/// <summary>
|
||||
/// The left edge of the Tab
|
||||
/// </summary>
|
||||
@ -342,6 +437,7 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
lblTab.Text = tabString;
|
||||
lblTab.Width = tabString.Length * 8;
|
||||
Invalidate();
|
||||
_MyStepRTB.Left = lblTab.Left + lblTab.Width;// +2;
|
||||
_MyStepRTB.Width = Width - _MyStepRTB.Left;
|
||||
// TODO: Performance - SetToolTip();
|
||||
@ -368,11 +464,23 @@ namespace Volian.Controls.Library
|
||||
get { return _MyPreviousStepItem; }
|
||||
set
|
||||
{
|
||||
LastMethodsPush("set_MyPreviousStepItem");
|
||||
_MyPreviousStepItem = value;
|
||||
if (_MyPreviousStepItem != null)
|
||||
{
|
||||
Location = new Point(_MyPreviousStepItem.Left, _MyPreviousStepItem.BottomMostStepItem.Bottom);
|
||||
_IgnoreResize=true;
|
||||
Width = MyPreviousStepItem.Width;
|
||||
_IgnoreResize=false;
|
||||
//ShowMe("");
|
||||
//if (MyID > _StartingID)
|
||||
// Console.WriteLine("{0}-->Setting MyPreviousStepItem {1},{2},{3},{4},{5},{6},{7}", WatchThisIndent, MyID, this
|
||||
// , _MyPreviousStepItem
|
||||
// ,Top
|
||||
// , _MyPreviousStepItem.BottomMostStepItem.Bottom
|
||||
// , FindTop(_MyPreviousStepItem.BottomMostStepItem.Bottom)
|
||||
// , _MyPreviousStepItem.Bottom);
|
||||
//Location = new Point(_MyPreviousStepItem.Left, _MyPreviousStepItem.BottomMostStepItem.Bottom);
|
||||
Location = new Point(_MyPreviousStepItem.Left, FindTop(_MyPreviousStepItem.BottomMostStepItem.Bottom));
|
||||
switch (_MyChildRelation)
|
||||
{
|
||||
case ChildRelation.None:
|
||||
@ -382,13 +490,14 @@ namespace Volian.Controls.Library
|
||||
case ChildRelation.RNO:
|
||||
break;
|
||||
case ChildRelation.Before:
|
||||
_MyStepPanel.ItemMoving++;
|
||||
UpOneStepItem.Top = BottomMostStepItem.Bottom;
|
||||
_MyStepPanel.ItemMoving--;
|
||||
//_MyStepPanel.ItemMoving++;
|
||||
//UpOneStepItem.Top = BottomMostStepItem.Bottom;
|
||||
//_MyStepPanel.ItemMoving--;
|
||||
break;
|
||||
}
|
||||
if (_MyPreviousStepItem.MyNextStepItem != this) _MyPreviousStepItem.MyNextStepItem = this;
|
||||
}
|
||||
LastMethodsPop();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
@ -441,15 +550,22 @@ namespace Volian.Controls.Library
|
||||
get
|
||||
{
|
||||
StepItem tmpr = null; // BottomMost RNO
|
||||
if ((MyExpandingStatus != ExpandingStatus.No || Expanded) && _MyRNOStepItems != null)
|
||||
//int rnoOffset = 0;
|
||||
if ((MyExpandingStatus != ExpandingStatus.No || Expanded) && _MyRNOStepItems != null)
|
||||
{
|
||||
//rnoOffset = this.Top - _MyRNOStepItems[0].Top;
|
||||
tmpr = _MyRNOStepItems[_MyRNOStepItems.Count - 1].BottomMostStepItem;
|
||||
}
|
||||
StepItem tmpa = this; // BottomMost After
|
||||
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;
|
||||
if (tmpa.Bottom >= tmpr.Bottom)
|
||||
//if (rnoOffset > 0)
|
||||
//Console.WriteLine("RNO Bottom Offset {0}", rnoOffset);
|
||||
//if (tmpa.Bottom >= (tmpr.Bottom + rnoOffset))
|
||||
if (tmpa.Bottom >= (tmpr.Bottom))
|
||||
return tmpa;
|
||||
return tmpr;
|
||||
}
|
||||
@ -487,8 +603,14 @@ namespace Volian.Controls.Library
|
||||
/// </summary>
|
||||
public bool Expanded
|
||||
{
|
||||
get { return !_Colapsing && (MyExpandingStatus != ExpandingStatus.No || _MyvlnExpander.Expanded); }
|
||||
set { _MyvlnExpander.Expanded = value; }
|
||||
get
|
||||
{
|
||||
return !_Colapsing && (MyExpandingStatus != ExpandingStatus.No || _MyvlnExpander.Expanded);
|
||||
}
|
||||
set
|
||||
{
|
||||
_MyvlnExpander.Expanded = value;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Sets or Gets expanding status
|
||||
@ -665,6 +787,7 @@ namespace Volian.Controls.Library
|
||||
{
|
||||
if (_Type == 0 && _MyStepSectionLayoutData != null)
|
||||
{
|
||||
LastMethodsPush(string.Format("SetupStepItem {0}", MyID));
|
||||
Width = _MyStepPanel.ToDisplay(_MyStepSectionLayoutData.WidT);
|
||||
}
|
||||
}
|
||||
@ -701,6 +824,15 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
//// TIMING: DisplayItem.TimeIt("CSLARTB before Controls Add");
|
||||
//myStepPanel.Controls.Add(this);
|
||||
int top = FindTop(0);
|
||||
if (Top < top)
|
||||
{
|
||||
LastMethodsPush("SetupStepItem");
|
||||
_MyStepPanel.ItemMoving++;
|
||||
Top = top;
|
||||
_MyStepPanel.ItemMoving--;
|
||||
LastMethodsPop();
|
||||
}
|
||||
_Loading = false;
|
||||
//// TIMING: DisplayItem.TimeIt("CSLARTB Controls Add");
|
||||
}
|
||||
@ -733,14 +865,23 @@ namespace Volian.Controls.Library
|
||||
StepItem parent = nextStepItem.MyParentStepItem;
|
||||
siblingStepItems.Insert(siblingStepItems.IndexOf(nextStepItem), this);
|
||||
MyStepPanel.ItemMoving++;
|
||||
_MyNextStepItem = nextStepItem;
|
||||
nextStepItem._MyPreviousStepItem = this;
|
||||
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;
|
||||
//nextStepItem.MyPreviousStepItem = this;
|
||||
MyStepPanel.ItemMoving--;
|
||||
}
|
||||
}
|
||||
SetAllTabs();
|
||||
}
|
||||
|
||||
private void SetAllTabs()
|
||||
{
|
||||
TabFormat = TemporaryFormat.TabFormat(this);
|
||||
//Console.WriteLine("TabFormat {0},{1},{2},{3}", MyID, MyPath, lblTab.Text,MyItemInfo.Ordinal);
|
||||
if (_MyNextStepItem != null) _MyNextStepItem.SetAllTabs();
|
||||
}
|
||||
/// <summary>
|
||||
/// Add the next item to a list
|
||||
@ -845,6 +986,7 @@ namespace Volian.Controls.Library
|
||||
//StepItem newStepItem = ActiveParent.AddChildAfter(newItemInfo, );
|
||||
_MyStepPanel.SelectedStepRTB = newStepItem.MyStepRTB;//Update Screen
|
||||
}
|
||||
private static int _WatchThis = 1;
|
||||
public void AddSiblingBefore()
|
||||
{
|
||||
ItemInfo newItemInfo = MyItemInfo.InsertSiblingBefore("");
|
||||
@ -867,6 +1009,10 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
public void AddChild(E_FromType fromType, int type)
|
||||
{
|
||||
if (_MyItemInfo.IsHigh || _MyItemInfo.IsSection)
|
||||
this.CanExpand = true;
|
||||
this.Expanded = true;
|
||||
_WatchThis = 1;
|
||||
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);
|
||||
@ -931,7 +1077,14 @@ namespace Volian.Controls.Library
|
||||
/// <param name="args"></param>
|
||||
private void _StepRTB_HeightChanged(object sender, EventArgs args)
|
||||
{
|
||||
this.Height = _MyStepRTB.Height + 10;
|
||||
if (this.Height != _MyStepRTB.Height + 10)
|
||||
{
|
||||
//if (MyID == 2131 || MyID == 2132)
|
||||
// Console.WriteLine("oops!");
|
||||
LastMethodsPush(string.Format("_StepRTB_HeightChanged {0}", _MyStepRTB.Height));
|
||||
this.Height = _MyStepRTB.Height + 10;
|
||||
LastMethodsPop();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Handle the colape event
|
||||
@ -951,9 +1104,11 @@ namespace Volian.Controls.Library
|
||||
_ExpandSuffix = BottomMostStepItem.Bottom - Bottom;
|
||||
if (Top != top)
|
||||
{
|
||||
LastMethodsPush(string.Format("Colapse {0}", MyID));
|
||||
_MyStepPanel.ItemMoving++;
|
||||
Top = top;
|
||||
_MyStepPanel.ItemMoving--;
|
||||
LastMethodsPop();
|
||||
}
|
||||
else
|
||||
AdjustLocation();
|
||||
@ -974,6 +1129,7 @@ namespace Volian.Controls.Library
|
||||
Expand(_Type >= 20000);
|
||||
Cursor.Current = tmp;
|
||||
}
|
||||
bool _IgnoreResize = false;
|
||||
/// <summary>
|
||||
/// Adjust the locations when the StepItem is resized
|
||||
/// </summary>
|
||||
@ -981,12 +1137,30 @@ namespace Volian.Controls.Library
|
||||
/// <param name="e"></param>
|
||||
private void StepItem_Resize(object sender, EventArgs e)
|
||||
{
|
||||
ShowMe("Resize");
|
||||
if (MyStepRTB.Text.EndsWith("\n"))
|
||||
Console.WriteLine("Added a new line to {0}", MyID);
|
||||
if (!_LookForID.Contains(MyID))
|
||||
{
|
||||
//Console.WriteLine("{0} Added a CR",MyID);
|
||||
_LookForID.Add(MyID);
|
||||
}
|
||||
//if ((_WatchThis > 0 && MyID > 2100) || MyID == _LookForID)
|
||||
//{
|
||||
// Console.WriteLine("{0}Resize {1},{2}",WatchThisIndent, MyID, this);
|
||||
// if (MyID == _LookForID)
|
||||
// Console.WriteLine("{0}------------------------",WatchThisIndent);
|
||||
//}
|
||||
if (_MyItemInfo == null) return;
|
||||
//Console.WriteLine("{0} Resize - {1}, BottomMost {2}", MyID, MyPath,BottomMostStepItem.MyPath);
|
||||
//if (_lookForID == MyID)
|
||||
// _lookForID = MyID;
|
||||
if (_IgnoreResize) return;
|
||||
AdjustLocation();
|
||||
}
|
||||
private string WatchThisIndent
|
||||
{
|
||||
get { return "".PadLeft(_WatchThis, '\t'); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Handles movement of the StepItems
|
||||
/// </summary>
|
||||
@ -994,50 +1168,111 @@ namespace Volian.Controls.Library
|
||||
/// <param name="e"></param>
|
||||
private void StepItem_Move(object sender, EventArgs e)
|
||||
{
|
||||
if (_MyStepPanel.ItemMoving == 0) return; // If 0 - Indicates scrolling which requires no action.
|
||||
if (_MyItemInfo == null) return;
|
||||
if (MyExpandingStatus == ExpandingStatus.Expanding) return;
|
||||
_Moving = true;
|
||||
int watchThis = _WatchThis;
|
||||
//if (MyID == _lookForID || MyID == 2111)
|
||||
//{
|
||||
// //vlnStackTrace.ShowStack("{0} Move TO {1} - {2}, BottomMost {3}", MyID, Top, MyPath, BottomMostStepItem.MyPath);
|
||||
// Console.WriteLine("{0} Move TO {1} - {2}, BottomMost {3}", MyID, Top, MyPath, BottomMostStepItem.MyPath);
|
||||
//}
|
||||
//if (MyID > _StartingID)
|
||||
// Console.WriteLine("{0}--------------- {1} Top = {2} Bottom {3}", WatchThisIndent, MyID, Top, Bottom);
|
||||
if (_MyStepPanel.ItemMoving == 0)
|
||||
{
|
||||
//vlnStackTrace.ScrollInStack();
|
||||
return; // If 0 - Indicates scrolling which requires no action.
|
||||
}
|
||||
ShowMe("Move");
|
||||
if (_MyItemInfo == null)
|
||||
return;
|
||||
//if (_WatchThis > 0 && MyID > _StartingID)
|
||||
//{
|
||||
|
||||
// Console.WriteLine("{0}Start Move {1},{2}", WatchThisIndent, MyID, this);
|
||||
// if (MyID == _LookForID)
|
||||
// Console.WriteLine("{0}---------------", WatchThisIndent,MyID, this);
|
||||
// _WatchThis++;
|
||||
//}
|
||||
if (MyExpandingStatus == ExpandingStatus.Expanding)
|
||||
{
|
||||
_WatchThis=watchThis;
|
||||
return;
|
||||
}
|
||||
Moving = true;
|
||||
StepItem tmp = (StepItem)sender;
|
||||
if (tmp._MyPreviousStepItem == null && tmp._MyParentStepItem == null)
|
||||
{
|
||||
_WatchThis=watchThis;
|
||||
return;
|
||||
}
|
||||
AdjustLocation();
|
||||
if (RNOBelow) // Adjust substeps first
|
||||
{
|
||||
AdjustLocation();
|
||||
MoveRNO();
|
||||
}
|
||||
else // Adjust RNO First
|
||||
{
|
||||
MoveRNO();
|
||||
AdjustLocation();
|
||||
}
|
||||
Moving = false;
|
||||
StepItem btm = BottomMostStepItem;
|
||||
if(this != btm)
|
||||
btm.AdjustLocation();
|
||||
//if (_WatchThis > 0 && MyID > _StartingID)
|
||||
//{
|
||||
// Console.WriteLine("{0}Finish Move {1},{2}",WatchThisIndent, MyID, this);
|
||||
//}
|
||||
_WatchThis=watchThis;
|
||||
}
|
||||
private bool RNOBelow
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_MyRNOStepItems != null)
|
||||
{
|
||||
return _MyRNOStepItems[0].Left == Left;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
private bool RNORight
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_MyRNOStepItems != null)
|
||||
{
|
||||
return _MyRNOStepItems[0].Left != Left;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
private void MoveRNO()
|
||||
{
|
||||
if (_MyRNOStepItems != null)
|
||||
{
|
||||
if (_MyRNOStepItems[0].TopMostStepItem.Top != Top)
|
||||
{
|
||||
//if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("\r\n'Adjust RNO',{0},'Move',{1}", MyID, _RNO[0].MyID);
|
||||
if (RNOLevel >= _MyStepPanel.MaxRNO)
|
||||
StepItem rnoTop = _MyRNOStepItems[0].TopMostStepItem;
|
||||
rnoTop.LastMethodsPush(string.Format("StepItem_Move RNO {0}", MyID));
|
||||
if (RNOLevel >= _MyItemInfo.ColumnMode)
|
||||
{
|
||||
StepItem tmpBottom = this;
|
||||
if (_MyAfterStepItems != null) tmpBottom = _MyAfterStepItems[_MyAfterStepItems.Count - 1].BottomMostStepItem;
|
||||
_MyStepPanel.ItemMoving++;
|
||||
_MyRNOStepItems[0].TopMostStepItem.Top = tmpBottom.Bottom;
|
||||
rnoTop.Top = tmpBottom.Bottom;
|
||||
_MyStepPanel.ItemMoving--;
|
||||
}
|
||||
else
|
||||
{
|
||||
_MyStepPanel.ItemMoving++;
|
||||
_MyRNOStepItems[0].TopMostStepItem.Top = Top;
|
||||
rnoTop.Top = Top;
|
||||
_MyStepPanel.ItemMoving--;
|
||||
}
|
||||
rnoTop.LastMethodsPop();
|
||||
}
|
||||
}
|
||||
_Moving = false;
|
||||
StepItem btm = BottomMostStepItem;
|
||||
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>
|
||||
@ -1147,8 +1382,10 @@ namespace Volian.Controls.Library
|
||||
/// </summary>
|
||||
private void SetText()
|
||||
{
|
||||
LastMethodsPush("SetText");
|
||||
if (_MyItemInfo != null)
|
||||
this._MyStepRTB.MyItemInfo = _MyItemInfo;
|
||||
LastMethodsPop();
|
||||
}
|
||||
/// <summary>
|
||||
/// If the selected StepItem is within the window leave it as it is.
|
||||
@ -1305,9 +1542,9 @@ namespace Volian.Controls.Library
|
||||
{
|
||||
get
|
||||
{
|
||||
if(MyItemInfo.MyContent.Type >= 20000)
|
||||
if (MyItemInfo.MyContent.Type >= 20000)
|
||||
return MyItemInfo.Path.Substring(MyItemInfo.ActiveSection.Path.Length);
|
||||
return "";
|
||||
return MyItemInfo.MyContent.ToString();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
@ -1315,15 +1552,43 @@ namespace Volian.Controls.Library
|
||||
/// </summary>
|
||||
internal void AdjustLocation()
|
||||
{
|
||||
StepItem tmp = NextDownStepItem;
|
||||
if (tmp == null) return;
|
||||
//int bottom = BottomMostStepItem.Bottom;
|
||||
int bottom = Bottom;
|
||||
if (tmp != null && !tmp.Moving && tmp.Top != bottom)
|
||||
//if (RNORight) MoveRNO();
|
||||
StepItem nextStepItem = NextDownStepItem;
|
||||
//if (MyID == 2138)
|
||||
// Console.WriteLine("2138");
|
||||
//if (_WatchThis > 0 && MyID > _StartingID)
|
||||
//if((nextStepItem == null ? 0 : nextStepItem.MyID) == MyID)
|
||||
//if(_LookForID.Contains(MyID))
|
||||
// Console.WriteLine("{0}AdjustLocation {1},{2},{3} -> {4},{5} ({6}) {7}", WatchThisIndent, MyID, MyItemInfo.Ordinal, MyPath,
|
||||
// nextStepItem == null ? 0 : nextStepItem.MyID, nextStepItem == null ? 0 : nextStepItem.MyItemInfo.Ordinal, nextStepItem == null ? "Null" : nextStepItem.MyPath,
|
||||
// _NextDownStepItemPath);
|
||||
//if (_WatchThis && MyID == 2119)
|
||||
// Console.WriteLine("I'm here");
|
||||
//if (MyID > 2120)
|
||||
// Console.WriteLine("{0}\t{1}", MyID, nextStepItem == null ? 0 : nextStepItem.MyID);
|
||||
if (nextStepItem != null)
|
||||
{
|
||||
_MyStepPanel.ItemMoving++;
|
||||
tmp.Top = bottom;
|
||||
_MyStepPanel.ItemMoving--;
|
||||
//int bottom = BottomMostStepItem.Bottom;
|
||||
if (nextStepItem != null)
|
||||
{
|
||||
//if (MyID == 2123)
|
||||
// _LookForID = 2123;
|
||||
int bottom = nextStepItem.FindTop(Bottom);
|
||||
if (nextStepItem.Top != bottom)
|
||||
// if (nextStepItem != null && !nextStepItem.Moving && nextStepItem.Top != bottom)
|
||||
{
|
||||
_MyStepPanel.ItemMoving++;
|
||||
nextStepItem.LastMethodsPush(string.Format("AdjustLocation {0}",MyID));
|
||||
nextStepItem._NextDownStepItemPath = _NextDownStepItemPath;
|
||||
nextStepItem.Top = bottom;
|
||||
nextStepItem.LastMethodsPop();
|
||||
_MyStepPanel.ItemMoving--;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("{0}** No Adjustment next = {1}, moving = {2}", WatchThisIndent, nextStepItem, nextStepItem == null ? false : nextStepItem.Moving);
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
@ -1393,9 +1658,12 @@ namespace Volian.Controls.Library
|
||||
AddChildBefore(MyItemInfo.Notes, expand);
|
||||
AddChildAfter(MyItemInfo.Procedures, expand);
|
||||
AddChildAfter(MyItemInfo.Sections, expand);
|
||||
if (MyItemInfo.RNOs != null && MyItemInfo.RNOLevel < MyItemInfo.ColumnMode)
|
||||
AddChildRNO(MyItemInfo.RNOs, expand);
|
||||
AddChildAfter(MyItemInfo.Steps, expand);
|
||||
AddChildAfter(MyItemInfo.Tables, expand);
|
||||
AddChildRNO(MyItemInfo.RNOs, expand);
|
||||
if (MyItemInfo.RNOs != null && MyItemInfo.RNOLevel >= MyItemInfo.ColumnMode)
|
||||
AddChildRNO(MyItemInfo.RNOs, expand);
|
||||
if (!_MyvlnExpander.Expanded)
|
||||
_MyvlnExpander.ShowExpanded();
|
||||
}
|
||||
@ -1404,6 +1672,85 @@ namespace Volian.Controls.Library
|
||||
MyExpandingStatus = ExpandingStatus.No;
|
||||
//// TIMING: DisplayItem.TimeIt("Expand End");
|
||||
}
|
||||
public StepItem BeforeItem
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_MyAfterStepItems != null)
|
||||
{
|
||||
foreach (StepItem stepItem in _MyAfterStepItems)
|
||||
{
|
||||
if (stepItem._MyBeforeStepItems != null)
|
||||
return stepItem.TopMostStepItem;
|
||||
StepItem beforeItem = stepItem.BeforeItem;
|
||||
if (beforeItem != null) return beforeItem;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public StepItem ItemAbove
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_MyChildRelation == ChildRelation.Before) return _MyParentStepItem.ItemAbove;
|
||||
if (_MyPreviousStepItem != null) return _MyPreviousStepItem.BottomMostStepItem;
|
||||
if (_MyChildRelation == ChildRelation.After) return _MyParentStepItem;
|
||||
if (_MyChildRelation == ChildRelation.RNO) return _MyParentStepItem;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
private static int? max(int? value1, int value2)
|
||||
{
|
||||
if (value1 == null || value2 > value1) return value2;
|
||||
return value1;
|
||||
}
|
||||
private static int min(int value1, int value2)
|
||||
{
|
||||
if (value2 < value1) return value2;
|
||||
return value1;
|
||||
}
|
||||
public int FindRight()
|
||||
{
|
||||
if (!RNORight) return Right;
|
||||
return _MyRNOStepItems[0].FindRight();
|
||||
}
|
||||
public int? BottomOfParentRNO()
|
||||
{
|
||||
//if (MyID > 2124) return null;
|
||||
// Console.WriteLine("Ooops!!!");
|
||||
int? bottom = null;
|
||||
StepItem stepItem = this;
|
||||
if (stepItem._MyChildRelation == ChildRelation.None)
|
||||
return null;
|
||||
if (stepItem._MyChildRelation == ChildRelation.After && !RNORight)
|
||||
return null;
|
||||
while (stepItem != null && stepItem._MyChildRelation != ChildRelation.None && stepItem._MyChildRelation != ChildRelation.After)
|
||||
stepItem = stepItem.UpOneStepItem;
|
||||
if (stepItem == null || stepItem._MyChildRelation == ChildRelation.None)
|
||||
return null;
|
||||
StepItem parent = stepItem.UpOneStepItem;
|
||||
//if (parent != null) parent = parent.UpOneStepItem;
|
||||
//if (_WatchThis > 0)
|
||||
// Console.WriteLine("watch this");
|
||||
int right = FindRight();
|
||||
while (parent != null && parent.MyItemInfo.IsSection == false)
|
||||
{
|
||||
if (parent._MyRNOStepItems != null)
|
||||
{
|
||||
if (right > parent._MyRNOStepItems[0].Left)
|
||||
{
|
||||
if(parent._MyRNOStepItems[0].BottomMostStepItem.RNOLevel > RNOLevel && RNOLevel < _MyItemInfo.ColumnMode)
|
||||
bottom = max(bottom, parent._MyRNOStepItems[0].BottomMostStepItem.Bottom);
|
||||
}
|
||||
}
|
||||
parent = parent.UpOneStepItem;
|
||||
}
|
||||
return bottom;
|
||||
}
|
||||
private static List<int> _LookForID = new List<int>();
|
||||
private static int _StartingID = 2114;
|
||||
private string _NextDownStepItemPath = "None";
|
||||
/// <summary>
|
||||
/// This finds the next StepItem down.
|
||||
/// </summary>
|
||||
@ -1411,43 +1758,95 @@ namespace Volian.Controls.Library
|
||||
{
|
||||
get
|
||||
{
|
||||
StepItem stepItem = this;
|
||||
//if (_WatchThis > 0 && MyID == _LookForID)
|
||||
// Console.WriteLine("{0}NextDownStepID {1} {2}",WatchThisIndent, MyID, this);
|
||||
StepItem stepItem = this;
|
||||
_NextDownStepItemPath = "Path 1";
|
||||
// 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;
|
||||
_NextDownStepItemPath = "Path 2";
|
||||
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
|
||||
return MyAfterStepItems[0].TopMostStepItem;// if there is, go that way
|
||||
_NextDownStepItemPath = "Path 3";
|
||||
if (Expanded && MyRNOStepItems != null && MyItemInfo.RNOLevel >= MyItemInfo.ColumnMode)// 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
|
||||
{
|
||||
bool lastWasRNO = (stepItem._MyChildRelation == ChildRelation.RNO);
|
||||
stepItem = stepItem.UpOneStepItem;
|
||||
_NextDownStepItemPath = "Path 4";
|
||||
if (stepItem == null) // No Parent
|
||||
return null;
|
||||
_NextDownStepItemPath = string.Format("Path 5 {0}, {1}",stepItem.MyExpandingStatus,stepItem.Moving);
|
||||
if (stepItem.MyExpandingStatus == ExpandingStatus.Expanding || stepItem.Moving) // Parent Expanding or Moving - Wait
|
||||
return null;
|
||||
_NextDownStepItemPath = "Path 5 RNO";
|
||||
if (stepItem.RNOBelow && !Ancestor(stepItem.MyRNOStepItems[0]))
|
||||
return stepItem.MyRNOStepItems[0];
|
||||
_NextDownStepItemPath = "Path 6";
|
||||
if (stepItem.MyNextStepItem == null && stepItem.FirstSiblingStepItem._MyChildRelation == ChildRelation.Before)
|
||||
return stepItem.UpOneStepItem;
|
||||
StepItem btm = stepItem.BottomMostStepItem; // Find the Bottom StepItem of this ancestor
|
||||
StepItem beforeItem = stepItem.BeforeItem;
|
||||
if (lastWasRNO && beforeItem != null)
|
||||
{
|
||||
_NextDownStepItemPath = "Path 7";
|
||||
if (beforeItem.ItemAbove.Bottom > this.Bottom) return null;
|
||||
_NextDownStepItemPath = "Path 8";
|
||||
return beforeItem;
|
||||
}
|
||||
if (this != btm) // If this is not the bottom, then just adjust things with respect to the bottom
|
||||
{
|
||||
StepItem btmNext = btm.NextDownStepItem;
|
||||
//if (stepItem.MyNextStepItem != null && stepItem.MyNextStepItem.TopMostStepItem.Top != btm.Bottom)
|
||||
if (btmNext != null && btmNext.Top != btm.Bottom)
|
||||
if (btmNext != null)
|
||||
{
|
||||
int bottom = btmNext.FindTop(btm.Bottom);
|
||||
if(btmNext.Top != bottom)
|
||||
{
|
||||
_MyStepPanel.ItemMoving++;
|
||||
//stepItem.MyNextStepItem.TopMostStepItem.Top = btm.Bottom;
|
||||
btmNext.Top = btm.Bottom;
|
||||
//Console.WriteLine("{0}***Move in NextDownStepItem {1},{2} From {3} To {4}",WatchThisIndent, btmNext.MyID, btmNext, btmNext.Top, btm.Bottom);
|
||||
btmNext.LastMethodsPush(string.Format("NextDownStepItem {0} {1}", MyID, stepItem.MyID));
|
||||
//ShowMe(string.Format("FindTop = {0}", btmNext.FindTop(btm.Bottom)));
|
||||
btmNext.Top = bottom;
|
||||
btmNext.LastMethodsPop();
|
||||
_MyStepPanel.ItemMoving--;
|
||||
}
|
||||
}
|
||||
_NextDownStepItemPath = string.Format("Path 9 {0}",btm);
|
||||
return null; // Not the bottom - don't adjust anything else
|
||||
}
|
||||
//else
|
||||
//{
|
||||
//}
|
||||
}
|
||||
if (stepItem != null)
|
||||
return stepItem.MyNextStepItem.TopMostStepItem;// if no _After - check to see if there is a Next
|
||||
{
|
||||
// Need to verify that the bottom of the parents RNO does not excede the bottom of this item.
|
||||
StepItem next = stepItem.MyNextStepItem.TopMostStepItem;
|
||||
_NextDownStepItemPath = "Path A";
|
||||
//if (Bottom >= (BottomOfParentRNO(next) ?? Bottom))
|
||||
return next;// if no _After - check to see if there is a Next
|
||||
//_NextDownStepItemPath = "Path B";
|
||||
//return null;
|
||||
}
|
||||
_NextDownStepItemPath = "Path C";
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private bool Ancestor(StepItem stepItem)
|
||||
{
|
||||
if (MyID == stepItem.MyID) return true;
|
||||
if (MyItemInfo.IsHigh) return false;
|
||||
return UpOneStepItem.Ancestor(stepItem);
|
||||
}
|
||||
public override string ToString()
|
||||
{
|
||||
return _MyItemInfo == null ? base.ToString() : string.Format("({0}) {1}", MyID, MyPath); // + "-" + MyItemInfo.MyContent.Text;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user