Fixed logic to support adding a Caution when a Caution or adding a note when a note exists in Deviation Document Format

This commit is contained in:
Rich 2017-02-20 16:08:23 +00:00
parent e1019e3454
commit 4932c7d28c

View File

@ -590,13 +590,17 @@ namespace Volian.Controls.Library
siblingEditItems.Insert(0, this);
MyStepPanel.ItemMoving++;
_MyNextEditItem = nextEditItem;
nextEditItem._MyPreviousEditItem = this;
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.ActiveFormat.MyStepSectionLayoutData.Dev_Format || !( nextEditItem.MyItemInfo.IsNote && MyItemInfo.IsCaution) )
if (MyItemInfo.IsNote && MyItemInfo.ActiveFormat.MyStepSectionLayoutData.Dev_Format && MyPreviousEditItem != null)
nextEditItem.MyPreviousEditItem = this;//Position First Note in Dev Doc Format
if (!MyItemInfo.ActiveFormat.MyStepSectionLayoutData.Dev_Format || !(nextEditItem.MyItemInfo.IsNote && MyItemInfo.IsCaution))
{
// RHM 20170216 For Deviation Document don't set MyParentEditItem to null when Type Changes from Caution to Note
nextEditItem.MyParentEditItem = null;
MyParentEditItem = parent; // If a parent exists - this will adjust the location and width of the EditItem
AdjustForDevDocStepHeight();
}
//nextEditItem.MyPreviousEditItem = this;
MyStepPanel.ItemMoving--;
@ -820,7 +824,18 @@ namespace Volian.Controls.Library
newFocus = MyNextEditItem;
}
// Adjust the vertical locations of all of the items below the item deleted
MyNextEditItem.TopMostEditItem.AdjustLocation();
if (MyItemInfo.ActiveFormat.MyStepSectionLayoutData.Dev_Format && MyNextEditItem.MyPreviousEditItem == null &&
(MyNextEditItem.MyItemInfo.IsNote || MyNextEditItem.MyItemInfo.IsCaution))
{
MyNextEditItem.MyParentEditItem.Top = (MyNextEditItem.MyParentEditItem.MyPreviousEditItem != null ?
MyNextEditItem.MyParentEditItem.MyPreviousEditItem.FindBottomDevDoc: MyNextEditItem.MyParentEditItem.MyParentEditItem.Bottom);
MyNextEditItem.Top = MyNextEditItem.MyParentEditItem.Top;
MyNextEditItem.AdjustLocation();
}
else
{
MyNextEditItem.TopMostEditItem.AdjustLocation();
}
MyNextEditItem = null;
}
else if (MyPreviousEditItem != null)
@ -829,6 +844,13 @@ namespace Volian.Controls.Library
//newFocus = MyPreviousEditItem.BottomMostEditItem;
// bug fix - when deleting an edit window in the AER, position to the bottom most in the AER - was jumping to RNO
newFocus = MyPreviousEditItem.BottomMostEditItemNoRNOs;
if (MyItemInfo.ActiveFormat.MyStepSectionLayoutData.Dev_Format && MyPreviousEditItem.MyNextEditItem == null &&
(MyPreviousEditItem.MyItemInfo.IsNote || MyPreviousEditItem.MyItemInfo.IsCaution))
{
MyPreviousEditItem.MyParent.Top = MyPreviousEditItem.MyParent.MyPreviousEditItem.FindBottomDevDoc;
MyPreviousEditItem.Top = MyPreviousEditItem.MyParent.Top;
MyPreviousEditItem.MyParent.AdjustLocation();
}
MyPreviousEditItem = null;
//Console.Write(",\"Previous\",");
}
@ -1777,7 +1799,7 @@ namespace Volian.Controls.Library
{
int newTop = Top - MyStepPanel.TopMostEditItem.Top;
//if(_ShowChanges && _LastTop != newTop && MyItemInfo.InList(134786))
// Volian.Base.Library.vlnStackTrace.ShowStackLocal(2,10,"\"EditItem_Move\"\t\"\"\t\"{0}\"\t{1}\t{2}\t{3}",MyItemInfo.ShortPath, MyID, Top, _LastTop);
//Volian.Base.Library.vlnStackTrace.ShowStackLocal(2,10,"\"EditItem_Move\"\t\"\"\t\"{0}\"\t{1}\t{2}\t{3}",MyItemInfo.ShortPath, MyID, Top, _LastTop);
if (_LastTop == newTop) return;
_LastTop = newTop;
int watchThis = _WatchThis;
@ -2163,25 +2185,14 @@ namespace Volian.Controls.Library
{
if (MyItemInfo.IsCaution || MyItemInfo.IsNote)
{
if (nextEditItem.MyItemInfo.IsHigh || nextEditItem.MyItemInfo.IsFirstNotePart)
if (nextEditItem.MyItemInfo.IsHigh || (nextEditItem.MyItemInfo.IsNote && MyItemInfo.IsCaution))
{
bottom = FirstSiblingEditItem.Top;
}
// RHM 20170216
// MyParent will walk back MyPrevious to find Parent
// NextDevDocStep will find the first part of a Dev Doc HLS
if (MyParent == nextEditItem && MyParent.NextDevDocStep != null)
{
int bot = MyParent.FindBottomDevDoc;
int DDHeight = bot - FirstSiblingEditItem.Top;//Determine the height of the step including cautions and notes
if (_DevDocHeight != DDHeight)
{
_DevDocHeight = DDHeight;// If the height has changed adjust the top of the next item down
EditItem ei = MyParent.NextDevDocStep;
ei.Top = bot;
ei.AdjustLocation();
}
}
AdjustForDevDocStepHeight();
}
}
// SameRowAsParent - Comanche Peak Step Designator
@ -2224,7 +2235,12 @@ namespace Volian.Controls.Library
}
}
}
public int _DevDocHeight = 0; // Deviation Document Step Height
private int _DevDocHeight = 0; // Deviation Document Step Height B2016-123, B2017-020, B2017-021
public int DevDocHeight
{
get { return _DevDocHeight; }
set { _DevDocHeight = value; }
}
public void TryAgainNow(int bottom)
{
TryToSetTop(bottom-10);
@ -2838,8 +2854,8 @@ namespace Volian.Controls.Library
{
_IgnoreResize = true;
// the table code goes through the following, rather than 'istablepart'
if (MyStepData != null && ((MyStepData.Type.ToLower().Contains("table") || MyStepData.ParentType.ToLower().Contains("table"))||
(MyStepData.Type.ToLower().Contains("figure") || MyStepData.ParentType.ToLower().Contains("figure"))||
if (MyStepData != null && ((MyStepData.Type.ToLower().Contains("table") || MyStepData.ParentType.ToLower().Contains("table")) ||
(MyStepData.Type.ToLower().Contains("figure") || MyStepData.ParentType.ToLower().Contains("figure")) ||
(MyStepData.Type.ToLower().Contains("equation") || MyStepData.ParentType.ToLower().Contains("equation"))))
{
ItemWidth = TableWidth;
@ -2864,54 +2880,40 @@ namespace Volian.Controls.Library
ContentWidth = (MyPreviousEditItem.MyItemInfo.MyTab.Offset != 0) ? MyPreviousEditItem.ContentWidth : MyPreviousEditItem.ContentWidth + 10;
else
Width = MyPreviousEditItem.Width;
if (TopMostEditItem == this)
if (TopMostEditItem == this)
{
if (MyItemInfo.ActiveFormat.MyStepSectionLayoutData.Dev_Format &&
(MyItemInfo.IsNote || MyItemInfo.IsCaution) &&
(MyPreviousEditItem == null || (MyPreviousEditItem.MyItemInfo.IsCaution && MyItemInfo.IsNote)))
//if ((MyItemInfo.SameRowAsParent && MyItemInfo.IsCaution2) || (MyItemInfo.ActiveFormat.MyStepSectionLayoutData.Dev_Format && (MyItemInfo.IsNote || MyItemInfo.IsCaution)))
{
int x = MyStepPanel.ToDisplay(MyItemInfo.ActiveFormat.MyStepSectionLayoutData.ColT);
if (MyItemInfo.IsNote)
x += Width + 6;
//Find first sibling
EditItem prev = _MyPreviousEditItem;
while (prev._MyPreviousEditItem != null)
prev = prev._MyPreviousEditItem;
Location = new Point(x, prev.Top);// Use the top of the first sibling
}
else
{
int top = FindTop(_MyPreviousEditItem.BottomMostEditItem.Bottom);
if (MyItemInfo.ActiveFormat.MyStepSectionLayoutData.Dev_Format && _MyPreviousEditItem.MyItemInfo.IsHigh)
//if (MyItemInfo.SameRowAsParent || (MyItemInfo.ActiveFormat.MyStepSectionLayoutData.Dev_Format && _MyPreviousEditItem.MyItemInfo.IsHigh))
{
if (MyItemInfo.ActiveFormat.MyStepSectionLayoutData.Dev_Format &&
(MyItemInfo.IsNote || MyItemInfo.IsCaution) &&
(MyPreviousEditItem == null || (MyPreviousEditItem.MyItemInfo.IsCaution && MyItemInfo.IsNote)))
//if ((MyItemInfo.SameRowAsParent && MyItemInfo.IsCaution2) || (MyItemInfo.ActiveFormat.MyStepSectionLayoutData.Dev_Format && (MyItemInfo.IsNote || MyItemInfo.IsCaution)))
{
int x = MyStepPanel.ToDisplay(MyItemInfo.ActiveFormat.MyStepSectionLayoutData.ColT);
if (MyItemInfo.IsNote)
x += Width + 6;
//Find first sibling
EditItem prev = _MyPreviousEditItem;
while (prev._MyPreviousEditItem != null)
prev = prev._MyPreviousEditItem;
Location = new Point(x, prev.Top);// Use the top of the first sibling
}
else
{
int top = FindTop(_MyPreviousEditItem.BottomMostEditItem.Bottom);
if (MyItemInfo.ActiveFormat.MyStepSectionLayoutData.Dev_Format && _MyPreviousEditItem.MyItemInfo.IsHigh)
//if (MyItemInfo.SameRowAsParent || (MyItemInfo.ActiveFormat.MyStepSectionLayoutData.Dev_Format && _MyPreviousEditItem.MyItemInfo.IsHigh))
{
if (_MyPreviousEditItem.MyBeforeEditItems != null)
foreach(EditItem ei in _MyPreviousEditItem.MyBeforeEditItems)
top=Math.Max(top, ei.Bottom);
}
Location = new Point(_MyPreviousEditItem.Left, top);
// B2017-029 only do this if this is a the deviation document
if (MyItemInfo.ActiveFormat.MyStepSectionLayoutData.Dev_Format && MyParent.MyItemInfo.IsHigh)
{
int bot = MyParent.FindBottomDevDoc;
int DDHeight = bot - FirstSiblingEditItem.Top;//Determine the height of the step including cautions and notes
if (MyParent._DevDocHeight != DDHeight)
{
MyParent._DevDocHeight = DDHeight;// If the height has changed adjust the top of the next item down
EditItem ei = NextDevDocStep;// RHM 20170216 Locate Next Dev Doc Step
if(ei != null)
{
ei.Top = bot;
ei.AdjustLocation();
}
}
}
}
if (_MyPreviousEditItem.MyBeforeEditItems != null)
foreach (EditItem ei in _MyPreviousEditItem.MyBeforeEditItems)
top = Math.Max(top, ei.Bottom);
}
else
TopMostEditItem.Location = new Point(TopMostEditItem.Left, FindTop(_MyPreviousEditItem.BottomMostEditItem.Bottom));
Location = new Point(_MyPreviousEditItem.Left, top);
// B2017-029 only do this if this is a the deviation document
AdjustForDevDocStepHeight();
}
}
else
TopMostEditItem.Location = new Point(TopMostEditItem.Left, FindTop(_MyPreviousEditItem.BottomMostEditItem.Bottom));
}
_IgnoreResize = false;
//ShowMe("");
@ -2941,6 +2943,27 @@ namespace Volian.Controls.Library
}
LastMethodsPop();
}
}
/// <summary>
/// Adjust the height of a Deviation Document Step Including the Cautions and Notes B2016-123, B2017-020, B2017-021
/// </summary>
private void AdjustForDevDocStepHeight()
{
if (MyItemInfo.ActiveFormat.MyStepSectionLayoutData.Dev_Format && MyParent.MyItemInfo.IsHigh)
{
int bot = MyParent.FindBottomDevDoc;
int DDHeight = bot - FirstSiblingEditItem.Top;//Determine the height of the step including cautions and notes
if (MyParent.DevDocHeight != DDHeight)
{
MyParent.DevDocHeight = DDHeight;// If the height has changed adjust the top of the next item down
EditItem ei = NextDevDocStep;// RHM 20170216 Locate Next Dev Doc Step
if (ei != null)
{
ei.Top = bot;
ei.AdjustLocation();
}
}
}
}
// RHM 20170216 - Find Next Dev Doc High Level Step
// If caution Exists return caution