diff --git a/PROMS/Volian.Controls.Library/EditItem.cs b/PROMS/Volian.Controls.Library/EditItem.cs index a1194532..df0f946c 100644 --- a/PROMS/Volian.Controls.Library/EditItem.cs +++ b/PROMS/Volian.Controls.Library/EditItem.cs @@ -1739,7 +1739,7 @@ namespace Volian.Controls.Library MyStepPanel.ItemMoving++; rnoTop.LastMethodsPush(string.Format("EditItem_Move RNO Right {0}", rnoTop.MyID)); //rnoTop.Top = tmpBottom.Bottom; - if(rnoTop.Top != Top) + if (rnoTop.Top != Top) rnoTop.Top = Top; rnoTop.LastMethodsPop(); MyStepPanel.ItemMoving--; @@ -1748,7 +1748,7 @@ namespace Volian.Controls.Library { MyStepPanel.ItemMoving++; rnoTop.LastMethodsPush(string.Format("EditItem_Move RNO Below {0} {1} {2}", rnoTop.MyID, BottomMostEditItemNoRNOs.MyID, BottomMostEditItemNoRNOs.Bottom)); - if(rnoTop.Top != BottomMostEditItemNoRNOs.Bottom) + if (rnoTop.Top != BottomMostEditItemNoRNOs.Bottom) rnoTop.Top = BottomMostEditItemNoRNOs.Bottom; rnoTop.LastMethodsPop(); MyStepPanel.ItemMoving--; @@ -1772,70 +1772,70 @@ namespace Volian.Controls.Library { int newTop = Top - MyStepPanel.TopMostEditItem.Top; if (_LastTop == newTop) return; - _LastTop = newTop; - int watchThis = _WatchThis; - //if (MyID == 136) - //{ - // vlnStackTrace.ShowStack("{0} Move TO {1}", MyID, Top); - // //vlnStackTrace.ShowStack("{0} Move TO {1} - {2}, BottomMost {3}", MyID, Top, MyPath, BottomMostRTBItem.MyPath); - // //Console.WriteLine("{0} Move TO {1} - {2}, BottomMost {3}", MyID, Top, MyPath, BottomMostRTBItem.MyPath); - //} - //if (MyID > _StartingID) - // Console.WriteLine("{0}--------------- {1} Top = {2} Bottom {3}", WatchThisIndent, MyID, Top, Bottom); - if (MyStepPanel.ItemMoving == 0 && !TryAgainLater) - { - //vlnStackTrace.ScrollInStack(); - return; // If 0 - Indicates scrolling which requires no action. - } - TryAgainLater = false; - //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; - EditItem tmp = (EditItem)sender; - if (tmp.MyPreviousEditItem == null && tmp.MyParentEditItem == null) - { - _WatchThis = watchThis; - return; - } - if (RNOBelow) // Adjust substeps first - { - //Console.WriteLine("RNOBelow"); - AdjustLocation(); - MoveRNO(); - } - else // Adjust RNO First - { - if (RNORight) + _LastTop = newTop; + int watchThis = _WatchThis; + //if (MyID == 136) + //{ + // vlnStackTrace.ShowStack("{0} Move TO {1}", MyID, Top); + // //vlnStackTrace.ShowStack("{0} Move TO {1} - {2}, BottomMost {3}", MyID, Top, MyPath, BottomMostRTBItem.MyPath); + // //Console.WriteLine("{0} Move TO {1} - {2}, BottomMost {3}", MyID, Top, MyPath, BottomMostRTBItem.MyPath); + //} + //if (MyID > _StartingID) + // Console.WriteLine("{0}--------------- {1} Top = {2} Bottom {3}", WatchThisIndent, MyID, Top, Bottom); + if (MyStepPanel.ItemMoving == 0 && !TryAgainLater) { - //Console.WriteLine("RNORight"); + //vlnStackTrace.ScrollInStack(); + return; // If 0 - Indicates scrolling which requires no action. + } + TryAgainLater = false; + //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; + EditItem tmp = (EditItem)sender; + if (tmp.MyPreviousEditItem == null && tmp.MyParentEditItem == null) + { + _WatchThis = watchThis; + return; + } + if (RNOBelow) // Adjust substeps first + { + //Console.WriteLine("RNOBelow"); + AdjustLocation(); MoveRNO(); } - AdjustLocation(); + else // Adjust RNO First + { + if (RNORight) + { + //Console.WriteLine("RNORight"); + MoveRNO(); + } + AdjustLocation(); + } + Moving = false; + EditItem btm = BottomMostEditItem; + if (this != btm) + btm.AdjustLocation(); + //if (_WatchThis > 0 && MyID > _StartingID) + //{ + // Console.WriteLine("{0}Finish Move {1},{2}",WatchThisIndent, MyID, this); + //} + _WatchThis = watchThis; } - Moving = false; - EditItem btm = BottomMostEditItem; - if (this != btm) - btm.AdjustLocation(); - //if (_WatchThis > 0 && MyID > _StartingID) - //{ - // Console.WriteLine("{0}Finish Move {1},{2}",WatchThisIndent, MyID, this); - //} - _WatchThis = watchThis; - } /// /// Adjust the locations when the EditItem is resized /// @@ -2139,9 +2139,27 @@ namespace Volian.Controls.Library return; int bottom = nextEditItem.FindTop(Bottom); if (MyItemInfo.ActiveFormat.MyStepSectionLayoutData.Dev_Format) + { if (MyItemInfo.IsCaution || MyItemInfo.IsNote) - bottom = Top; - + { + if (nextEditItem.MyItemInfo.IsHigh || nextEditItem.MyItemInfo.IsFirstNotePart) + { + bottom = FirstSiblingEditItem.Top; + } + if (MyParentEditItem == nextEditItem && MyParentEditItem.NextDownEditItem != null) + { + int bot = 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 = MyParentEditItem.NextDownEditItem; + ei.Top = bot; + ei.AdjustLocation(); + } + } + } + } // SameRowAsParent - Comanche Peak Step Designator //FormatData fmtdata = MyItemInfo.ActiveFormat.PlantFormat.FormatData; //int formatSteptype = MyItemInfo.FormatStepType; @@ -2152,7 +2170,14 @@ namespace Volian.Controls.Library // If this is a "TitleWithTextRight", don't move down on the screen but only if it has a // child, i.e. want the child to be positioned on line, but if no child, move down on screen: int newTop = bottom; + if (MyItemInfo.IsStep &&nextEditItem.MyItemInfo.MyHLS.ItemID != MyItemInfo.MyHLS.ItemID)// Move from one step to another + if (MyItemInfo.ActiveFormat.MyStepSectionLayoutData.Dev_Format) // Deviation Document Format + newTop = FindBottomDevDoc;// Use the bottom most caution or note + if (MyItemInfo.FormatStepData != null && MyItemInfo.FormatStepData.Type == "TitleWithTextRight" && MyItemInfo.HasChildren) newTop = Top; + //This was useful to find the code that was positioning the Deviationn Document steps + //if (MyItemInfo.InList(134782, 134783) || nextEditItem.MyItemInfo.InList(134782, 134783)) + // Console.WriteLine("\"AdjustLocation\"\t\"{0}\"\t\"{1}\"\t{2}\t{3}\t{4}\t{5}", MyItemInfo.ShortPath, nextEditItem.MyItemInfo.ShortPath, nextEditItem.MyID, newTop, FindBottom, FindBottom - Top); if (nextEditItem.Top != newTop) { MyStepPanel.ItemMoving++; @@ -2175,6 +2200,7 @@ namespace Volian.Controls.Library } } } + public int _DevDocHeight = 0; // Deviation Document Step Height public void TryAgainNow(int bottom) { TryToSetTop(bottom-10); @@ -2220,7 +2246,7 @@ namespace Volian.Controls.Library if (ExpandPrefix != 0) { MyStepPanel.ItemMoving++; - if(TopMostEditItem.Top != Top) + if (TopMostEditItem.Top != Top) TopMostEditItem.Top = Top; MyStepPanel.ItemMoving--; } @@ -2399,7 +2425,7 @@ namespace Volian.Controls.Library //Console.WriteLine("{0}***Move in NextDownEditItem {1},{2} From {3} To {4}",WatchThisIndent, btmNext.MyID, btmNext, btmNext.Top, btm.Bottom); btmNext.LastMethodsPush(string.Format("NextDownEditItem {0} {1}", MyID, EditItem.MyID)); //ShowMe(string.Format("FindTop = {0}", btmNext.FindTop(btm.Bottom))); - if(btmNext.Top != bottom) + if (btmNext.Top != bottom) btmNext.Top = bottom; btmNext.LastMethodsPop(); MyStepPanel.ItemMoving--; @@ -2491,6 +2517,27 @@ namespace Volian.Controls.Library protected string _TabFormat; private static int _WidthAdjust = 5; protected bool _IgnoreResize = false; + private int FindBottomDevDoc // Find Bottom of a Deviation Document Step + { + get + { + int y = Bottom; + if (MyParentEditItem == null || MyParentEditItem.MyItemInfo.IsSection) + { + EditItem eitm2 = this; + if (eitm2 != null && eitm2.MyBeforeEditItems != null) + foreach (EditItem eitm2Tmp in eitm2.MyBeforeEditItems) + y = Math.Max(y, eitm2Tmp.Bottom); + return y; + } + y = Math.Max(y, MyParentEditItem.Bottom); + EditItem eitm = MyParentEditItem; + if (eitm != null && eitm.MyBeforeEditItems != null) + foreach (EditItem eitmTmp in eitm.MyBeforeEditItems) + y = Math.Max(y, eitmTmp.Bottom); + return y; + } + } /// /// Sets the parent and postions the item with respect to the parent /// @@ -2522,8 +2569,29 @@ namespace Volian.Controls.Library case 1: // Section if (this == TopMostEditItem) { - if(MyItemInfo.ActiveFormat.MyStepSectionLayoutData.Dev_Format) - ItemLocation = new Point(MyStepPanel.ToDisplay(MyItemInfo.ActiveFormat.MyStepSectionLayoutData.ColS)+50, _MyParentEditItem.Bottom); + if (MyItemInfo.ActiveFormat.MyStepSectionLayoutData.Dev_Format) + { + if (MyPreviousEditItem != null) + { + EditItem ei = MyPreviousEditItem.BottomMostEditItem; + if (ei.MyItemInfo.IsHigh && (ei.MyItemInfo.Cautions !=null || ei.MyItemInfo.Notes!=null)) + { + 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 + { + EditItem ein = MyStepPanel._LookupEditItems[ei.MyItemInfo.Notes[0].ItemID].BottomMostEditItem; + if (ein.Bottom > ei.Bottom) ei = ein; + } + } + ItemLocation = new Point(MyStepPanel.ToDisplay(MyItemInfo.ActiveFormat.MyStepSectionLayoutData.ColS) + 50, ei.Bottom); + } + else + ItemLocation = new Point(MyStepPanel.ToDisplay(MyItemInfo.ActiveFormat.MyStepSectionLayoutData.ColS) + 50, _MyParentEditItem.Bottom); + } else ItemLocation = new Point(_MyParentEditItem.ItemLocation.X + 20, _MyParentEditItem.Bottom); } @@ -2655,8 +2723,8 @@ namespace Volian.Controls.Library if (top != _MyParentEditItem.Top) { _MyParentEditItem.LastMethodsPush(string.Format("set_MyParentRTBItem RNO Right {0}", MyID)); - if(_MyParentEditItem.Top != top) - _MyParentEditItem.Top = top; + if (_MyParentEditItem.Top != top) + _MyParentEditItem.Top = top; _MyParentEditItem.LastMethodsPop(); Top = top; } @@ -2694,19 +2762,22 @@ namespace Volian.Controls.Library //} if (MyItemInfo.ActiveFormat.MyStepSectionLayoutData.Dev_Format && (MyItemInfo.IsCaution || MyItemInfo.IsNote)) { - int x = MyStepPanel.ToDisplay(MyItemInfo.ActiveFormat.MyStepSectionLayoutData.ColT); - int y = FindTop(myTop); - // Get the "bottom" number of the longest Caution/Note on the step/substep above so that - // we can position properly on the screen. - // EX. Catawba Deviations E-1 step deviation for step 10 - EditItem eitm = (MyParentEditItem.MyPreviousEditItem != null) ? MyParentEditItem.MyPreviousEditItem : MyParentEditItem.MyParentEditItem; - if (eitm != null && eitm.MyBeforeEditItems != null) - { - foreach (EditItem eitmTmp in eitm.MyBeforeEditItems) - y = Math.Max(y, eitmTmp.Bottom); - } - if(MyItemInfo.IsNote) - x += Width + 6; + int x = MyStepPanel.ToDisplay(MyItemInfo.ActiveFormat.MyStepSectionLayoutData.ColT); + int y = Top; + if (MyPreviousEditItem == null || !MyPreviousEditItem.MyItemInfo.IsCaution || !MyItemInfo.IsNote) + y = FindTop(myTop); + // Get the "bottom" number of the longest Caution/Note on the step/substep above so that + // we can position properly on the screen. + // EX. Catawba Deviations E-1 step deviation for step 10 + EditItem eitm = (MyParentEditItem.MyPreviousEditItem != null) ? MyParentEditItem.MyPreviousEditItem : MyParentEditItem.MyParentEditItem; + if (eitm != null && eitm.MyBeforeEditItems != null) + foreach (EditItem eitmTmp in eitm.MyBeforeEditItems) + y = Math.Max(y, eitmTmp.Bottom); + if (MyItemInfo.IsNote) // Move to the right based upon the Width of the Caution which is the same as the width of the note. + { // AdjustChildren width BeforeItem setting Left offset + int width = MyStepPanel.ToDisplay(MyStepSectionLayoutData.WidT) + spaceToRTB; + x += width + 6;//Account for the width of the Caution in the Deviation Document + } Location = new Point(x, y); } else @@ -2775,7 +2846,11 @@ namespace Volian.Controls.Library int x = MyStepPanel.ToDisplay(MyItemInfo.ActiveFormat.MyStepSectionLayoutData.ColT); if (MyItemInfo.IsNote) x += Width + 6; - Location = new Point(x, _MyPreviousEditItem.Top); + //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 {