B2017-175 The steps were being displayed with High-level steps and sections overlapping an expanded high-level step. The fix assures that high level steps and sections will be located vertically so that they don't overlap other steps.

This commit is contained in:
Rich 2017-08-18 12:43:45 +00:00
parent 086adde4c6
commit 88383ec87f

View File

@ -303,7 +303,7 @@ namespace Volian.Controls.Library
//private string _LastMethod = "";
internal void LastMethodsPush(string str)
{
if(MyStepPanel != null)MyStepPanel._LastAdjust = str;
if (MyStepPanel != null) MyStepPanel._LastAdjust = str;
_LastMethods.Push(str);
}
internal string LastMethodsPop()
@ -331,7 +331,7 @@ namespace Volian.Controls.Library
// whether it is expanded or collapsed.
if (MyParentEditItem.MyPreviousEditItem != null) return MyParentEditItem.MyPreviousEditItem.BottomMostEditItem.Bottom;
if (MyParentEditItem.MyBeforeEditItems != null) return MyParentEditItem.MyBeforeEditItems[MyParentEditItem.MyBeforeEditItems.Count - 1].BottomMostEditItem.Bottom;
return (MySectionRTBItem==null)?0:MySectionRTBItem.Bottom;
return (MySectionRTBItem == null) ? 0 : MySectionRTBItem.Bottom;
}
int b1 = prevOrParSupInfo.BottomMostEditItem.Bottom;
int b2 = b1;
@ -370,7 +370,7 @@ namespace Volian.Controls.Library
{
EditItem eitmp = null;
// if on a Note/Caution, need to be sure there isn't a step before me with supinfo (don't just assume going to Section)
if (prev.MyParentEditItem.MyPreviousEditItem!=null)eitmp = prev.MyParentEditItem.MyPreviousEditItem.BottomMostEditItem.FindPreviousOrParentSupInfo();
if (prev.MyParentEditItem.MyPreviousEditItem != null) eitmp = prev.MyParentEditItem.MyPreviousEditItem.BottomMostEditItem.FindPreviousOrParentSupInfo();
return eitmp;
}
if (prev.MyParentEditItem.MySupInfoEditItems != null) return prev.MyParentEditItem.MySupInfoEditItems[0];
@ -722,13 +722,13 @@ namespace Volian.Controls.Library
{
EditItem prevChild = nextEditItem.MyPreviousEditItem;
EditItem parent = nextEditItem.MyParentEditItem;
if(siblingEditItems.Contains(nextEditItem))
if (siblingEditItems.Contains(nextEditItem))
siblingEditItems.Insert(siblingEditItems.IndexOf(nextEditItem), this);
else
siblingEditItems.Insert(0, this);
MyStepPanel.ItemMoving++;
_MyNextEditItem = nextEditItem;
if(!MyItemInfo.IsNote || !MyItemInfo.ActiveFormat.MyStepSectionLayoutData.Dev_Format || MyPreviousEditItem == null)
if (!MyItemInfo.IsNote || !MyItemInfo.ActiveFormat.MyStepSectionLayoutData.Dev_Format || MyPreviousEditItem == null)
nextEditItem._MyPreviousEditItem = this;
MyPreviousEditItem = prevChild;// If a previous exists - this will adjust the location and width of the EditItem
if (MyItemInfo.IsNote && MyItemInfo.ActiveFormat.MyStepSectionLayoutData.Dev_Format && MyPreviousEditItem != null)
@ -984,7 +984,7 @@ namespace Volian.Controls.Library
(MyNextEditItem.MyItemInfo.IsNote || MyNextEditItem.MyItemInfo.IsCaution))
{
MyNextEditItem.MyParentEditItem.Top = (MyNextEditItem.MyParentEditItem.MyPreviousEditItem != null ?
MyNextEditItem.MyParentEditItem.MyPreviousEditItem.FindBottomDevDoc: MyNextEditItem.MyParentEditItem.MyParentEditItem.Bottom);
MyNextEditItem.MyParentEditItem.MyPreviousEditItem.FindBottomDevDoc : MyNextEditItem.MyParentEditItem.MyParentEditItem.Bottom);
MyNextEditItem.Top = MyNextEditItem.MyParentEditItem.Top;
MyNextEditItem.AdjustLocation();
}
@ -1223,7 +1223,7 @@ namespace Volian.Controls.Library
child = new ImageItem(MyItemInfo, MyStepPanel, this, ChildRelation.Before, true, nextEditItem, FigInsType);
else if (MyItemInfo.IsRtfRaw)
child = new RtfRawItem(MyItemInfo, MyStepPanel, this, ChildRelation.Before, true, nextEditItem);
if(MyItemInfo.MyContent.MyGrid != null)
if (MyItemInfo.MyContent.MyGrid != null)
child = new GridItem(MyItemInfo, MyStepPanel, this, ChildRelation.Before, true, nextEditItem);
else
child = new RTBItem(MyItemInfo, MyStepPanel, this, ChildRelation.Before, true, nextEditItem);
@ -1357,7 +1357,7 @@ namespace Volian.Controls.Library
public void AddSiblingBefore(int? type, bool updateStatus)
{
SaveContents();
ItemInfo newItemInfo = MyItemInfo.InsertSiblingBefore("", "",type);
ItemInfo newItemInfo = MyItemInfo.InsertSiblingBefore("", "", type);
AddGridIfNeeded(newItemInfo);
AddImageIfNeeded(newItemInfo);
DoAddSiblingBefore(newItemInfo, updateStatus);
@ -1801,7 +1801,7 @@ namespace Volian.Controls.Library
// To allow a Paste Step into an empty (new) step/substep, we need to add a character to the the Text field
// to simulate replacing an existing step - otherwise we will get null references.
if (MyStepPanel.SelectedEditItem.Empty)
MyStepPanel.SelectedEditItem.Empty=false;
MyStepPanel.SelectedEditItem.Empty = false;
MyStepPanel.SelectedEditItem = null; // Unselect the item to be deleted
ChildRelation childRelation = _MyChildRelation;
EditItem newFocus = null;
@ -1888,7 +1888,7 @@ namespace Volian.Controls.Library
MessageBox.Show("The step being pasted has been deleted", "Cannot Paste Step", MessageBoxButtons.OK, MessageBoxIcon.Hand);
return true;
}
if(ex.Message.Contains("This current step has been deleted in another session"))
if (ex.Message.Contains("This current step has been deleted in another session"))
{
MessageBox.Show("The highlighted step has been deleted by another user.", "Cannot Paste Step", MessageBoxButtons.OK, MessageBoxIcon.Hand);
return true;
@ -2150,7 +2150,7 @@ namespace Volian.Controls.Library
int center = aboveForLocation.ContentLeft + aboveForLocation.ContentWidth / 2;
int rightLimit = aboveForLocation.Right;
// Then should center on the wid Limit
if ((MyItemInfo.FormatStepData.Type.Contains("AER") == false && MyItemInfo.RNOLevel == 0 ) && !MyItemInfo.IsInSupInfo)
if ((MyItemInfo.FormatStepData.Type.Contains("AER") == false && MyItemInfo.RNOLevel == 0) && !MyItemInfo.IsInSupInfo)
{
// B2017-043 COLR is used as a Width
int colR = MyStepPanel.ToDisplay(MyStepSectionLayoutData.ColRTable, MyItemInfo.ColumnMode);
@ -2164,7 +2164,7 @@ namespace Volian.Controls.Library
int x = center - width / 2;
if (x + width > rightLimit) x = rightLimit - width;
// B2017-043 account for Horizontal Scroll
int colT =MyStepPanel.DisplayRectangle.X + MyStepPanel.ToDisplay((int)myStepSectionLayoutData.ColT);
int colT = MyStepPanel.DisplayRectangle.X + MyStepPanel.ToDisplay((int)myStepSectionLayoutData.ColT);
if (x < colT) x = colT;
int y = FindTop(myParentEditItem.Bottom);
return new Point(x, y);
@ -2249,7 +2249,7 @@ namespace Volian.Controls.Library
if (Top >= 0 && Bottom <= MyStepPanel.Height) return;// Don't move if within screen.
int scrollValue = MyStepPanel.VerticalScroll.Value + (Top - (MyStepPanel.Height / 2)); // calculate scroll center for the item
// Limit scroll location within allowable values
scrollValue = Math.Max(MyStepPanel.VerticalScroll.Minimum,Math.Min(MyStepPanel.VerticalScroll.Maximum,scrollValue));
scrollValue = Math.Max(MyStepPanel.VerticalScroll.Minimum, Math.Min(MyStepPanel.VerticalScroll.Maximum, scrollValue));
//Console.WriteLine("CenterScroll {0} Current {1} New {2} Min {3} Max {4}", _MyItem.ItemID, _Panel.VerticalScroll.Value, scrollValue, _Panel.VerticalScroll.Minimum, _Panel.VerticalScroll.Maximum);
//if (scrollValue >= MyStepPanel.VerticalScroll.Minimum && scrollValue <= MyStepPanel.VerticalScroll.Maximum) // If it is within range
MyStepPanel.VerticalScroll.Value = scrollValue; // Center the item
@ -2412,9 +2412,17 @@ namespace Volian.Controls.Library
// _NextDownEditItemPath);
if (nextEditItem != null)
{
if (MyStepPanel.ExpandingHLS != null && nextEditItem.MyItemInfo.IsSection) return; // without this, if next item is section, it crashes on null reference
if (MyStepPanel.ExpandingHLS != null && nextEditItem.MyItemInfo.IsSection)
{
AddAdjustItem(this);// B2017-175 Adjust Location after Expanding
return; // without this, if next item is section, it crashes on null reference
}
if (MyStepPanel.ExpandingHLS != null && nextEditItem.MyItemInfo.MyHLS.ItemID != MyStepPanel.ExpandingHLS.ItemID)
{
AddAdjustItem(this);// B2017-175 Adjust Location after Expanding
return;
}
if (AdjustItems.Contains(this)) AdjustItems.Remove(this);//B2017-175 If processed remove from list to do later
int bottom = nextEditItem.FindTop(Bottom);
if (MyItemInfo.ActiveFormat.MyStepSectionLayoutData.Dev_Format)
{
@ -2472,6 +2480,21 @@ namespace Volian.Controls.Library
}
}
}
private static List<EditItem> _AdjustItems=new List<EditItem>();// B2017-175 Keep a list of EditItems to adjust after expanding
public static List<EditItem> AdjustItems
{
get { return _AdjustItems; }
set { _AdjustItems = value; }
}
private static void AddAdjustItem(EditItem ei)// B2017-175 Add edit item to adjust after expanding
{
if(!AdjustItems.Contains(ei)) AdjustItems.Add(ei);
}
private static void ProcessAdjustItems() // B2017-175 adjust after expanding
{
while (AdjustItems.Count > 0)
AdjustItems[0].AdjustLocation();
}
private int _DevDocHeight = 0; // Deviation Document Step Height B2016-123, B2017-020, B2017-021
public int DevDocHeight
{
@ -2480,7 +2503,7 @@ namespace Volian.Controls.Library
}
public void TryAgainNow(int bottom)
{
TryToSetTop(bottom-10);
TryToSetTop(bottom - 10);
//TryToSetTop(bottom+10);
TryToSetTop(bottom);
}
@ -2488,7 +2511,7 @@ namespace Volian.Controls.Library
{
Top = offset;
if (Top != offset)
_MyLog.InfoFormat("Didn't work - Top {0} != offset {1} {2}", Top, offset,MyStepPanel.VerticalScroll.Value);
_MyLog.InfoFormat("Didn't work - Top {0} != offset {1} {2}", Top, offset, MyStepPanel.VerticalScroll.Value);
}
/// <summary>
/// Automatically expands Steps if not currently expanded
@ -2497,7 +2520,7 @@ namespace Volian.Controls.Library
{
if (CanExpand && Expanded == false)// TODO: May need to do some additional checking for subsections
{
if(MyStepPanel.AutoExpand)
if (MyStepPanel.AutoExpand)
Expand((_ContentType >= 20000) || MyItemInfo.ActiveFormat.MyStepSectionLayoutData.Dev_Format);
else
Expand(false);
@ -2556,7 +2579,7 @@ namespace Volian.Controls.Library
// Only check the flag if the section has subsections because the
// default for the flag is not editable, and this would make non-metasections
// not editable.
bool hasMetaSubs = MyItemInfo.IsSection && MyItemInfo.Sections != null && MyItemInfo.Sections.Count>0;
bool hasMetaSubs = MyItemInfo.IsSection && MyItemInfo.Sections != null && MyItemInfo.Sections.Count > 0;
bool EditSteps = !hasMetaSubs || (MyItemInfo.MyConfig is SectionConfig && (MyItemInfo.MyConfig as SectionConfig).SubSection_Edit == "Y");
if (EditSteps) AddChildAfter(MyItemInfo.Steps, expand);
@ -2569,6 +2592,8 @@ namespace Volian.Controls.Library
}
MyExpandingStatus = ExpandingStatus.Done;
BottomMostEditItem.AdjustLocation();
if (MyItemInfo.IsHigh)
ProcessAdjustItems(); // B2017-175 Adjust after expanding
MyExpandingStatus = ExpandingStatus.No;
//// TIMING: DisplayItem.TimeIt("Expand End");
}
@ -2795,7 +2820,7 @@ namespace Volian.Controls.Library
public abstract bool FindText(string str, bool caseSensitive, bool matchWholeWord, bool reverse);
public abstract void PositionToEnd();
public abstract void PositionToStart();
public abstract string SelectedTextForFind { get;}
public abstract string SelectedTextForFind { get; }
public abstract bool SpellCheckNext();
public abstract void IdentifyMe(bool highlight);
public abstract void SetActive();
@ -2884,14 +2909,14 @@ namespace Volian.Controls.Library
if (MyPreviousEditItem != null)
{
EditItem ei = MyPreviousEditItem.BottomMostEditItem;
if (ei.MyItemInfo.IsHigh && (ei.MyItemInfo.Cautions !=null || ei.MyItemInfo.Notes!=null))
if (ei.MyItemInfo.IsHigh && (ei.MyItemInfo.Cautions != null || ei.MyItemInfo.Notes != null))
{
if (ei.MyItemInfo.Cautions!= null)// Look at cautions
if (ei.MyItemInfo.Cautions != null)// Look at cautions
{
EditItem eic = MyStepPanel._LookupEditItems[ei.MyItemInfo.Cautions[0].ItemID].BottomMostEditItem;
if (eic.Bottom > ei.Bottom) ei = eic;
}
if (ei.MyItemInfo.Notes!= null)//Look at notes
if (ei.MyItemInfo.Notes != null)//Look at notes
{
EditItem ein = MyStepPanel._LookupEditItems[ei.MyItemInfo.Notes[0].ItemID].BottomMostEditItem;
if (ein.Bottom > ei.Bottom) ei = ein;
@ -3063,7 +3088,7 @@ namespace Volian.Controls.Library
// width for the screen (this does not affect the printout)
// If in single column, don't make this adjustment:
string[] splitRNOWidthAlt = MyStepSectionLayoutData.RNOWidthAlt.Split(',');
int ovrRNOWidth = (RNOLevel < splitRNOWidthAlt.Length)?MyStepPanel.ToDisplay(float.Parse(splitRNOWidthAlt[RNOLevel])+1) : 0;
int ovrRNOWidth = (RNOLevel < splitRNOWidthAlt.Length) ? MyStepPanel.ToDisplay(float.Parse(splitRNOWidthAlt[RNOLevel]) + 1) : 0;
if (MyStepSectionLayoutData.RNOWidthAlt != null && ovrRNOWidth > 1 && MyItemInfo.ColumnMode != 0)
ContentWidth = ovrRNOWidth;
else
@ -3331,7 +3356,7 @@ namespace Volian.Controls.Library
EIWsupInfoBelow.Top = Math.Max(bottomOfAboveSupInfoColumn, bottomOfImmediatelyAbove);
EIWsupInfoBelow.AdjustLocation();
MyStepPanel.ItemMoving--;
return EIWsupInfoBelow.MySupInfoEditItems==null?null:EIWsupInfoBelow.MySupInfoEditItems[0];
return EIWsupInfoBelow.MySupInfoEditItems == null ? null : EIWsupInfoBelow.MySupInfoEditItems[0];
}
}
return null;
@ -3340,7 +3365,7 @@ namespace Volian.Controls.Library
{
ItemInfo hls = ei.MyItemInfo.MyHLS;
EditItem hlsEI = GetEditItemFromItemID(hls.ItemID);
if (hlsEI==null) return null;
if (hlsEI == null) return null;
return ei;
}
// FindSiblingOrParentSiblingWithSupInfo will find the next edititem below me on the screen that has a supinfo
@ -3467,7 +3492,7 @@ namespace Volian.Controls.Library
{
EditItem ei = this;
while (ei != null && !ei.MyItemInfo.IsHigh) ei = ei.MyParent;// Get High Level Step
if(ei != null) ei=ei.MyNextEditItem;// Get Next High Level Step
if (ei != null) ei = ei.MyNextEditItem;// Get Next High Level Step
if (ei != null)
{
if (ei.MyItemInfo.IsHigh && (ei.MyItemInfo.Cautions != null || ei.MyItemInfo.Notes != null))
@ -3538,7 +3563,7 @@ namespace Volian.Controls.Library
vlntxt = null;
}
ContentFont = myStepPanel.StepFont;//lblTab.Font = myStepPanel.StepFont;
if (itemInfo.MyTab != null ) TabFont = itemInfo.MyTab.MyFont.WindowsFont;
if (itemInfo.MyTab != null) TabFont = itemInfo.MyTab.MyFont.WindowsFont;
MyStepData = itemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList[ContentType % 10000];
break;
}
@ -3710,7 +3735,7 @@ namespace Volian.Controls.Library
//g.DrawLine(Pens.DarkGreen, 18, 3, 21, 3);
//g.DrawLine(Pens.DarkGreen, 18, 6, 21, 6);
//g.DrawString("B", fnt, Brushes.Green, new RectangleF(new PointF(0,0), this.Size), StringFormat.GenericDefault);
g.DrawString(dved.PdfToken, fnt, Brushes.Green, new RectangleF(new PointF(x,y), this.Size), StringFormat.GenericDefault);
g.DrawString(dved.PdfToken, fnt, Brushes.Green, new RectangleF(new PointF(x, y), this.Size), StringFormat.GenericDefault);
if (y > 0)
{
x += 18;
@ -3757,7 +3782,7 @@ namespace Volian.Controls.Library
if (this is GridItem)
{
GridItem gi = this as GridItem;
X = gi.MyFlexGrid.Right+2;
X = gi.MyFlexGrid.Right + 2;
H = gi.MyFlexGrid.Height;
}
else if (this is RtfRawItem)
@ -3778,7 +3803,7 @@ namespace Volian.Controls.Library
X = ri.MyStepRTB.Right + 2;
H = ri.MyStepRTB.Height;
}
g.DrawLine(penCB, X, ContentTop, X, ContentTop+H); //Height);
g.DrawLine(penCB, X, ContentTop, X, ContentTop + H); //Height);
}
}
if (UserCheckOff)