diff --git a/PROMS/Volian.Controls.Library/DisplayText.cs b/PROMS/Volian.Controls.Library/DisplayText.cs index dcc4b147..ff96f65c 100644 --- a/PROMS/Volian.Controls.Library/DisplayText.cs +++ b/PROMS/Volian.Controls.Library/DisplayText.cs @@ -362,12 +362,7 @@ namespace Volian.Controls.Library _MyItem.DTS = DateTime.Now; _MyItem.UserID = Environment.UserName; // Do the Save once rather than multiple times - bool saveAtOnce = false; - // If it is a new Item, save it before the transitions and ROs are saved - if (_MyItem.ItemID < 0) - _MyItem.Save(); - else - saveAtOnce = true; + _MyItem.Save(); if (ctReplacements.Count > 0) { EditText = FixCtReplacements(EditText, ctReplacements); @@ -375,15 +370,13 @@ namespace Volian.Controls.Library foreach (ContentTransition ct in ctReplacements.Values) using (TransitionInfo tran = TransitionInfo.Get(ct.TransitionID)) _MyItem.MyContent.FixTransitionText(tran); - saveAtOnce = true; + _MyItem.Save(); } if (roUsgReplacements.Count > 0) { EditText = FixRoUsgReplacements(EditText, roUsgReplacements); - saveAtOnce = true; - } - if(saveAtOnce) _MyItem.Save(); + } modtext = EditText; } else @@ -783,10 +776,9 @@ namespace Volian.Controls.Library retval = Regex.Replace(retval, @"(\\[^' \\?\r\n\t]+) (?=\\)", "$1"); // remove space between tokens retval = Regex.Replace(retval, @"(\\[^' \\?\r\n\t]+) (?=\r\n)", "$1"); // remove space before /r/n // remove \r\n at end of string if the string has 2 or more characters - if (retval.Length > 1 && retval.Substring(retval.Length - 2, 2) == "\r\n") retval = retval.Remove(retval.Length - 2, 2); - + if (retval.EndsWith("\r\n")) retval = retval.Remove(retval.Length - 2, 2); if (retval.Length == 0) return ""; - if (retval.Substring(retval.Length - 2, 2) == @"\v") retval = retval.Remove(retval.Length - 2, 2); + if (retval.EndsWith(@"\v")) retval = retval.Remove(retval.Length - 2, 2); retval = _MyItemInfo.RemoveRtfStyles(retval); // RemoveRtfStyles(retval); retval = retval.Replace(@"(![", @"\{"); retval = retval.Replace(@"(!]", @"\}"); diff --git a/PROMS/Volian.Controls.Library/StepItem.cs b/PROMS/Volian.Controls.Library/StepItem.cs index d503fde0..be177fff 100644 --- a/PROMS/Volian.Controls.Library/StepItem.cs +++ b/PROMS/Volian.Controls.Library/StepItem.cs @@ -1009,7 +1009,6 @@ namespace Volian.Controls.Library newFocus.AdjustLocation(); //newFocus.ShowTops(""); } - public StepItem DeleteItem() { StepItem newFocus = null; @@ -2053,6 +2052,7 @@ namespace Volian.Controls.Library { get { + if(RNOLevel == 0)return null; if (MyParentStepItem != null) { if (MyParentStepItem.RNOLevel < RNOLevel) @@ -2060,10 +2060,12 @@ namespace Volian.Controls.Library else return MyParentStepItem.AERStepItem; } - else + else if (MyPreviousStepItem != null) { return MyPreviousStepItem.AERStepItem; } + //Volian.Base.Library.vlnStackTrace.ShowStackLocal("'AERStepItem',{0},{1}", MyID, MyItemInfo.DBSequence); + return null; } } /// @@ -2071,8 +2073,10 @@ namespace Volian.Controls.Library /// internal void AdjustLocation() { + //Console.WriteLine("'AdjustLocation',{0},{1},'{2}'", MyID, MyItemInfo.DBSequence, Volian.Base.Library.vlnStackTrace.CalledFrom4); if (RNORight) MoveRNO(); // This is needed when an AER is Deleted that has an RNO. - if (RNOLevel>0) AERStepItem.AdjustLocation(); + if (RNOLevel > 0 && AERStepItem != null) + AERStepItem.AdjustLocation(); StepItem nextStepItem = NextDownStepItem; //if (MyID == 2138) // Console.WriteLine("2138"); diff --git a/PROMS/Volian.Controls.Library/StepPanel.cs b/PROMS/Volian.Controls.Library/StepPanel.cs index cb89f0ef..1a8e375c 100644 --- a/PROMS/Volian.Controls.Library/StepPanel.cs +++ b/PROMS/Volian.Controls.Library/StepPanel.cs @@ -713,16 +713,14 @@ namespace Volian.Controls.Library break; case E_ArrowKeys.Down: case E_ArrowKeys.CtrlDown: - ii = ArrowDown(rtb.MyItemInfo); - // The following lines are debug to check that the results of moving down and moving up are the same - //ix = ArrowUp(ii); - //Console.WriteLine("'Down',{0},{1},{2},{3}", rtb.MyItemInfo.ItemID, rtb.MyItemInfo.DBSequence, ii.DBSequence, ix.DBSequence); - if (ii != null) SelectedStepRTB = _LookupStepItems[ii.ItemID].MyStepRTB; + ii = MoveDown(rtb, ii); break; case E_ArrowKeys.Right: case E_ArrowKeys.CtrlRight: if (rtb.MyItemInfo.RNOs != null) SelectedStepRTB = _LookupStepItems[rtb.MyItemInfo.RNOs[0].ItemID].MyStepRTB; + else + ii = MoveDown(rtb, ii); break; case E_ArrowKeys.Left: case E_ArrowKeys.CtrlLeft: @@ -733,6 +731,16 @@ namespace Volian.Controls.Library break; } } + + private ItemInfo MoveDown(StepRTB rtb, ItemInfo ii) + { + ii = ArrowDown(rtb.MyItemInfo); + // The following lines are debug to check that the results of moving down and moving up are the same + //ix = ArrowUp(ii); + //Console.WriteLine("'Down',{0},{1},{2},{3}", rtb.MyItemInfo.ItemID, rtb.MyItemInfo.DBSequence, ii.DBSequence, ix.DBSequence); + if (ii != null) SelectedStepRTB = _LookupStepItems[ii.ItemID].MyStepRTB; + return ii; + } private ItemInfo ArrowUp(ItemInfo ii) { // Arrow-Up from a Substep should look for a Table. diff --git a/PROMS/Volian.Controls.Library/StepRTB.cs b/PROMS/Volian.Controls.Library/StepRTB.cs index 6003d7d0..15914326 100644 --- a/PROMS/Volian.Controls.Library/StepRTB.cs +++ b/PROMS/Volian.Controls.Library/StepRTB.cs @@ -1585,7 +1585,7 @@ namespace Volian.Controls.Library pos.Y = ClientRectangle.Height; int lastIndex = this.GetCharIndexFromPosition(pos); int lastLine = this.GetLineFromCharIndex(lastIndex); - if (e.Control || l == lastLine) + if (e.Control || l >= lastLine) { StepRTB_ArrowPressed(e.Control ? E_ArrowKeys.CtrlDown : E_ArrowKeys.Down); HandleLocalSelectionChange(); @@ -1729,7 +1729,7 @@ namespace Volian.Controls.Library } private void StepRTB_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e) { - if (!ReadOnly) + if (!ReadOnly) { // add the character with its font depending on the char.... if (!IsControlChar)