4344 lines
		
	
	
		
			179 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			4344 lines
		
	
	
		
			179 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
| using System;
 | ||
| using System.ComponentModel;
 | ||
| using System.Collections.Generic;
 | ||
| using System.Diagnostics;
 | ||
| using System.Text;
 | ||
| using System.Drawing;
 | ||
| using System.Windows.Forms;
 | ||
| using System.Text.RegularExpressions;
 | ||
| using VEPROMS.CSLA.Library;
 | ||
| using Volian.Base.Library;
 | ||
| using JR.Utils.GUI.Forms;
 | ||
| using System.Linq;
 | ||
| 
 | ||
| namespace Volian.Controls.Library
 | ||
| {
 | ||
| 	#region Enums
 | ||
| 	public enum ChildRelation : int
 | ||
| 	{
 | ||
| 		None = 0,
 | ||
| 		After = 1,
 | ||
| 		Before = 2,
 | ||
| 		RNO = 3,
 | ||
| 		SupInfo = 4
 | ||
| 	}
 | ||
| 	public enum E_ChangeBarPosition : int
 | ||
| 	{
 | ||
| 		Left = 0,
 | ||
| 		Right = 1
 | ||
| 	}
 | ||
| 	#endregion
 | ||
| 	public abstract partial class EditItem : UserControl
 | ||
| 	{
 | ||
| 		#region EditItemUnique
 | ||
| 		//private static int _EditItemUnique = 0;
 | ||
| 		//private static int EditItemUnique
 | ||
| 		//{
 | ||
| 		//    get
 | ||
| 		//    {
 | ||
| 		//        if (_EditItemUnique == 3)
 | ||
| 		//            Console.WriteLine("here");
 | ||
| 		//        return ++_EditItemUnique;
 | ||
| 		//    }
 | ||
| 		//}
 | ||
| 		//private int _MyEditItemUnique = EditItemUnique;
 | ||
| 
 | ||
| 		//public int MyEditItemUnique
 | ||
| 		//{
 | ||
| 		//    get {return _MyEditItemUnique; }
 | ||
| 		//}
 | ||
| 		#endregion
 | ||
| 		#region Constructor
 | ||
| 		public EditItem()
 | ||
| 		{
 | ||
| 			InitializeComponent();
 | ||
| 			this.Enter += EditItem_Enter;
 | ||
| 		}
 | ||
| 
 | ||
| 		// This event was added to better control enabling or disabling of the Insert and Copy Step buttons on the ribbon
 | ||
| 		void EditItem_Enter(object sender, EventArgs e)
 | ||
| 		{
 | ||
| 			bool allow = (MyStepPanel.VwMode == E_ViewMode.Edit);
 | ||
| 			StepTabRibbon str = MyStepPanel.MyStepTabPanel.MyStepTabRibbon;
 | ||
| 			str.SiblingsButtonsEnabled = allow;
 | ||
| 			str.InsertButtonsEnabled = allow && !(MyItemInfo.IsProcedure || MyItemInfo.IsSection || MyItemInfo.IsRNOPart || MyItemInfo.IsSupInfoPart);
 | ||
| 			// do special case for cpystep button:  cannot copy an enhanced step and can copy a supinfo
 | ||
| 			if (MyItemInfo.IsEnhancedStep) str.SetCopyStepButton(false);
 | ||
| 			if (MyItemInfo.IsSupInfoPart) str.SetCopyStepButton(allow);
 | ||
| 			if (MyItemInfo.IsRNOPart) str.SetCopyStepButton(allow); //B2019-009 allow the selection of an RNO step type for CopyStep
 | ||
| 		}
 | ||
| 
 | ||
| 		public EditItem(IContainer container)
 | ||
| 		{
 | ||
| 			container.Add(this);
 | ||
| 			InitializeComponent();
 | ||
| 			this.Enter += EditItem_Enter;
 | ||
| 		}
 | ||
| 		#endregion
 | ||
| 		#region Properties
 | ||
| 		private bool _RTBLastFocus = true;
 | ||
| 		public bool RTBLastFocus
 | ||
| 		{
 | ||
| 			get { return _RTBLastFocus; }
 | ||
| 			set { _RTBLastFocus = value; }
 | ||
| 		}
 | ||
| 		protected static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
 | ||
| 		protected ChildRelation _MyChildRelation;
 | ||
| 		public ChildRelation MyChildRelation
 | ||
| 		{
 | ||
| 			get { return _MyChildRelation; }
 | ||
| 			set { _MyChildRelation = value; }
 | ||
| 		}
 | ||
| 		protected bool _Loading = true;
 | ||
| 		protected EditItem _MyParentEditItem = null;
 | ||
| 		protected EditItem _MySectionRTBItem;
 | ||
| 		protected EditItem _MyPreviousEditItem = null;
 | ||
| 		protected EditItem _MyNextEditItem = null;
 | ||
| 		private bool _ChildrenLoaded = false;
 | ||
| 		public bool HasChildren
 | ||
| 		{
 | ||
| 			get { return _MyBeforeEditItems != null || _MyRNOEditItems != null || _MyAfterEditItems != null; }
 | ||
| 		}
 | ||
| 		internal List<EditItem> _MyBeforeEditItems;
 | ||
| 		public List<EditItem> MyBeforeEditItems					// MyBeforeEditItems are Cautions & Notes
 | ||
| 		{
 | ||
| 			get { return _MyBeforeEditItems; }
 | ||
| 			set { _MyBeforeEditItems = value; }
 | ||
| 		}
 | ||
| 		internal List<EditItem> _MyAfterEditItems;
 | ||
| 		public List<EditItem> MyAfterEditItems
 | ||
| 		{
 | ||
| 			get { return _MyAfterEditItems; }
 | ||
| 			set { _MyAfterEditItems = value; }
 | ||
| 		}
 | ||
| 		internal List<EditItem> _MyRNOEditItems;
 | ||
| 		public List<EditItem> MyRNOEditItems
 | ||
| 		{
 | ||
| 			get { return _MyRNOEditItems; }
 | ||
| 			set { _MyRNOEditItems = value; }
 | ||
| 		}
 | ||
| 		internal List<EditItem> _MySupInfoEditItems;
 | ||
| 		public List<EditItem> MySupInfoEditItems
 | ||
| 		{
 | ||
| 			get { return _MySupInfoEditItems; }
 | ||
| 			set { _MySupInfoEditItems = value; }
 | ||
| 		}
 | ||
| 		private StepSectionLayoutData _MyStepSectionLayoutData;
 | ||
| 		public StepSectionLayoutData MyStepSectionLayoutData
 | ||
| 		{
 | ||
| 			get { return _MyStepSectionLayoutData; }
 | ||
| 			set { _MyStepSectionLayoutData = value; }
 | ||
| 		}
 | ||
| 		private StepData _MyStepData;
 | ||
| 		public StepData MyStepData
 | ||
| 		{
 | ||
| 			get { return _MyStepData; }
 | ||
| 			set { _MyStepData = value; }
 | ||
| 		}
 | ||
| 		private ItemInfo _MyItemInfo;
 | ||
| 		private int _ExpandPrefix = 0;
 | ||
| 		public int ExpandPrefix
 | ||
| 		{
 | ||
| 			get { return _ExpandPrefix; }
 | ||
| 			set { _ExpandPrefix = value; }
 | ||
| 		}
 | ||
| 		private bool _Colapsing = false;
 | ||
| 		/// <summary>
 | ||
| 		/// Gets or sets colapsing
 | ||
| 		/// </summary>
 | ||
| 		public bool Colapsing
 | ||
| 		{
 | ||
| 			get { return _Colapsing; }
 | ||
| 			set { _Colapsing = value; }
 | ||
| 		}
 | ||
| 		private bool _Moving = false;
 | ||
| 		private int _RNOLevel = 0;
 | ||
| 		private int _SeqLevel = 0;
 | ||
| 		private int _ContentType;
 | ||
| 		public int ContentType
 | ||
| 		{
 | ||
| 			get { return _ContentType; }
 | ||
| 			set { _ContentType = value; }
 | ||
| 		}
 | ||
| 		private bool _Circle = false;
 | ||
| 		private bool _CheckOff = false;
 | ||
| 		private bool _UserCheckOff = false;
 | ||
| 		private bool _ChangeBar = false;
 | ||
| 		private StepPanel _MyStepPanel;
 | ||
| 		public StepPanel MyStepPanel
 | ||
| 		{
 | ||
| 			get { return _MyStepPanel; }
 | ||
| 			set { _MyStepPanel = value; }
 | ||
| 		}
 | ||
| 
 | ||
| 		private DisplayTags _MyStepPropertiesPanel;
 | ||
| 		public DisplayTags MyStepPropertiesPanel // gives us access to the Step Properties panel - used with shortcut keystrokes
 | ||
| 		{
 | ||
| 			get { return _MyStepPropertiesPanel; }
 | ||
| 			set { _MyStepPropertiesPanel = value; }
 | ||
| 		}
 | ||
| 
 | ||
| 		/// <summary>
 | ||
| 		/// This returns the section or procedure for the current item.
 | ||
| 		/// If the item is a step or section, it returns the section
 | ||
| 		/// If it is a procedure, it returns the procedure 
 | ||
| 		/// </summary>
 | ||
| 		public EditItem MySectionRTBItem
 | ||
| 		{
 | ||
| 			get
 | ||
| 			{
 | ||
| 				if (_MySectionRTBItem == null)
 | ||
| 				{
 | ||
| 					if (MyItemInfo.IsSection || MyItemInfo.IsProcedure) _MySectionRTBItem = (RTBItem)this;
 | ||
| 					else _MySectionRTBItem = MyParent.MySectionRTBItem;
 | ||
| 				}
 | ||
| 				return _MySectionRTBItem;
 | ||
| 			}
 | ||
| 			set { _MySectionRTBItem = value; }
 | ||
| 		}
 | ||
| 		/// <summary>
 | ||
| 		/// Gets or Sets ItemInfo
 | ||
| 		/// </summary>
 | ||
| 		public ItemInfo MyItemInfo
 | ||
| 		{
 | ||
| 			get 
 | ||
| 			{
 | ||
| 				ToolTipOnOff(); //B2025-050 Show the tooltip based on User Options Settings
 | ||
| 				return _MyItemInfo; 
 | ||
| 			}
 | ||
| 			set
 | ||
| 			{
 | ||
| 				_MyItemInfo = value;
 | ||
| 				SetToolTip(_MyItemInfo.ToolTip); // B2025-050 always set tooltip text. This method will also show the tooltip based on User Options Settings
 | ||
| 				ChangeBar = _MyItemInfo.HasChangeBar;
 | ||
| 				CheckOff co = _MyItemInfo.GetCheckOffStep();
 | ||
| 				if (co != null && co.UIMark != null)
 | ||
| 				{
 | ||
| 					UserCheckOff = true;
 | ||
| 					UserCheckOffChar = (char)co.UIMark;
 | ||
| 				}
 | ||
| 				// Deal with changes in content data
 | ||
| 				value.MyContent.Changed -= new ContentInfoEvent(MyContent_Changed);
 | ||
| 				value.MyContent.Changed += new ContentInfoEvent(MyContent_Changed);
 | ||
| 				value.MyProcedure.MyContent.Changed -= new ContentInfoEvent(MyContent_Changed);
 | ||
| 				value.MyProcedure.MyContent.Changed += new ContentInfoEvent(MyContent_Changed);
 | ||
| 				// Deal with change in item data
 | ||
| 				value.Changed -= new ItemInfoEvent(value_Changed);
 | ||
| 				value.Changed += new ItemInfoEvent(value_Changed);
 | ||
| 				value.OrdinalChanged -= new ItemInfoEvent(value_OrdinalChanged);
 | ||
| 				value.OrdinalChanged += new ItemInfoEvent(value_OrdinalChanged);
 | ||
| 				// do something like this to draw circle around step numbers - note got NULL reference error on NSP data
 | ||
| 				//if (value.FormatStepData != null && value.FormatStepData.TabData.IdentPrint.Contains("C0")) Circle = true;
 | ||
| 			}
 | ||
| 		}
 | ||
| 		private bool _ChangeBarForConfigItemChange = true;
 | ||
| 
 | ||
| 		public bool ChangeBarForConfigItemChange
 | ||
| 		{
 | ||
| 			get { return _ChangeBarForConfigItemChange; }
 | ||
| 			set { _ChangeBarForConfigItemChange = value; }
 | ||
| 		}
 | ||
| 
 | ||
| 		void value_Changed(object sender)
 | ||
| 		{
 | ||
| 			ChangeBar = _MyItemInfo.HasChangeBar;
 | ||
| 		}
 | ||
| 		protected void MyContent_Changed(object sender)
 | ||
| 		{
 | ||
| 			// Update the text to reflect the content change
 | ||
| 			MyItemInfo.RefreshItemAnnotations();
 | ||
| 			ChangeBar = MyItemInfo.HasChangeBar;
 | ||
| 			CheckOff co = _MyItemInfo.GetCheckOffStep();
 | ||
| 			if (co != null && co.UIMark != null)
 | ||
| 			{
 | ||
| 				UserCheckOff = true;
 | ||
| 				UserCheckOffChar = (char)co.UIMark;
 | ||
| 			}
 | ||
| 			else
 | ||
| 				UserCheckOff = false;
 | ||
| 			RefreshContent();
 | ||
| 
 | ||
| 			// see if change in subsections to be displayed, i.e. if the user made a change to editable data
 | ||
| 			// on the section properties form, we may have to display steps or remove steps.  By design,
 | ||
| 			// steps are the first children from a section. Also, this will only occur if the format has
 | ||
| 			// metasections AND there are subsections.
 | ||
| 			if (MyItemInfo.IsSection && MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.UseMetaSections
 | ||
| 				&& MyItemInfo.Sections != null && MyItemInfo.Sections.Count > 0)
 | ||
| 			{
 | ||
| 				// find out what the editable flag is to determine if change.
 | ||
| 				bool showSteps = MyItemInfo.MyConfig is SectionConfig && (MyItemInfo.MyConfig as SectionConfig).SubSection_Edit == "Y";
 | ||
| 				if (showSteps && _MyAfterEditItems != null && _MyAfterEditItems.Count > 0 && _MyAfterEditItems[0].MyItemInfo.IsSection)
 | ||
| 				{
 | ||
| 					// need to add steps in, i.e. they do not exist in step editor yet.
 | ||
| 					_MyAfterEditItems[0].AddSiblingBeforeNoDataSave(MyItemInfo.Steps, false);
 | ||
| 				}
 | ||
| 				else if (!showSteps && _MyAfterEditItems != null && _MyAfterEditItems.Count > 0 && _MyAfterEditItems[0].MyItemInfo.IsStep)
 | ||
| 				{
 | ||
| 					// Remove steps - only want sections.  Put in a list for removal.
 | ||
| 					List<EditItem> remEIs = new List<EditItem>();
 | ||
| 					foreach (EditItem ei in _MyAfterEditItems)
 | ||
| 					{
 | ||
| 						if (!ei.MyItemInfo.IsSection) remEIs.Add(ei);
 | ||
| 					}
 | ||
| 					foreach (EditItem ei1 in remEIs)
 | ||
| 					{
 | ||
| 						ei1.RemoveItemWithoutDelete();
 | ||
| 					}
 | ||
| 					remEIs.Clear();
 | ||
| 				}
 | ||
| 			}
 | ||
| 		}
 | ||
| 		void value_OrdinalChanged(object sender)
 | ||
| 		{
 | ||
| 			RefreshOrdinal();
 | ||
| 		}
 | ||
| 		public EditItem ActiveParent
 | ||
| 		{
 | ||
| 			get { return _MyParentEditItem != null ? _MyParentEditItem : _MyPreviousEditItem?.ActiveParent; }
 | ||
| 		}
 | ||
| 		/// <summary>
 | ||
| 		/// Return the Parent EditItem
 | ||
| 		/// </summary>
 | ||
| 		private EditItem UpOneEditItem
 | ||
| 		{
 | ||
| 			get
 | ||
| 			{
 | ||
| 				EditItem tmp = this;
 | ||
| 				while (tmp != null && tmp.MyParentEditItem == null) tmp = tmp.MyPreviousEditItem;
 | ||
| 				if (tmp != null) return tmp.MyParentEditItem;
 | ||
| 				return null;
 | ||
| 			}
 | ||
| 		}
 | ||
| 		private Stack<string> _LastMethods = new Stack<string>();
 | ||
| 		//private string _LastMethod = "";
 | ||
| 		internal void LastMethodsPush(string str)
 | ||
| 		{
 | ||
| 			if (MyStepPanel != null) MyStepPanel._LastAdjust = str;
 | ||
| 			_LastMethods.Push(str);
 | ||
| 		}
 | ||
| 		internal string LastMethodsPop()
 | ||
| 		{
 | ||
| 			//MyStepPanel._LastAdjust = "";
 | ||
| 			return _LastMethods.Pop();
 | ||
| 		}
 | ||
| 		internal bool LastMethodsEmpty
 | ||
| 		{
 | ||
| 			get { return _LastMethods.Count == 0; }
 | ||
| 		}
 | ||
| 		// This should find the item that precedes the current item vertically in the supplemental information column
 | ||
| 		// and then return the Bottom of that item.
 | ||
| 		// It is used so that an edit item does not overlap in 'y-direction' any preceding items.
 | ||
| 		internal int? FindTopSupInfo(bool useSuppInfoColBottom)
 | ||
| 		{
 | ||
| 			if (MyParentEditItem == null) return null;
 | ||
| 			// on supplemental info item:  parent is item in left column.
 | ||
| 			// return null if parent does not have previous siblings or parents that have supp info.  FindPreviousOrParentSupInfo looks above to
 | ||
| 			// items that have supinfo.
 | ||
| 			EditItem prevOrParSupInfo = MyParentEditItem.FindPreviousOrParentSupInfo();
 | ||
| 			if (prevOrParSupInfo == null || !prevOrParSupInfo.Visible)
 | ||
| 			{
 | ||
| 				// Account for Expanded or collapsed.  note that BottomMostEditItem already accounts for
 | ||
| 				// 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;
 | ||
| 			}
 | ||
| 			int b1 = prevOrParSupInfo.BottomMostEditItem.Bottom;
 | ||
| 			int b2 = b1;
 | ||
| 			if (prevOrParSupInfo.MyParentEditItem.MyItemInfo.StepLevel > MyParentEditItem.MyItemInfo.StepLevel)
 | ||
| 				b2 = prevOrParSupInfo.MyParentEditItem.LastSiblingEditItem.BottomMostEditItem.Bottom;
 | ||
| 
 | ||
| 			// if the current supinfo's parent (proc step) is same as the lastsibling bottom most, don't use its value - it puts the next step
 | ||
| 			// down too far:
 | ||
| 			if (this.MyParentEditItem.MyID == prevOrParSupInfo.MyParentEditItem.LastSiblingEditItem.BottomMostEditItem.MyID) b2 = b1;
 | ||
| 			// if not in the same HLS, don't use the lastsibling either:
 | ||
| 			if (this.MyParentEditItem.MyItemInfo.MyHLS.ItemID != prevOrParSupInfo.MyParentEditItem.LastSiblingEditItem.MyItemInfo.MyHLS.ItemID) b2 = b1;
 | ||
| 			if (useSuppInfoColBottom)
 | ||
| 				return b1;
 | ||
| 			else
 | ||
| 				return Math.Max(b1, b2);	// look at both supinfo & parent column to determine bottom
 | ||
| 		}
 | ||
| 		// This goes up edititems, looking for the closest in 'y-direction' of any supplemental info items.
 | ||
| 		EditItem FindPreviousOrParentSupInfo()  // current edit item is parent of supplmental info item
 | ||
| 		{
 | ||
| 			EditItem prev = this;
 | ||
| 			// First see if there are any Cautions or Notes before me that have supinfo:
 | ||
| 			EditItem lastBefore = prev.FindLastBeforeWithSupInfo();
 | ||
| 			if (lastBefore != null) return lastBefore.MySupInfoEditItems[0];
 | ||
| 
 | ||
| 			// There were no Cautions/Notes before me with supinfo, now see if there are previous items with supinfo:
 | ||
| 			while (prev.MyPreviousEditItem != null)
 | ||
| 			{
 | ||
| 				prev = prev.MyPreviousEditItem;
 | ||
| 				EditItem eiTmp = prev.FindLastSubstepWithSupInfo();
 | ||
| 				// check for MySupInfoEditItems as null because the FindLastSubstepWithSupInfo checks for data, but the supinfo step may
 | ||
| 				// not be displayed yet, i.e. the eiTmp.MySupInfoEditItems has an edititem defined only it if is displayed.
 | ||
| 				if (eiTmp != null && eiTmp.MySupInfoEditItems != null) return eiTmp.MySupInfoEditItems[0];
 | ||
| 			}
 | ||
| 			// No previous items had supinfo, look up to the parent. But if on first before, i.e. first caution or note, there is nothing before (just the section)
 | ||
| 			if (prev.MyParentEditItem.MyBeforeEditItems != null && prev.MyParentEditItem.MyBeforeEditItems.Count > 0 && prev.MyParentEditItem.MyBeforeEditItems[0] == prev)
 | ||
| 			{
 | ||
| 				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();
 | ||
| 				return eitmp;
 | ||
| 			}
 | ||
| 			if (prev.MyParentEditItem.MySupInfoEditItems != null) return prev.MyParentEditItem.MySupInfoEditItems[0];
 | ||
| 			if (prev.MyItemInfo.IsSection) return null;
 | ||
| 			return prev.MyParentEditItem.FindPreviousOrParentSupInfo();
 | ||
| 		}
 | ||
| 		private EditItem FindLastBeforeWithSupInfo()
 | ||
| 		{
 | ||
| 			if (MyBeforeEditItems == null || MyBeforeEditItems.Count == 0) return null;
 | ||
| 
 | ||
| 			for (int i = MyBeforeEditItems.Count - 1; i > -1; i--)
 | ||
| 			{
 | ||
| 				// Need to look at caution/note (mybeforeedititems) if they have substeps that have supinfo
 | ||
| 				if (MyBeforeEditItems[i].MySupInfoEditItems != null && MyBeforeEditItems[i].MySupInfoEditItems.Count > 0) return MyBeforeEditItems[i];
 | ||
| 			}
 | ||
| 			return null;
 | ||
| 		}
 | ||
| 		// The next 2 methods, FindLastSubstepWithSupInfo, FindLastItemWithSupInfo:
 | ||
| 		// for the current item, get to its bottommost supplemental info, if any steps/substeps have it.
 | ||
| 		// 
 | ||
| 		private EditItem FindLastSubstepWithSupInfo()
 | ||
| 		{
 | ||
| 			ItemInfo ii = FindLastItemWithSupInfo(MyItemInfo);
 | ||
| 			if (ii == null) return null;
 | ||
| 			return GetEditItemFromItemID(ii.ItemID);
 | ||
| 		}
 | ||
| 		private ItemInfo FindLastItemWithSupInfo(ItemInfo stp)
 | ||
| 		{
 | ||
| 			// first check substeps (& their substeps) of item passed in.
 | ||
| 			if (stp.Steps != null && stp.Steps.Count > 0)
 | ||
| 			{
 | ||
| 				for (int i = stp.Steps.Count - 1; i > -1; i--)
 | ||
| 				{
 | ||
| 					ItemInfo tmp = FindLastItemWithSupInfo(stp.Steps[i]);
 | ||
| 					if (tmp != null) return tmp;
 | ||
| 				}
 | ||
| 			}
 | ||
| 			//now check the step that was passed in.
 | ||
| 			if (stp.SupInfos != null && stp.SupInfos.Count > 0) return stp;
 | ||
| 			if (stp.Notes != null && stp.Notes.Count > 0)
 | ||
| 			{
 | ||
| 				for (int j = stp.Notes.Count - 1; j > -1; j--)
 | ||
| 				{
 | ||
| 					if (stp.Notes[j].SupInfos != null && stp.Notes[j].SupInfos.Count > 0) return stp.Notes[j];
 | ||
| 				}
 | ||
| 			}
 | ||
| 			if (stp.Cautions != null && stp.Cautions.Count > 0)
 | ||
| 			{
 | ||
| 				for (int j = stp.Cautions.Count - 1; j > -1; j--)
 | ||
| 				{
 | ||
| 					if (stp.Cautions[j].SupInfos != null && stp.Cautions[j].SupInfos.Count > 0) return stp.Cautions[j];
 | ||
| 				}
 | ||
| 			}
 | ||
| 			return null;
 | ||
| 		}
 | ||
| 		/// <summary>
 | ||
| 		/// This should find the item that precedes the current item vertically
 | ||
| 		/// and then return the Bottom of that item.
 | ||
| 		/// </summary>
 | ||
| 		/// <returns></returns>
 | ||
| 		internal int FindTop(int bottom, bool test1)
 | ||
| 		{
 | ||
| 			// if on a supplemental info, use special code to find what steps are above the supplemental info
 | ||
| 			if (MyItemInfo.MyDocStyle != null && MyItemInfo.MyDocStyle.SupplementalInformation)
 | ||
| 			{
 | ||
| 				if (MyItemInfo.IsSupInfoPart)
 | ||
| 				{
 | ||
| 					int? tmptop = FindTopSupInfo(test1);
 | ||
| 					return tmptop == null ? bottom : Math.Max(bottom, (int)tmptop);
 | ||
| 				}
 | ||
| 			}
 | ||
| 			int lastBottomPrev = bottom;  // This is necessary if the value of bottom can be negative.
 | ||
| 			if (_MyPreviousEditItem != null)
 | ||
| 				lastBottomPrev = _MyPreviousEditItem.BottomMostEditItem.Bottom;
 | ||
| 			int? bottomRNO = BottomOfParentRNO();
 | ||
| 			if (lastBottomPrev > bottom) bottom = (int)(lastBottomPrev); // RHM 20090615 ES02 Step8
 | ||
| 			// Moving from Step 8 to the Note preceeding step 8 caused the step 9 to be positioned in the wrong place.
 | ||
| 			//if (lastBottomParent > bottom) bottom = lastBottomParent;
 | ||
| 			//if (bottomRNO == null) return bottom;
 | ||
| 			return (int)max(bottomRNO, bottom);
 | ||
| 		}
 | ||
| 		internal int FindTop(int bottom)
 | ||
| 		{
 | ||
| 			return FindTop(bottom, true);
 | ||
| 		}
 | ||
| 		/// <summary>
 | ||
| 		/// The Top of the EditItem
 | ||
| 		/// </summary>
 | ||
| 		public int ItemTop
 | ||
| 		{
 | ||
| 			get { return Top; }
 | ||
| 			set
 | ||
| 			{
 | ||
| 				MyStepPanel.ItemMoving++;
 | ||
| 				Top = value;
 | ||
| 				MyStepPanel.ItemMoving--;
 | ||
| 			}
 | ||
| 		}
 | ||
| 		private E_ChangeBarPosition _ChangeBarPosition = E_ChangeBarPosition.Right;
 | ||
| 		public E_ChangeBarPosition ChangeBarPosition
 | ||
| 		{
 | ||
| 			get { return _ChangeBarPosition; }
 | ||
| 			set { _ChangeBarPosition = value; }
 | ||
| 		}
 | ||
| 		/// <summary>
 | ||
| 		/// Sets the next item and adjusts the location,
 | ||
| 		/// This also sets the previous for the "next" item
 | ||
| 		/// which adjusts other locations.
 | ||
| 		/// </summary>
 | ||
| 		public EditItem MyNextEditItem
 | ||
| 		{
 | ||
| 			get { return _MyNextEditItem; }
 | ||
| 			set
 | ||
| 			{
 | ||
| 				_MyNextEditItem = value;
 | ||
| 				if (_MyNextEditItem != null)
 | ||
| 				{
 | ||
| 					if (_MyNextEditItem.MyPreviousEditItem != this)
 | ||
| 					{
 | ||
| 						_MyNextEditItem.MyPreviousEditItem = this;
 | ||
| 						MyNextEditItem.Location = new Point(Left, Bottom);
 | ||
| 					}
 | ||
| 				}
 | ||
| 			}
 | ||
| 		}
 | ||
| 		/// <summary>
 | ||
| 		/// returns the TopMostChild
 | ||
| 		/// </summary>
 | ||
| 		public EditItem TopMostEditItem
 | ||
| 		{
 | ||
| 			get
 | ||
| 			{
 | ||
| 				if (Expanded && _MyBeforeEditItems != null) return _MyBeforeEditItems[0].TopMostEditItem;
 | ||
| 				return this;
 | ||
| 			}
 | ||
| 		}
 | ||
| 		/// <summary>
 | ||
| 		/// Returns the bottom location (Top + Height)
 | ||
| 		/// </summary>
 | ||
| 		public new int Bottom
 | ||
| 		{
 | ||
| 			get
 | ||
| 			{
 | ||
| 				return Top + (Hidden ? 0 : Height);
 | ||
| 			}
 | ||
| 		}
 | ||
| 		private bool _Hidden = false;
 | ||
| 		public bool Hidden
 | ||
| 		{
 | ||
| 			get { return _Hidden; }
 | ||
| 			set { _Hidden = value; Visible = !value; }
 | ||
| 		}
 | ||
| 		/// <summary>
 | ||
| 		/// Bottom most child
 | ||
| 		/// </summary>
 | ||
| 		public EditItem BottomMostEditItem
 | ||
| 		{
 | ||
| 			get
 | ||
| 			{
 | ||
| 				EditItem tmpr = null; // BottomMost RNO
 | ||
| 				//int rnoOffset = 0;
 | ||
| 				if ((MyExpandingStatus != ExpandingStatus.No || Expanded) && _MyRNOEditItems != null)
 | ||
| 				{
 | ||
| 					//rnoOffset = this.Top - _MyRNOEditItems[0].Top;
 | ||
| 					tmpr = _MyRNOEditItems[_MyRNOEditItems.Count - 1].BottomMostEditItem;
 | ||
| 				}
 | ||
| 				EditItem tmpa = this; // BottomMost After
 | ||
| 				if ((MyExpandingStatus != ExpandingStatus.No || Expanded) & _MyAfterEditItems != null)
 | ||
| 					tmpa = _MyAfterEditItems[_MyAfterEditItems.Count - 1].BottomMostEditItem;
 | ||
| 				// return the bottom most of the two results
 | ||
| 				if (tmpr == null)
 | ||
| 					return tmpa;
 | ||
| 				//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;
 | ||
| 			}
 | ||
| 		}
 | ||
| 		/// <summary>
 | ||
| 		/// Bottom most child excluding RNOs
 | ||
| 		/// </summary>
 | ||
| 		public EditItem BottomMostEditItemNoRNOs
 | ||
| 		{
 | ||
| 			get
 | ||
| 			{
 | ||
| 				EditItem tmpa = this; // BottomMost After
 | ||
| 				if ((MyExpandingStatus != ExpandingStatus.No || Expanded) & _MyAfterEditItems != null)
 | ||
| 					tmpa = _MyAfterEditItems[_MyAfterEditItems.Count - 1].BottomMostEditItem;
 | ||
| 				// return the bottom most 
 | ||
| 				return tmpa;
 | ||
| 			}
 | ||
| 		}
 | ||
| 		/// <summary>
 | ||
| 		/// First sibling
 | ||
| 		/// </summary>
 | ||
| 		private EditItem FirstSiblingEditItem
 | ||
| 		{
 | ||
| 			get
 | ||
| 			{
 | ||
| 				EditItem tmp = this;
 | ||
| 				while (tmp.MyPreviousEditItem != null)
 | ||
| 					tmp = tmp.MyPreviousEditItem;
 | ||
| 				return tmp;
 | ||
| 			}
 | ||
| 		}
 | ||
| 		/// <summary>
 | ||
| 		/// Last sibling
 | ||
| 		/// </summary>
 | ||
| 		private EditItem LastSiblingEditItem
 | ||
| 		{
 | ||
| 			get
 | ||
| 			{
 | ||
| 				EditItem tmp = this;
 | ||
| 				while (tmp.MyNextEditItem != null)
 | ||
| 					tmp = tmp.MyNextEditItem;
 | ||
| 				return tmp;
 | ||
| 			}
 | ||
| 		}
 | ||
| 		private ExpandingStatus _MyExpandingStatus = ExpandingStatus.No;
 | ||
| 		/// <summary>
 | ||
| 		/// Sets or Gets expanding status
 | ||
| 		/// </summary>
 | ||
| 		public ExpandingStatus MyExpandingStatus
 | ||
| 		{
 | ||
| 			get { return _MyExpandingStatus; }
 | ||
| 			set { _MyExpandingStatus = value; }
 | ||
| 		}
 | ||
| 		/// <summary>
 | ||
| 		/// Gets the ItemID from the ItemInfo
 | ||
| 		/// </summary>
 | ||
| 		public int MyID
 | ||
| 		{
 | ||
| 			get { return _MyItemInfo == null ? 0 : _MyItemInfo.ItemID; }
 | ||
| 		}
 | ||
| 		/// <summary>
 | ||
| 		/// Tracks when a EditItem is moving
 | ||
| 		/// </summary>
 | ||
| 		public bool Moving
 | ||
| 		{
 | ||
| 			get { return _Moving; }
 | ||
| 			set { _Moving = value; }
 | ||
| 		}
 | ||
| 		/// <summary>
 | ||
| 		/// The RNO (Contingency) Level  
 | ||
| 		/// </summary>
 | ||
| 		public int RNOLevel
 | ||
| 		{
 | ||
| 			get { return _RNOLevel; }
 | ||
| 			set { _RNOLevel = value; }
 | ||
| 		}
 | ||
| 		/// <summary>
 | ||
| 		/// Sequential Level - Only counts levels of Sequential substeps
 | ||
| 		/// </summary>
 | ||
| 		public int SeqLevel
 | ||
| 		{
 | ||
| 			get { return _SeqLevel; }
 | ||
| 			set { _SeqLevel = value; }
 | ||
| 		}
 | ||
| 		// TODO:  This should be changed to get the Circle format from the data
 | ||
| 		/// <summary>
 | ||
| 		/// Show a circle or not
 | ||
| 		/// </summary>
 | ||
| 		public bool Circle
 | ||
| 		{
 | ||
| 			get { return _Circle; }
 | ||
| 			set { _Circle = value; }
 | ||
| 		}
 | ||
| 		// TODO: This should be changed to get the Checkoff status from the data
 | ||
| 		/// <summary>
 | ||
| 		/// Has a check-off or not
 | ||
| 		/// </summary>
 | ||
| 		public bool CheckOff
 | ||
| 		{
 | ||
| 			get { return _CheckOff; }
 | ||
| 			set { _CheckOff = value; }
 | ||
| 		}
 | ||
| 		public bool UserCheckOff
 | ||
| 		{
 | ||
| 			get { return _UserCheckOff; }
 | ||
| 			set { _UserCheckOff = value; }
 | ||
| 		}
 | ||
| 		private char _UserCheckOffChar;
 | ||
| 		public char UserCheckOffChar
 | ||
| 		{
 | ||
| 			get { return _UserCheckOffChar; }
 | ||
| 			set { _UserCheckOffChar = value; }
 | ||
| 		}
 | ||
| 		// TODO: This should be changed to get the ChangeBar status from the data
 | ||
| 		/// <summary>
 | ||
| 		/// Has a changebar or not
 | ||
| 		/// </summary>
 | ||
| 		public bool ChangeBar
 | ||
| 		{
 | ||
| 			get { return _ChangeBar; }
 | ||
| 			set
 | ||
| 			{
 | ||
| 				_ChangeBar = value;
 | ||
| 				this.Invalidate();
 | ||
| 			}
 | ||
| 		}
 | ||
| 		#endregion // Properties
 | ||
| 		#region AddItem
 | ||
| 		/// <summary>
 | ||
| 		/// Adds an item to a list
 | ||
| 		/// </summary>
 | ||
| 		/// <param name="parentEditItem">Parent Container</param>
 | ||
| 		/// <param name="siblingEditItems">EditItem List</param>
 | ||
| 		public void AddItem(EditItem parentEditItem, ref List<EditItem> siblingEditItems, EditItem nextEditItem, bool addFirstChld)
 | ||
| 		{
 | ||
| 			if (siblingEditItems == null) // Create a list of siblings
 | ||
| 			{
 | ||
| 				siblingEditItems = new List<EditItem>();
 | ||
| 				siblingEditItems.Add(this);
 | ||
| 				MyParentEditItem = parentEditItem;
 | ||
| 			}
 | ||
| 			else // Add to the existing list
 | ||
| 			{
 | ||
| 				// add first child, when there are other children already there.  This is used
 | ||
| 				// for metasection editable data changed from off to on so that the first step is located
 | ||
| 				// in the editor correctly, i.e. right below the section & above the subsections.
 | ||
| 				if (addFirstChld)
 | ||
| 				{
 | ||
| 					EditItem parent = siblingEditItems[0].MyParentEditItem;
 | ||
| 					siblingEditItems.Insert(0, this);
 | ||
| 					MyStepPanel.ItemMoving++;
 | ||
| 					_MyNextEditItem = siblingEditItems[1];
 | ||
| 					_MyNextEditItem._MyPreviousEditItem = this;
 | ||
| 					MyPreviousEditItem = null;
 | ||
| 					_MyNextEditItem.MyParentEditItem = null;
 | ||
| 					MyParentEditItem = parent;
 | ||
| 					MyStepPanel.ItemMoving--;
 | ||
| 				}
 | ||
| 				else if (nextEditItem == null) // Add to the end of the list
 | ||
| 				{
 | ||
| 					EditItem lastChild = LastChild(siblingEditItems);
 | ||
| 					siblingEditItems.Add(this);
 | ||
| 					MyPreviousEditItem = lastChild;
 | ||
| 					// RHM - The following line was remove for Facing Pages (Supplemental Information)
 | ||
| 					// *******************************************************************************
 | ||
| 					// When MyPreviousEditItem is set, the location and size is set as a side-effect.
 | ||
| 					// When MyParentEditItem is set, the location and size is set as a side effect.
 | ||
| 					// Only Previous or Parent should be set, no both.
 | ||
| 					// *******************************************************************************
 | ||
| 					//MyParentEditItem = MyPreviousEditItem.MyParentEditItem;  // Farley - part of bug fix B2015-123 alignment of tabs on the edit screen 
 | ||
| 				}
 | ||
| 				else // Add to the middle of the list before a particular item
 | ||
| 				{
 | ||
| 					EditItem prevChild = nextEditItem.MyPreviousEditItem;
 | ||
| 					EditItem parent = nextEditItem.MyParentEditItem;
 | ||
| 					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)
 | ||
| 						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)
 | ||
| 						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--;
 | ||
| 				}
 | ||
| 			}
 | ||
| 			if (MyItemInfo.IsCaution || MyItemInfo.IsNote)
 | ||
| 			{
 | ||
| 				EditItem prev = this;
 | ||
| 				while (prev.MyPreviousEditItem != null) prev = prev.MyPreviousEditItem;
 | ||
| 				prev.SetAllTabs();
 | ||
| 			}
 | ||
| 			else
 | ||
| 				SetAllTabs();
 | ||
| 		}
 | ||
| 		// clear tabs, clears then all so that next 'get' will calculate new.
 | ||
| 		public void SetAllTabs()
 | ||
| 		{
 | ||
| 				RefreshTab();
 | ||
| 
 | ||
| 			if (_MyAfterEditItems != null) _MyAfterEditItems[0].SetAllTabs();	// B2020-043: used to loop through all, but then recursion would redo.
 | ||
| 			if (_MyNextEditItem != null) _MyNextEditItem.SetAllTabs();
 | ||
| 			// Update the RNO tab if it exists - RHM 20100106
 | ||
| 			if (_MyRNOEditItems != null) foreach (EditItem chld in _MyRNOEditItems) chld.SetAllTabs();
 | ||
| 			if (_MySupInfoEditItems != null) foreach (EditItem chld in _MySupInfoEditItems) chld.SetAllTabs();
 | ||
| 		}
 | ||
| 		/// <summary>
 | ||
| 		/// Add the next item to a list
 | ||
| 		/// </summary>
 | ||
| 		/// <param name="myItemInfo"></param>
 | ||
| 		/// <param name="expand"></param>
 | ||
| 		/// <returns></returns>
 | ||
| 		//public EditItem AddNext(ItemInfo myItemInfo, bool expand)
 | ||
| 		//{
 | ||
| 		//  EditItem tmp = new EditItem(myItemInfo, MyStepPanel, MyParentEditItem, ChildRelation.None, expand);
 | ||
| 		//  MyNextEditItem = tmp;
 | ||
| 		//  return tmp;
 | ||
| 		//}
 | ||
| 		#endregion
 | ||
| 		#region RemoveItem
 | ||
| 		protected void ShowTops(string title)
 | ||
| 		{
 | ||
| 			int TopMostY = TopMostEditItem.Top;
 | ||
| 			int? TopMostParentY = (MyParentEditItem == null ? null : (int?)(MyParentEditItem.TopMostEditItem.Top));
 | ||
| 			int? ParentY = (MyParentEditItem == null ? null : (int?)(MyParentEditItem.Top));
 | ||
| 			//Console.Write("{0}: TopMostY={1}, TopMostParentY={2}, ParentY = {3}",title, TopMostY, TopMostParentY, ParentY);
 | ||
| 			Console.Write("{0}{1},{2},{3}", title, TopMostY, TopMostParentY.ToString() ?? "null", ParentY.ToString() ?? "null");
 | ||
| 		}
 | ||
| 		private bool _BeingRemoved = false;
 | ||
| 		public bool BeingRemoved
 | ||
| 		{
 | ||
| 			get { return _BeingRemoved; }
 | ||
| 			set { _BeingRemoved = value; }
 | ||
| 		}
 | ||
| 		public void RemoveItemWithoutDelete()
 | ||
| 		{
 | ||
| 			BeingRemoved = true;
 | ||
| 			int TopMostYBefore = TopMostEditItem.Top;
 | ||
| 			MyStepPanel._LookupEditItems.Remove(MyID);
 | ||
| 			EditItem newFocus = null;
 | ||
| 			int? TopMostParentY = (MyParentEditItem == null ? null : (int?)(MyParentEditItem.TopMostEditItem.Top));
 | ||
| 			int? ParentY = (MyParentEditItem == null ? null : (int?)(MyParentEditItem.Top));
 | ||
| 			RemoveFromParentsChildList();
 | ||
| 			if (MyNextEditItem != null)
 | ||
| 			{
 | ||
| 				if (MyPreviousEditItem != null)
 | ||
| 				{
 | ||
| 					MyNextEditItem.MyPreviousEditItem = MyPreviousEditItem;
 | ||
| 					MyPreviousEditItem = null;
 | ||
| 					newFocus = MyNextEditItem;
 | ||
| 				}
 | ||
| 				else
 | ||
| 				{
 | ||
| 					MyNextEditItem.MyParentEditItem = MyParentEditItem;
 | ||
| 					MyParentEditItem = null;
 | ||
| 					MyNextEditItem.MyPreviousEditItem = null;
 | ||
| 					newFocus = MyNextEditItem;
 | ||
| 				}
 | ||
| 				// Adjust the vertical locations of all of the items below the item deleted
 | ||
| 				MyNextEditItem.TopMostEditItem.AdjustLocation();
 | ||
| 				MyNextEditItem = null;
 | ||
| 			}
 | ||
| 			else if (MyPreviousEditItem != null)
 | ||
| 			{
 | ||
| 				MyPreviousEditItem.MyNextEditItem = null;
 | ||
| 				newFocus = MyPreviousEditItem.BottomMostEditItem;
 | ||
| 				MyPreviousEditItem = null;
 | ||
| 			}
 | ||
| 			else
 | ||
| 			{
 | ||
| 				newFocus = MyParentEditItem;
 | ||
| 				MyParentEditItem = null;
 | ||
| 			}
 | ||
| 			Dispose();
 | ||
| 			if (newFocus != null)
 | ||
| 			{
 | ||
| 				newFocus.SetFocus();
 | ||
| 				newFocus.SetAllTabs();
 | ||
| 				newFocus.AdjustLocation();
 | ||
| 			}
 | ||
| 		}
 | ||
| 		private static int xOffset = 0;
 | ||
| 		public void RemoveItem()
 | ||
| 		{
 | ||
| 			// if this item has enhanced edititems, remove them:
 | ||
| 			StepConfig sc = MyItemInfo.MyConfig as StepConfig;
 | ||
| 			List<EnhancedDocument> thisEnhs = null;
 | ||
| 			if (sc != null)
 | ||
| 				thisEnhs = sc.MyEnhancedDocuments;
 | ||
| 			else
 | ||
| 			{
 | ||
| 				if (MyItemInfo.IsSection)
 | ||
| 				{
 | ||
| 					SectionConfig secc = MyItemInfo.MyConfig as SectionConfig;
 | ||
| 					if (secc.Section_LnkEnh == "Y") thisEnhs = secc.MyEnhancedDocuments;
 | ||
| 				}
 | ||
| 			}
 | ||
| 
 | ||
| 			List<int> enhIds = new List<int>();
 | ||
| 			if (thisEnhs != null)
 | ||
| 			{
 | ||
| 				foreach (EnhancedDocument ed in thisEnhs)
 | ||
| 				{
 | ||
| 					if (ed.Type != 0) enhIds.Add(ed.ItemID);
 | ||
| 				}
 | ||
| 			}
 | ||
| 			BeingRemoved = true;
 | ||
| 			EditItem tmpSelEI = MyStepPanel.SelectedEditItem;       // B2021-002: if can't remove, reset SelectedEditItem
 | ||
| 			MyStepPanel.SelectedEditItem = null; // Unselect the item to be deleted
 | ||
| 			//ShowTops("\r\n");
 | ||
| 			int TopMostYBefore = TopMostEditItem.Top;
 | ||
| 			//_MyTimer.ActiveProcess = "DeleteItem";
 | ||
| 			// Add a Panel temporarily so that AutoScroll will not happen during the delete.
 | ||
| 			Panel pnl = new Panel();
 | ||
| 			pnl.Size = new Size(10, 10);
 | ||
| 			MyStepPanel.Controls.Add(pnl);
 | ||
| 			pnl.BackColor = Color.Red;
 | ||
| 			pnl.Location = new Point(xOffset += 15, MyStepPanel.ClientSize.Height + 10);
 | ||
| 			EditItem newFocus = DeleteItem();
 | ||
| 			if (newFocus == null)
 | ||
| 			{
 | ||
| 				MyStepPanel.Controls.Remove(pnl);
 | ||
| 				MyStepPanel.SelectedEditItem = tmpSelEI;        // B2021-002: if can't remove, reset SelectedEditItem
 | ||
| 				return;
 | ||
| 			}
 | ||
| 			//_MyTimer.ActiveProcess = "SetFocus";
 | ||
| 
 | ||
| 			int b4topadjust = newFocus.Top;
 | ||
| 			newFocus.SetFocus();			//shifts edititem to center it
 | ||
| 			// need to adjust the TopMostYBefore so that it accounts for any shifting that occurred when the
 | ||
| 			// SetFocus was called. This fixes B2016-040.
 | ||
| 			b4topadjust -= newFocus.Top;
 | ||
| 			TopMostYBefore -= b4topadjust;
 | ||
| 
 | ||
| 			//B2024-075: If Deleting an item in a Source Document that is unlinked
 | ||
| 			//and the overall procedure has connected Background Documents
 | ||
| 			//and a window is open containing the background documents
 | ||
| 			//then need to force a refresh on that window as
 | ||
| 			//step numbering will shift
 | ||
| 			EnhancedDocuments ProcEnh = MyItemInfo.MyProcedure.GetMyEnhancedDocuments();
 | ||
| 			if (ProcEnh.Count > 0)
 | ||
| 			{
 | ||
| 				DisplayTabItem wndowToRefresh = MyStepPanel.MyStepTabPanel.MyDisplayTabControl.MyBar.Items.Cast<DisplayTabItem>().FirstOrDefault(x => x.MyKey == $"Item - {ProcEnh[0].ItemID}");
 | ||
| 				wndowToRefresh?.MyStepTabPanel.MyStepPanel.Reset(wndowToRefresh.MyItemInfo);
 | ||
| 			}
 | ||
| 
 | ||
| 			//_MyTimer.ActiveProcess = "Dispose";
 | ||
| 			Dispose();
 | ||
| 			//_MyTimer.ActiveProcess = "SetAllTabs";
 | ||
| 			newFocus.SetAllTabs();
 | ||
| 			//_MyTimer.ActiveProcess = "TopMostYAfter";
 | ||
| 			int TopMostYAfter = newFocus.TopMostEditItem.Top;
 | ||
| 			if (TopMostYAfter > TopMostYBefore)
 | ||
| 				newFocus.TopMostEditItem.Top = TopMostYBefore;
 | ||
| 			//_MyTimer.ActiveProcess = "AdjustLocation";
 | ||
| 			newFocus.AdjustLocation();
 | ||
| 			//newFocus.ShowTops("");
 | ||
| 			//_MyTimer.ShowElapsedTimes("RemoveItem");
 | ||
| 			ForceEditItemRefresh(newFocus);
 | ||
| 			MyStepPanel.Controls.Remove(pnl);
 | ||
| 			foreach (int enhId in enhIds)
 | ||
| 			{
 | ||
| 				ItemInfo ii = ItemInfo.Get(enhId);
 | ||
| 				bool success = this._MyStepPanel.MyStepTabPanel.MyDisplayTabControl.DeleteRTBItem(ii);
 | ||
| 				if (!success)
 | ||
| 					Item.DeleteItemAndChildren(ii);
 | ||
| 			}
 | ||
| 			if (MyItemInfo.MyDocStyle != null && MyItemInfo.MyDocStyle.SupplementalInformation)
 | ||
| 			{
 | ||
| 				if (newFocus.MyItemInfo.IsInSupInfo)
 | ||
| 					newFocus.AdjustAllForSupInfoHeight();
 | ||
| 				else
 | ||
| 				{
 | ||
| 					EditItem prvOrParSupInfo = newFocus.FindPreviousOrParentSupInfo();
 | ||
| 					if (prvOrParSupInfo != null) prvOrParSupInfo.AdjustAllForSupInfoHeight();
 | ||
| 				}
 | ||
| 			}
 | ||
| 		}
 | ||
| 
 | ||
| 		private static void ForceEditItemRefresh(EditItem newFocus)
 | ||
| 		{
 | ||
| 			// bug fix
 | ||
| 			// need to force a refresh from the level above the step that was removed.
 | ||
| 			// this fixes a problem where the following step/substep wasn't shown on the screen (but was there)
 | ||
| 			// and fixes a problem where the sequence numbers were off by one
 | ||
| 			// and fixes a problem where an edit window would end up on top of the ones above it
 | ||
| 			EditItem ei = newFocus;
 | ||
| 			while (ei.MyPreviousEditItem != null) ei = ei.MyPreviousEditItem;
 | ||
| 			if (ei.MyParentEditItem != null && ei.MyParentEditItem.MyItemInfo.IsStep)
 | ||
| 				ei.MyParentEditItem.Expand(true);
 | ||
| 		}
 | ||
| 		public EditItem DeleteItem()
 | ||
| 		{
 | ||
| 			//Volian.Base.Library.VlnTimer _MyTimer = new VlnTimer();
 | ||
| 			//_MyTimer.ActiveProcess = "_LookupEditItems.Remove";
 | ||
| 			MyStepPanel._LookupEditItems.Remove(MyID);
 | ||
| 			EditItem newFocus = null;
 | ||
| 			int? TopMostParentY = (MyParentEditItem == null ? null : (int?)(MyParentEditItem.TopMostEditItem.Top));
 | ||
| 			int? ParentY = (MyParentEditItem == null ? null : (int?)(MyParentEditItem.Top));
 | ||
| 			try
 | ||
| 			{
 | ||
| 				//_MyTimer.ActiveProcess = "DeleteItemAndChildren";
 | ||
| 				Item.DeleteItemAndChildren(MyItemInfo);
 | ||
| 			}
 | ||
| 			catch (System.Data.SqlClient.SqlException ex)
 | ||
| 			{
 | ||
| 				HandleSqlExceptionOnDelete(ex);
 | ||
| 				return null;
 | ||
| 			}
 | ||
| 			// B2017-159: Don't allow paste if this deleted item is in paste buffer:
 | ||
| 			if (MyStepPanel.MyStepTabPanel.MyDisplayTabControl.MyCopyStep != null && MyStepPanel.MyStepTabPanel.MyDisplayTabControl.MyCopyStep.ItemID == MyItemInfo.ItemID)
 | ||
| 			{
 | ||
| 				MyStepPanel.MyStepTabPanel.MyDisplayTabControl.MyCopyStep = null;
 | ||
| 				MyStepPanel.MyStepTabPanel.MyStepTabRibbon.SetPasteButtons(false);
 | ||
| 			}
 | ||
| 
 | ||
| 			// Remove EditItems
 | ||
| 			//_MyTimer.ActiveProcess = "RemoveFromParentsChildList";
 | ||
| 			RemoveFromParentsChildList();
 | ||
| 			//_MyTimer.ActiveProcess = "MyNextEditItem";
 | ||
| 			if (MyNextEditItem != null)
 | ||
| 			{
 | ||
| 				if (MyPreviousEditItem != null)
 | ||
| 				{
 | ||
| 					MyNextEditItem.MyPreviousEditItem = MyPreviousEditItem;
 | ||
| 					MyPreviousEditItem = null;
 | ||
| 					newFocus = MyNextEditItem;
 | ||
| 				}
 | ||
| 				else
 | ||
| 				{
 | ||
| 					MyNextEditItem.MyParentEditItem = MyParentEditItem;
 | ||
| 					MyParentEditItem = null;
 | ||
| 					MyNextEditItem.MyPreviousEditItem = null;
 | ||
| 					newFocus = MyNextEditItem;
 | ||
| 				}
 | ||
| 				// Adjust the vertical locations of all of the items below the item deleted
 | ||
| 				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)
 | ||
| 			{
 | ||
| 				MyPreviousEditItem.MyNextEditItem = null;
 | ||
| 				//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\",");
 | ||
| 			}
 | ||
| 			else
 | ||
| 			{
 | ||
| 				newFocus = MyParentEditItem;
 | ||
| 				MyParentEditItem = null;
 | ||
| 				//Console.Write(",\"Parent\",");
 | ||
| 			}
 | ||
| 			//_MyTimer.ShowElapsedTimes("DeleteItem");
 | ||
| 			if (newFocus != null)				// B2020-043: Fix transition text when previous text is deleted
 | ||
| 			{
 | ||
| 				newFocus.SetAllTabs();
 | ||
| 				newFocus.MyItemInfo.UpdateTransitionText();
 | ||
| 			}
 | ||
| 			return newFocus;
 | ||
| 		}
 | ||
| 
 | ||
| 		//private void HandleSqlExceptionOnDelete(System.Data.SqlClient.SqlException ex)
 | ||
| 		private void HandleSqlExceptionOnDelete(Exception ex)
 | ||
| 		{
 | ||
| 			// C2020-018 made the messaging consistent in the message boxes
 | ||
| 			// C2020-033: Expand/fill in the Search/Incoming Transition panel.  Also, the dialog message was changed
 | ||
| 			//	to give message to view panel and eliminate list in the dialog. This is done for each of cases.
 | ||
| 			if (ex.Message.Contains("has External Transitions and has no next step"))
 | ||
| 			{
 | ||
| 				MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OnSearchIncTrans(this, new vlnTreeItemInfoEventArgs(MyStepRTB.MyItemInfo));
 | ||
| 				using (TransitionInfoList exTrans = TransitionInfoList.GetExternalTransitionsToChildren(MyID)) // B2020-109: look at substeps too
 | ||
| 				{
 | ||
| 					DialogResult ans = FlexibleMessageBox.Show("Transitions exist to this step and cannot be adjusted automatically." +
 | ||
| 						"\r\n\r\nThe list of all locations are shown in the Tools/Search/Incoming Transitions tab.",
 | ||
| 						"Cannot Delete This Step", MessageBoxButtons.OK, MessageBoxIcon.Information);
 | ||
| 					SetFocus();
 | ||
| 				}
 | ||
| 			}
 | ||
| 			else if (ex.Message.Contains("has External Transitions to Procedure"))
 | ||
| 			{
 | ||
| 				MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OnSearchIncTrans(this, new vlnTreeItemInfoEventArgs(MyStepRTB.MyItemInfo));
 | ||
| 				using (TransitionInfoList exTrans = TransitionInfoList.GetExternalTransitionsToChildren(MyID))
 | ||
| 				{
 | ||
| 					DialogResult ans = FlexibleMessageBox.Show("Transitions exist to this procedure." +
 | ||
| 						"\r\n\r\nThe list of all locations are shown in the Tools/Search/Incoming Transitions tab.",
 | ||
| 						"Cannot Delete This Procedure", MessageBoxButtons.OK, MessageBoxIcon.Information);
 | ||
| 					SetFocus();
 | ||
| 				}
 | ||
| 			}
 | ||
| 			// B2020-097: If deleting a section that has transitions pointing to it, show list:
 | ||
| 			// B2020-098: If deleting a section that has transitions & select to remove 1st transition, crash on trying to delete section again
 | ||
| 			else if (ex.Message.Contains("has External Transitions to Section"))
 | ||
| 			{
 | ||
| 				MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OnSearchIncTrans(this, new vlnTreeItemInfoEventArgs(MyStepRTB.MyItemInfo));
 | ||
| 				using (TransitionInfoList exTrans = TransitionInfoList.GetExternalTransitionsToChildren(MyID))
 | ||
| 				{
 | ||
| 					DialogResult ans = FlexibleMessageBox.Show("Transitions exist to this section and cannot be adjusted automatically." +
 | ||
| 						"\r\n\r\nThe list of all locations are shown in the Tools/Search/Incoming Transitions tab.",
 | ||
| 						"Cannot Delete This Section", MessageBoxButtons.OK, MessageBoxIcon.Information);
 | ||
| 					MyStepPanel.SelectedEditItem = this;
 | ||
| 				}
 | ||
| 			}
 | ||
| 			else if (ex.Message.Contains("has External Transitions to it's children"))
 | ||
| 			{
 | ||
| 				MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OnSearchIncTrans(this, new vlnTreeItemInfoEventArgs(MyStepRTB.MyItemInfo));
 | ||
| 				using (TransitionInfoList exTrans = TransitionInfoList.GetExternalTransitionsToChildren(MyID))
 | ||
| 				{
 | ||
| 					DialogResult ans = FlexibleMessageBox.Show("Transitions exist to the substeps of this step and cannot be adjusted automatically." +
 | ||
| 						"\r\n\r\nThe list of all locations are shown in the Tools/Search/Incoming Transitions tab.",
 | ||
| 						"Cannot Delete This Step", MessageBoxButtons.OK, MessageBoxIcon.Information);
 | ||
| 						SetFocus();
 | ||
| 				}
 | ||
| 			}
 | ||
| 			else
 | ||
| 				FlexibleMessageBox.Show(ex.Message, "SQL Exception", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
 | ||
| 		}
 | ||
| 		private void RemoveFromParentsChildList()
 | ||
| 		{
 | ||
| 			EditItem top = this;
 | ||
| 			while (top.MyPreviousEditItem != null) top = top.MyPreviousEditItem;
 | ||
| 			EditItem parentEditItem = top.MyParentEditItem;
 | ||
| 			if (parentEditItem == null) return; // No parent, nothing to remove.
 | ||
| 			if (parentEditItem.MyAfterEditItems != null && parentEditItem.MyAfterEditItems.Contains(this))
 | ||
| 			{
 | ||
| 				parentEditItem.MyAfterEditItems.Remove(this);
 | ||
| 				if (parentEditItem.MyAfterEditItems.Count == 0)
 | ||
| 					parentEditItem.MyAfterEditItems = null;
 | ||
| 			}
 | ||
| 			else if (parentEditItem.MyBeforeEditItems != null && parentEditItem.MyBeforeEditItems.Contains(this))
 | ||
| 			{
 | ||
| 				parentEditItem.MyBeforeEditItems.Remove(this);
 | ||
| 				if (parentEditItem.MyBeforeEditItems.Count == 0)
 | ||
| 					parentEditItem.MyBeforeEditItems = null;
 | ||
| 			}
 | ||
| 			else if (parentEditItem.MyRNOEditItems != null && parentEditItem.MyRNOEditItems.Contains(this))
 | ||
| 			{
 | ||
| 				parentEditItem.MyRNOEditItems.Remove(this);
 | ||
| 				if (parentEditItem.MyRNOEditItems.Count == 0)
 | ||
| 					parentEditItem.MyRNOEditItems = null;
 | ||
| 			}
 | ||
| 			else if (parentEditItem.MySupInfoEditItems != null && parentEditItem.MySupInfoEditItems.Contains(this))
 | ||
| 			{
 | ||
| 				parentEditItem.MySupInfoEditItems.Remove(this);
 | ||
| 				if (parentEditItem.MySupInfoEditItems.Count == 0)
 | ||
| 					parentEditItem.MySupInfoEditItems = null;
 | ||
| 			}
 | ||
| 			if (parentEditItem.MyAfterEditItems == null && parentEditItem.MyBeforeEditItems == null && parentEditItem.MyRNOEditItems == null)
 | ||
| 				parentEditItem.CanExpand = false;
 | ||
| 		}
 | ||
| 		//private void ShowSiblings(string title)
 | ||
| 		//{
 | ||
| 		//  Console.WriteLine("---{0} {1}---",title,MyID);
 | ||
| 		//  EditItem top = this;
 | ||
| 		//  while (top.MyPreviousEditItem != null) top = top.MyPreviousEditItem;
 | ||
| 		//  do
 | ||
| 		//  {
 | ||
| 		//    Console.WriteLine("{0} EditItem - {1} {2}", top.MyID == MyID ? "*" : " ", top.MyID, top.MyItemInfo.MyContent.Text);
 | ||
| 		//    top = top.MyNextEditItem;
 | ||
| 		//  } while (top != null);
 | ||
| 		//}
 | ||
| 		#endregion
 | ||
| 		#region Add Children
 | ||
| 		/// <summary>
 | ||
| 		/// Add a child before (Notes, Cautions, etc.)
 | ||
| 		/// </summary>
 | ||
| 		/// <param name="myItemInfo"></param>
 | ||
| 		/// <param name="expand"></param>
 | ||
| 		public void AddChildBefore(ItemInfo myItemInfo, bool expand)
 | ||
| 		{
 | ||
| 			EditItem child = new RTBItem(myItemInfo, MyStepPanel, this, ChildRelation.Before, expand);
 | ||
| 		}
 | ||
| 		/// <summary>
 | ||
| 		/// Add a list of children before
 | ||
| 		/// </summary>
 | ||
| 		/// <param name="myItemInfoList"></param>
 | ||
| 		/// <param name="expand"></param>
 | ||
| 		public void AddChildBefore(ItemInfoList myItemInfoList, bool expand)
 | ||
| 		{
 | ||
| 			if (myItemInfoList != null)
 | ||
| 				foreach (ItemInfo item in myItemInfoList)
 | ||
| 					AddChildBefore(item, expand); 
 | ||
| 		}
 | ||
| 		public EditItem AddChildBefore(ItemInfoList myItemInfoList, EditItem nextEditItem)
 | ||
| 		{
 | ||
| 			EditItem child = null;
 | ||
| 			if (myItemInfoList != null)
 | ||
| 				foreach (ItemInfo item in myItemInfoList)
 | ||
| 					child = AddChildBefore(item, nextEditItem);
 | ||
| 			return child;
 | ||
| 		}
 | ||
| 		/// <summary>
 | ||
| 		/// Add an RNO (Contingency) child
 | ||
| 		/// </summary>
 | ||
| 		/// <param name="myItemInfo"></param>
 | ||
| 		/// <param name="expand"></param>
 | ||
| 		public void AddChildRNO(ItemInfo myItemInfo, bool expand)
 | ||
| 		{
 | ||
| 			EditItem child = new RTBItem(myItemInfo, MyStepPanel, this, ChildRelation.RNO, expand);
 | ||
| 		}
 | ||
| 		public void AddChildSupInfo(ItemInfo myItemInfo, bool expand)
 | ||
| 		{
 | ||
| 			EditItem child = new RTBItem(myItemInfo, MyStepPanel, this, ChildRelation.SupInfo, expand);
 | ||
| 		}
 | ||
| 		/// <summary>
 | ||
| 		/// Add a list of RNO (Contingency) children
 | ||
| 		/// </summary>
 | ||
| 		/// <param name="myItemInfoList"></param>
 | ||
| 		/// <param name="expand"></param>
 | ||
| 		public void AddChildRNO(ItemInfoList myItemInfoList, bool expand)
 | ||
| 		{
 | ||
| 			if (myItemInfoList != null)
 | ||
| 				foreach (ItemInfo item in myItemInfoList)
 | ||
| 					AddChildRNO(item, expand);
 | ||
| 		}
 | ||
| 		public void AddChildSupInfo(ItemInfoList myItemInfoList, bool expand)
 | ||
| 		{
 | ||
| 			if (myItemInfoList != null)
 | ||
| 				foreach (ItemInfo item in myItemInfoList)
 | ||
| 					AddChildSupInfo(item, expand);
 | ||
| 		}
 | ||
| 		/// <summary>
 | ||
| 		/// Add a child after
 | ||
| 		/// </summary>
 | ||
| 		/// <param name="MyItemInfo"></param>
 | ||
| 		/// <param name="expand"></param>
 | ||
| 		public EditItem AddChildAfter(ItemInfo MyItemInfo, bool expand, bool addFirstChld)
 | ||
| 		{
 | ||
| 			EditItem child = null;
 | ||
| 			if (MyItemInfo.IsFigure)
 | ||
| 				child = new ImageItem(MyItemInfo, MyStepPanel, this, ChildRelation.After, expand);
 | ||
| 			else if (MyItemInfo.IsRtfRaw)
 | ||
| 				child = new RtfRawItem(MyItemInfo, MyStepPanel, this, ChildRelation.After, expand);
 | ||
| 			else if (MyItemInfo.MyContent.MyGrid != null)
 | ||
| 				child = new GridItem(MyItemInfo, MyStepPanel, this, ChildRelation.After, expand);
 | ||
| 			else
 | ||
| 				child = new RTBItem(MyItemInfo, MyStepPanel, this, ChildRelation.After, expand, addFirstChld);
 | ||
| 			return child;
 | ||
| 		}
 | ||
| 		public EditItem AddChildAfter(ItemInfo MyItemInfo, EditItem nextEditItem)
 | ||
| 		{
 | ||
| 			EditItem child = null;
 | ||
| 			if (MyItemInfo.IsFigure)
 | ||
| 				child = new ImageItem(MyItemInfo, MyStepPanel, this, ChildRelation.After, true, nextEditItem, FigInsType, _MyStepPropertiesPanel);
 | ||
| 			else if (MyItemInfo.IsRtfRaw)
 | ||
| 				child = new RtfRawItem(MyItemInfo, MyStepPanel, this, ChildRelation.After, true, nextEditItem);
 | ||
| 			else if (MyItemInfo.MyContent.MyGrid != null)
 | ||
| 				child = new GridItem(MyItemInfo, MyStepPanel, this, ChildRelation.After, true, nextEditItem);
 | ||
| 			else
 | ||
| 				child = new RTBItem(MyItemInfo, MyStepPanel, this, ChildRelation.After, true, nextEditItem);
 | ||
| 			return child;
 | ||
| 		}
 | ||
| 		public EditItem AddChildBefore(ItemInfo MyItemInfo, EditItem nextEditItem)
 | ||
| 		{
 | ||
| 			EditItem child = null;
 | ||
| 			if (MyItemInfo.IsFigure)
 | ||
| 				child = new ImageItem(MyItemInfo, MyStepPanel, this, ChildRelation.Before, true, nextEditItem, FigInsType, _MyStepPropertiesPanel);
 | ||
| 			else if (MyItemInfo.IsRtfRaw)
 | ||
| 				child = new RtfRawItem(MyItemInfo, MyStepPanel, this, ChildRelation.Before, true, nextEditItem);
 | ||
| 			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);
 | ||
| 			return child;
 | ||
| 		}
 | ||
| 		public EditItem AddChildRNO(ItemInfo MyItemInfo, EditItem nextEditItem)
 | ||
| 		{
 | ||
| 			// not sure about this, i.e. whether a grid can be added here.
 | ||
| 			EditItem child = null;
 | ||
| 			//if (MyItemInfo.MyContent.ContentGridCount != 0)
 | ||
| 			if (MyItemInfo.MyContent.MyGrid != null)
 | ||
| 				child = new GridItem(MyItemInfo, MyStepPanel, this, ChildRelation.RNO, true, nextEditItem);
 | ||
| 			else
 | ||
| 				child = new RTBItem(MyItemInfo, MyStepPanel, this, ChildRelation.RNO, true, nextEditItem);
 | ||
| 			return child;
 | ||
| 		}
 | ||
| 		public EditItem AddChildSupInfo(ItemInfo MyItemInfo, EditItem nextEditItem)
 | ||
| 		{
 | ||
| 			EditItem child = null;
 | ||
| 			if (MyItemInfo.MyContent.MyGrid != null)
 | ||
| 				child = new GridItem(MyItemInfo, MyStepPanel, this, ChildRelation.SupInfo, true, nextEditItem);
 | ||
| 			else
 | ||
| 				child = new RTBItem(MyItemInfo, MyStepPanel, this, ChildRelation.SupInfo, true, nextEditItem);
 | ||
| 			return child;
 | ||
| 		}
 | ||
| 		/// <summary>
 | ||
| 		/// Adds a sibling after the current EditItem
 | ||
| 		/// </summary>
 | ||
| 		public void AddSiblingAfter()
 | ||
| 		{
 | ||
| 			AddSiblingAfter("", true);
 | ||
| 		}
 | ||
| 		public void AddSiblingAfter(string text, bool updateStatus)
 | ||
| 		{
 | ||
| 			SaveContents();
 | ||
| 			ItemInfo newItemInfo = MyItemInfo.InsertSiblingAfter(text);
 | ||
| 			AddGridIfNeeded(newItemInfo);
 | ||
| 			AddImageIfNeeded(newItemInfo);
 | ||
| 			DoAddSiblingAfter(newItemInfo, updateStatus);
 | ||
| 			if (MyStepPanel.SelectedEditItem is RTBItem)
 | ||
| 			{
 | ||
| 				RTBItem rtbi = MyStepPanel.SelectedEditItem as RTBItem;
 | ||
| 				// see if this step has associated enhanced step(s).  If it does, flag it so 
 | ||
| 				// that the enhanced steps get inserted also.
 | ||
| 				StepConfig sc = new StepConfig(MyItemInfo.MyContent.Config);
 | ||
| 				if (sc.MyEnhancedDocuments.Count > 0)
 | ||
| 				{
 | ||
| 					rtbi.EnhAddFromItemInfo = MyItemInfo;
 | ||
| 					rtbi.EnhAddType = EnhancedAddTypes.After;
 | ||
| 				}
 | ||
| 			}
 | ||
| 		}
 | ||
| 		// This logic allows us to do an Insert Before and Insert After while on a Table
 | ||
| 		// if allowed by the format
 | ||
| 		private void AddGridIfNeeded(ItemInfo newItemInfo)
 | ||
| 		{
 | ||
| 			if (this is GridItem)
 | ||
| 			{
 | ||
| 				GridItem gi = this as GridItem;
 | ||
| 				VlnFlexGrid fg = new VlnFlexGrid(gi.MyFlexGrid.Rows.Count, gi.MyFlexGrid.Cols.Count);
 | ||
| 				// bug fix B2015136
 | ||
| 				// need to copy the font used in the table we are doing the Insert Previous/Next from.
 | ||
| 				VE_Font vefont = MyItemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList.Table.Font;
 | ||
| 				Font GridFont = new Font(vefont.Family, (float)vefont.Size);
 | ||
| 				fg.Font = GridFont;
 | ||
| 				using (Item itm = newItemInfo.Get())
 | ||
| 				{
 | ||
| 					itm.MyContent.MyGrid.Data = fg.GetXMLData();
 | ||
| 					itm.Save();
 | ||
| 				}
 | ||
| 			}
 | ||
| 		}
 | ||
| 		// This logic allows us to do an Insert Before and Insert After while on a Figure
 | ||
| 		// if allowed by the format.  Note that Before/After for figures is only Clipboard (if
 | ||
| 		// image data exists in clipboard), or file. Doing RO images will be added later if needed - 
 | ||
| 		// this decision was made because of scope.
 | ||
| 		// C2019-008 - Check if sibling is a RO image.  If so open the step properties panel and select the RO tab so that a RO Image (figure) can be selected. jsj 2019Feb20
 | ||
| 		private void AddImageIfNeeded(ItemInfo newItemInfo)
 | ||
| 		{
 | ||
| 				if (this is ImageItem)
 | ||
| 				{
 | ||
| 						if (MyItemInfo.MyContent.MyImage != null) // C2019-008 this is null if it is a RO Image
 | ||
| 								ImageItem.AddImageIfNeeded(newItemInfo); // this will use image in windows clipboard or display a file select dialog for an image
 | ||
| 						else
 | ||
| 						{
 | ||
| 								if (MyStepPanel != null && MyStepPanel.MyStepTabPanel != null)
 | ||
| 										MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OnLinkModifyRO(this, new StepPanelLinkEventArgs(null)); // C2019-008 This will open the RO tab on the Step Properties panel
 | ||
| 						}
 | ||
| 				}
 | ||
| 		}
 | ||
| 
 | ||
| 		public void AddSiblingAfter(int? type, bool updateStatus)
 | ||
| 		{
 | ||
| 			SaveContents();
 | ||
| 			ItemInfo newItemInfo = MyItemInfo.InsertSiblingAfter("", "", type);
 | ||
| 			AddGridIfNeeded(newItemInfo);
 | ||
| 			AddImageIfNeeded(newItemInfo);
 | ||
| 			DoAddSiblingAfter(newItemInfo, updateStatus);
 | ||
| 			if (MyStepPanel.SelectedEditItem is RTBItem)
 | ||
| 			{
 | ||
| 				RTBItem rtbi = MyStepPanel.SelectedEditItem as RTBItem;
 | ||
| 				// see if this step has associated enhanced step(s).  If it does, flag it so 
 | ||
| 				// that the enhanced steps get inserted also.
 | ||
| 				StepConfig sc = new StepConfig(MyItemInfo.MyContent.Config);
 | ||
| 				if (sc.MyEnhancedDocuments.Count > 0)
 | ||
| 				{
 | ||
| 					rtbi.EnhAddFromItemInfo = MyItemInfo;
 | ||
| 					rtbi.EnhAddType = EnhancedAddTypes.After;
 | ||
| 				}
 | ||
| 			}
 | ||
| 		}
 | ||
| 		private void DoAddSiblingAfter(ItemInfo newItemInfo, bool updateStatus)
 | ||
| 		{
 | ||
| 			EditItem newEditItem = null;
 | ||
| 			switch (_MyChildRelation)
 | ||
| 			{
 | ||
| 				case ChildRelation.After:
 | ||
| 					newEditItem = ActiveParent.AddChildAfter(newItemInfo, MyNextEditItem);
 | ||
| 					break;
 | ||
| 				case ChildRelation.Before:
 | ||
| 					newEditItem = ActiveParent.AddChildBefore(newItemInfo, MyNextEditItem);
 | ||
| 					break;
 | ||
| 				case ChildRelation.RNO:
 | ||
| 					newEditItem = ActiveParent.AddChildRNO(newItemInfo, MyNextEditItem);
 | ||
| 					break;
 | ||
| 				case ChildRelation.SupInfo:
 | ||
| 					newEditItem = ActiveParent.AddChildSupInfo(newItemInfo, MyNextEditItem);
 | ||
| 					break;
 | ||
| 				default: // Need debug
 | ||
| 					break;
 | ||
| 			}
 | ||
| 			//EditItem newEditItem = ActiveParent.AddChildAfter(newItemInfo, );
 | ||
| 			if (updateStatus)
 | ||
| 				MyStepPanel.SelectedEditItem = newEditItem;//Update Screen
 | ||
| 		}
 | ||
| 		protected static int _WatchThis = 1;
 | ||
| 		public void AddSiblingBefore()
 | ||
| 		{
 | ||
| 			AddSiblingBefore("", true);
 | ||
| 		}
 | ||
| 		public void AddSiblingBefore(int? type, bool updateStatus)
 | ||
| 		{
 | ||
| 			SaveContents();
 | ||
| 			ItemInfo newItemInfo = MyItemInfo.InsertSiblingBefore("", "", type);
 | ||
| 			AddGridIfNeeded(newItemInfo);
 | ||
| 			AddImageIfNeeded(newItemInfo);
 | ||
| 			DoAddSiblingBefore(newItemInfo, updateStatus);
 | ||
| 		}
 | ||
| 		public void AddSiblingBefore(string text, bool updateSelection)
 | ||
| 		{
 | ||
| 			// Save RTB text before creating a new item because the process of creating 
 | ||
| 			// a new item will save a change to iteminfo excluding text changes. This 
 | ||
| 			// shouldn't be necessary for adding sibling after because the current step
 | ||
| 			// doesn't get saved during the insert after because of the MyPrevious field
 | ||
| 			// is only set on an insert before, which is what saves the item without
 | ||
| 			// any updates from the richtextbox text.
 | ||
| 			SaveContents();
 | ||
| 			ItemInfo newItemInfo = MyItemInfo.InsertSiblingBefore(text);
 | ||
| 			AddGridIfNeeded(newItemInfo);
 | ||
| 			AddImageIfNeeded(newItemInfo);
 | ||
| 			DoAddSiblingBefore(newItemInfo, updateSelection);
 | ||
| 			newItemInfo.UpdateTransitionText();		// B2020-043: fix transition text when a step is inserted before
 | ||
| 			if (MyStepPanel.SelectedEditItem is RTBItem)
 | ||
| 			{
 | ||
| 				RTBItem rtbi = MyStepPanel.SelectedEditItem as RTBItem;
 | ||
| 				// see if this step has associated enhanced step(s).  If it does, flag it so 
 | ||
| 				// that the enhanced steps get inserted also.
 | ||
| 				StepConfig sc = new StepConfig(MyItemInfo.MyContent.Config);
 | ||
| 				if (sc.MyEnhancedDocuments.Count > 0)
 | ||
| 				{
 | ||
| 					rtbi.EnhAddFromItemInfo = MyItemInfo;
 | ||
| 					rtbi.EnhAddType = EnhancedAddTypes.Before;
 | ||
| 				}
 | ||
| 			}
 | ||
| 		}
 | ||
| 		public void DoAddSiblingBefore(ItemInfo newItemInfo, bool updateSelection)
 | ||
| 		{
 | ||
| 			EditItem newEditItem = null;
 | ||
| 			switch (_MyChildRelation)
 | ||
| 			{
 | ||
| 				case ChildRelation.After:
 | ||
| 					newEditItem = ActiveParent.AddChildAfter(newItemInfo, this);
 | ||
| 					break;
 | ||
| 				case ChildRelation.Before:
 | ||
| 					newEditItem = ActiveParent.AddChildBefore(newItemInfo, this);
 | ||
| 					break;
 | ||
| 				case ChildRelation.RNO:
 | ||
| 					newEditItem = ActiveParent.AddChildRNO(newItemInfo, this);
 | ||
| 					break;
 | ||
| 				case ChildRelation.SupInfo:
 | ||
| 					newEditItem = ActiveParent.AddChildSupInfo(newItemInfo, this);
 | ||
| 					break;
 | ||
| 				default: // Need debug
 | ||
| 					break;
 | ||
| 			}
 | ||
| 			if (updateSelection)
 | ||
| 				MyStepPanel.SelectedEditItem = newEditItem;//Update Screen
 | ||
| 		}
 | ||
| 		public void AddSiblingBeforeNoDataSave(ItemInfo newItemInfo, bool updateSelection, EditItem tt)
 | ||
| 		{
 | ||
| 			EditItem newEditItem = null;
 | ||
| 			newEditItem = ActiveParent.AddChildBefore(newItemInfo, this);
 | ||
| 			//switch (_MyChildRelation)
 | ||
| 			//{
 | ||
| 			//    case ChildRelation.After:
 | ||
| 			//        newEditItem = ActiveParent.AddChildAfter(newItemInfo, this);
 | ||
| 			//        break;
 | ||
| 			//    case ChildRelation.Before:
 | ||
| 			//        newEditItem = ActiveParent.AddChildBefore(newItemInfo, this);
 | ||
| 			//        break;
 | ||
| 			//    case ChildRelation.RNO:
 | ||
| 			//        newEditItem = ActiveParent.AddChildRNO(newItemInfo, this);
 | ||
| 			//        break;
 | ||
| 			//    default: // Need debug
 | ||
| 			//        break;
 | ||
| 			//}
 | ||
| 			if (updateSelection)
 | ||
| 				MyStepPanel.SelectedEditItem = newEditItem;//Update Screen
 | ||
| 		}
 | ||
| 		private bool specialAdd = false;
 | ||
| 		public void AddSiblingBeforeNoDataSave(ItemInfoList newItemInfos, bool updateSelection)
 | ||
| 		{
 | ||
| 			specialAdd = true;
 | ||
| 			EditItem newEditItem = null;
 | ||
| 			newEditItem = ActiveParent.AddChildAfter(newItemInfos, false, true);
 | ||
| 			if (updateSelection)
 | ||
| 				MyStepPanel.SelectedEditItem = newEditItem;//Update Screen
 | ||
| 			specialAdd = false;
 | ||
| 		}
 | ||
| 		private ImageItem.E_ImageSource FigInsType = ImageItem.E_ImageSource.None;
 | ||
| 		public void AddChild(E_FromType fromType, int type, ImageItem.E_ImageSource newSource)
 | ||
| 		{
 | ||
| 			FigInsType = newSource;
 | ||
| 			AddChild("", fromType, type, null);
 | ||
| 			FigInsType = ImageItem.E_ImageSource.None;
 | ||
| 		}
 | ||
| 		public void AddChild(E_FromType fromType, int type)
 | ||
| 		{
 | ||
| 			AddChild("", fromType, type, null);
 | ||
| 		}
 | ||
| 		public void AddChild(E_FromType fromType, int type, VlnFlexGrid vfGrid)
 | ||
| 		{
 | ||
| 			AddChild("", fromType, type, vfGrid);
 | ||
| 		}
 | ||
| 		public void AddChild(string text, E_FromType fromType, int type, VlnFlexGrid vfGrid)
 | ||
| 		{
 | ||
| 			if ((_MyItemInfo.IsHigh && !MyItemInfo.ActiveFormat.MyStepSectionLayoutData.Dev_Format) || _MyItemInfo.IsSection)
 | ||
| 				CanExpand = true;
 | ||
| 			this.Expanded = true;
 | ||
| 			_WatchThis = 1;
 | ||
| 			ItemInfo newItemInfo = MyItemInfo.InsertChild(fromType, type, text);
 | ||
| 			if (vfGrid != null)
 | ||
| 			{
 | ||
| 				string xml = vfGrid.GetXMLData();
 | ||
| 				using (Item itm = newItemInfo.Get())
 | ||
| 				{
 | ||
| 					itm.MyContent.MyGrid.Data = xml;
 | ||
| 					itm.Save();
 | ||
| 					// newItemInfo.MyContent.MyGrid.ResetContent(itm.MyContent.MyGrid);  // Do I need this?
 | ||
| 				}
 | ||
| 			}
 | ||
| 			// TODO: We need to determine where this will go in the stack of children
 | ||
| 			EditItem nextItem = GetNextItem(fromType, newItemInfo);
 | ||
| 			// TODO:  May need similar logic if a Table is being added to a step that has substeps
 | ||
| 			//   else if (fromType == E_FromType.Table && ((ItemInfo)newItemInfo.ActiveParent).Steps != null
 | ||
| 			//&& ((ItemInfo)newItemInfo.ActiveParent).Steps.Count > 0)
 | ||
| 			//     nextItem = MyStepPanel.FindItem(((ItemInfo)newItemInfo.ActiveParent).Steps[0]);
 | ||
| 			EditItem newEditItem;
 | ||
| 			switch (fromType)
 | ||
| 			{
 | ||
| 				case E_FromType.Caution:
 | ||
| 					newEditItem = this.AddChildBefore(newItemInfo, nextItem);
 | ||
| 					break;
 | ||
| 				case E_FromType.Note:
 | ||
| 					newEditItem = this.AddChildBefore(newItemInfo, nextItem);
 | ||
| 					break;
 | ||
| 				case E_FromType.Procedure:
 | ||
| 					newEditItem = this.AddChildAfter(newItemInfo, nextItem);
 | ||
| 					break;
 | ||
| 				case E_FromType.RNO:
 | ||
| 					newEditItem = this.AddChildRNO(newItemInfo, nextItem);
 | ||
| 					break;
 | ||
| 				case E_FromType.Section:
 | ||
| 					newEditItem = this.AddChildAfter(newItemInfo, nextItem);
 | ||
| 					break;
 | ||
| 				case E_FromType.Step:
 | ||
| 					newEditItem = this.AddChildAfter(newItemInfo, nextItem);
 | ||
| 					break;
 | ||
| 				case E_FromType.Table:
 | ||
| 					newEditItem = this.AddChildAfter(newItemInfo, nextItem);
 | ||
| 					break;
 | ||
| 				case E_FromType.SupInfo:
 | ||
| 					newEditItem = this.AddChildSupInfo(newItemInfo, nextItem);
 | ||
| 					break;
 | ||
| 				default:
 | ||
| 					newEditItem = this.AddChildAfter(newItemInfo, nextItem);
 | ||
| 					break;
 | ||
| 			}
 | ||
| 			MyStepPanel.SelectedEditItem = newEditItem;//Update Screen
 | ||
| 			if (MyStepPanel.SelectedEditItem is RTBItem)
 | ||
| 			{
 | ||
| 				RTBItem rtbi = MyStepPanel.SelectedEditItem as RTBItem;
 | ||
| 				// see if this step has associated enhanced step(s).  If it does, flag it so 
 | ||
| 				// that the enhanced steps get inserted also.
 | ||
| 				EnhancedDocuments cfgeds = null;
 | ||
| 				if (MyItemInfo.IsStepSection)
 | ||
| 				{
 | ||
| 					SectionConfig scfg = MyItemInfo.MyConfig as SectionConfig;
 | ||
| 					if (scfg.Section_LnkEnh != "Y") return;
 | ||
| 					cfgeds = scfg.MyEnhancedDocuments;
 | ||
| 				}
 | ||
| 				// B2019-017: Add check for caution & note, only add enahnced step for those types.  Note that procedure is done from tree and section
 | ||
| 				// is done from code above.  HLS are not added as children, so are not added here.
 | ||
| 				else if (fromType == E_FromType.Caution || fromType == E_FromType.Note)
 | ||
| 				{
 | ||
| 					StepConfig sc = new StepConfig(MyItemInfo.MyContent.Config);
 | ||
| 					cfgeds = sc.MyEnhancedDocuments;
 | ||
| 				}
 | ||
| 				if (cfgeds != null && cfgeds.Count > 0)
 | ||
| 				{
 | ||
| 					rtbi.EnhAddFromItemInfo = MyItemInfo;
 | ||
| 					rtbi.EnhAddType = EnhancedAddTypes.Child;
 | ||
| 				}
 | ||
| 			}
 | ||
| 		}
 | ||
| 		public EditItem GetNextItem(E_FromType fromType, ItemInfo newItemInfo)
 | ||
| 		{
 | ||
| 			EditItem nextItem = null;
 | ||
| 			if (newItemInfo.NextItem != null)
 | ||
| 				nextItem = MyStepPanel.FindItem(newItemInfo.NextItem);
 | ||
| 			else if (fromType == E_FromType.Table && MyAfterEditItems != null)
 | ||
| 				nextItem = MyAfterEditItems[0];
 | ||
| 			// Cautions come before notes, so if this is a Caution and there are Notes, put this first 
 | ||
| 			else if (fromType == E_FromType.Caution && ((ItemInfo)newItemInfo.ActiveParent).Notes != null
 | ||
| 				&& ((ItemInfo)newItemInfo.ActiveParent).Notes.Count > 0)
 | ||
| 				nextItem = MyStepPanel.FindItem(((ItemInfo)newItemInfo.ActiveParent).Notes[0]);
 | ||
| 			return nextItem;
 | ||
| 		}
 | ||
| 		/// <summary>
 | ||
| 		/// Add a list of children after
 | ||
| 		/// </summary>
 | ||
| 		/// <param name="myItemInfoList"></param>
 | ||
| 		/// <param name="expand"></param>
 | ||
| 		public EditItem AddChildAfter(ItemInfoList myItemInfoList, bool expand, bool addFirstChld)
 | ||
| 		{
 | ||
| 			EditItem child = null;
 | ||
| 			int indx = 0;
 | ||
| 			if (myItemInfoList != null)
 | ||
| 				foreach (ItemInfo item in myItemInfoList)
 | ||
| 				{
 | ||
| 					if (addFirstChld)
 | ||
| 					{
 | ||
| 						// the first time add it as first child, the rest should be done in between.
 | ||
| 						child = AddChildAfter(item, expand, addFirstChld);
 | ||
| 						addFirstChld = false;
 | ||
| 					}
 | ||
| 					else
 | ||
| 						child = AddChildAfter(item, this._MyAfterEditItems[indx]);
 | ||
| 					indx++;
 | ||
| 				}
 | ||
| 			return child;
 | ||
| 		}
 | ||
| 		public EditItem AddChildAfter(ItemInfoList myItemInfoList, bool expand)
 | ||
| 		{
 | ||
| 			EditItem child = null;
 | ||
| 			if (myItemInfoList != null)
 | ||
| 				foreach (ItemInfo item in myItemInfoList)
 | ||
| 					child = AddChildAfter(item, expand, false);
 | ||
| 			return child;
 | ||
| 		}
 | ||
| 		public EditItem AddChildAfter(ItemInfoList myItemInfoList, EditItem nextEditItem)
 | ||
| 		{
 | ||
| 			EditItem child = null;
 | ||
| 			if (myItemInfoList != null)
 | ||
| 				foreach (ItemInfo item in myItemInfoList)
 | ||
| 					child = AddChildAfter(item, nextEditItem);
 | ||
| 			return child;
 | ||
| 		}
 | ||
| 		#endregion
 | ||
| 		#region CopyPaste
 | ||
| 		public void PasteSiblingBefore(int copyStartID)
 | ||
| 		{
 | ||
| 			ItemInfo newItemInfo = MyItemInfo.PasteSiblingBefore(copyStartID, GetChangeId(MyItemInfo));
 | ||
| 
 | ||
| 			if (newItemInfo.ItemID == MyItemInfo.ItemID) return;
 | ||
| 
 | ||
| 			EditItem newEditItem = null;
 | ||
| 			switch (_MyChildRelation)
 | ||
| 			{
 | ||
| 				case ChildRelation.After:
 | ||
| 					newEditItem = ActiveParent.AddChildAfter(newItemInfo, this);
 | ||
| 					break;
 | ||
| 				case ChildRelation.Before:
 | ||
| 					newEditItem = ActiveParent.AddChildBefore(newItemInfo, this);
 | ||
| 					break;
 | ||
| 				case ChildRelation.RNO:
 | ||
| 					newEditItem = ActiveParent.AddChildRNO(newItemInfo, this);
 | ||
| 					break;
 | ||
| 				case ChildRelation.SupInfo:
 | ||
| 					newEditItem = ActiveParent.AddChildSupInfo(newItemInfo, this);
 | ||
| 					break;
 | ||
| 				default: // Need debug
 | ||
| 					break;
 | ||
| 			}
 | ||
| 			if (newEditItem != null) MyStepPanel.SelectedEditItem = newEditItem;//Update Screen
 | ||
| 			MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OnItemPaste(this, new vlnTreeItemInfoPasteEventArgs(newItemInfo, copyStartID, ItemInfo.EAddpingPart.Before, newItemInfo.MyContent.Type));
 | ||
| 
 | ||
| 			// MyItemInfo is the 'paste from' item, if it has enhanced need to copy and paste the steps in enhanced.
 | ||
| 			//if doing a paste before/after and item being copied is unlinked, item pasted should also be unlinked.
 | ||
| 			ItemInfo tmpCopyStartSourceItem = ItemInfo.Get(copyStartID);
 | ||
| 			ItemInfo newEnh = null;
 | ||
| 			if (tmpCopyStartSourceItem.GetMyEnhancedDocuments().Count > 0)
 | ||
| 			{
 | ||
| 				newEnh = newItemInfo.EnhancedPasteItem(copyStartID, MyItemInfo, ItemInfo.EAddpingPart.Before, GetChangeId(MyItemInfo));
 | ||
| 			}
 | ||
| 
 | ||
| 			//B2024-075: When doing Paste Before / After with Enhanced Documents only link from Background document to source was created
 | ||
| 			//since source is done first
 | ||
| 			//this is so that after the steps are created in the enhanced, go back and update the link in the source to point to the correct item
 | ||
| 			if (newEditItem != null && newEnh != null)
 | ||
| 			{
 | ||
| 				FixEnhanceLinkOnSource(newEditItem.MyItemInfo, newEnh, MyItemInfo.GetMyEnhancedDocuments());
 | ||
| 			}
 | ||
| 			else if (newEnh == null && newEditItem != null && newEditItem.MyItemInfo.IsEnhancedStep)
 | ||
| 			{
 | ||
| 				UnlinkEnhanced(newEditItem);
 | ||
| 			}
 | ||
| 			else if (newEnh == null && newEditItem != null)
 | ||
| 			{
 | ||
| 				//if did a paste before/after in a source document that contains enhanced steps
 | ||
| 				//but step being pasted was non-enhanced (unlinked)
 | ||
| 				//then look to see if the background page is open
 | ||
| 				//and if it is, do a refresh so that step numbers update appropriately
 | ||
| 				//without having to close and re-open the background steps
 | ||
| 				foreach (EnhancedDocument edSource in MyItemInfo.GetMyEnhancedDocuments())
 | ||
| 				{
 | ||
| 					ItemInfo exEnh = ItemInfo.Get(edSource.ItemID);
 | ||
| 					DisplayTabItem wndowToRefresh = newEditItem.MyStepPanel.MyStepTabPanel.MyDisplayTabControl.MyBar.Items.Cast<DisplayTabItem>().FirstOrDefault(x => x.MyKey == $"Item - {exEnh.MyProcedure.ItemID}");
 | ||
| 					wndowToRefresh?.MyStepTabPanel.MyStepPanel.Reset(wndowToRefresh.MyItemInfo);
 | ||
| 				}
 | ||
| 			}
 | ||
| 
 | ||
| 			// if enhanced items were created, then see if they need displayed:
 | ||
| 			if (newEnh != null) AddAllEnhancedItemsToDisplay(newItemInfo);
 | ||
| 		}
 | ||
| 
 | ||
|         //B2024-075: When doing Paste Before / After with Enhanced Documents only link from Background document to source was created
 | ||
|         //since source is done first
 | ||
|         //this is so that after the steps are created in the enhanced, go back and update the link in the source to point to the correct item
 | ||
|         //if enhanced document wasn't created then paste happened inside a enhanced Step/background step - so remove any links that shouldn't be there
 | ||
|         //and don't have a corresponding spot in the Source
 | ||
|         private void FixEnhanceLinkOnSource(ItemInfo SourceItem, ItemInfo newEnhItem,  EnhancedDocuments enhancedDocuments)
 | ||
| 		{
 | ||
| 			if (enhancedDocuments.Count > 0)
 | ||
| 				CreateLinksEnhancedSingleItem(SourceItem, newEnhItem, enhancedDocuments[0].Type); 
 | ||
| 		}
 | ||
| 		private void AddAllEnhancedItemsToDisplay(ItemInfo newItemInfo)
 | ||
| 		{
 | ||
| 			EnhancedDocuments eds = newItemInfo.GetMyEnhancedDocuments();
 | ||
| 			if (eds != null && eds.Count > 0)
 | ||
| 			{
 | ||
| 				foreach (EnhancedDocument ed in eds)
 | ||
| 					AddEnhancedItemToDisplayTabItem(ItemInfo.Get(ed.ItemID));
 | ||
| 			}
 | ||
| 		}
 | ||
| 		public void AddEnhancedItemToDisplayTabItem(ItemInfo newEnh)
 | ||
| 		{
 | ||
| 			// if tabcontrol was open for enhanced, display the steps:
 | ||
| 			ItemInfo proc = newEnh.MyProcedure; // Find procedure Item
 | ||
| 			string key = "Item - " + proc.ItemID.ToString();
 | ||
| 			if (MyStepPanel.MyStepTabPanel.MyDisplayTabControl._MyDisplayTabItems.ContainsKey(key))
 | ||
| 			{
 | ||
| 				DisplayTabItem pg = MyStepPanel.MyStepTabPanel.MyDisplayTabControl._MyDisplayTabItems[key];
 | ||
| 				// _MyDisplayTabItems (in line above) had tabs that were closed, so use the next line
 | ||
| 				// to validate that the tab is still open.
 | ||
| 				foreach (DisplayTabItem ti in MyStepPanel.MyStepTabPanel.MyDisplayTabControl.MyBar.Items)
 | ||
| 				{
 | ||
| 					if (ti == pg) pg.MyStepTabPanel.MyStepPanel.GetEditItem(newEnh);
 | ||
| 				}
 | ||
| 			}
 | ||
| 		}
 | ||
| 		public void CreateLinksEnhancedSingleItem(ItemInfo srcII, ItemInfo enhII, int enhtype)
 | ||
| 		{
 | ||
| 			srcII.DoCreateLinksEnhancedSingleItem(enhII, enhtype);
 | ||
| 			SetFocus();
 | ||
| 		}
 | ||
| 		public void CreateLinksEnhancedAllInProcedure(ItemInfo srcII, ItemInfo enhII, int enhtype)
 | ||
| 		{
 | ||
| 			using (ContentInfoList cil = ContentInfoList.Convert16To32EnhancedContents(srcII.ItemID, enhII.ItemID, enhtype))
 | ||
| 			{
 | ||
| 				foreach (ContentInfo ci in cil)
 | ||
| 				{
 | ||
| 					using (Content c = ci.Get())
 | ||
| 					{
 | ||
| 						// first refresh configs because the ContentInfo.Refresh causes events to occur that refresh screen
 | ||
| 						// and if configs aren't done first, the screen refresh, if based on config data, will not be correct.
 | ||
| 						foreach (ItemInfo ii in ci.ContentItems) ii.RefreshConfig();
 | ||
| 						ContentInfo.Refresh(c);
 | ||
| 					}
 | ||
| 				}
 | ||
| 			}
 | ||
| 		}
 | ||
| 		public void UnlinkEnhanced(EditItem enhII)
 | ||
| 		{
 | ||
| 			// B2022-049: Copy/paste of enhanced procedure and bad links between source and enhanced
 | ||
| 			//	Pass in to unlink as before this change
 | ||
| 			// B2024 - 075: Change made to pass in an EditTem instead of a ItemInfo
 | ||
| 			//so can refresh the UI
 | ||
| 			enhII.MyItemInfo.DoUnlinkEnhanced(enhII.MyItemInfo, 0, false);
 | ||
| 			SetFocus();
 | ||
| 			enhII.MyStepPanel.Reset(enhII.MyItemInfo); //need to reset parts so refreshes display to show as unlinked
 | ||
| 		}
 | ||
| 		public ItemInfo AddMissingEnhancedStep(ItemInfo ii, int EnhType)
 | ||
| 		{
 | ||
| 			// if the missing enhanced step is a caution or note, check that parent HLS has the needed 
 | ||
| 			// enhanced step to insert the caution/note from.  If not, do a message.
 | ||
| 			if (ii.IsCaution || ii.IsNote)
 | ||
| 			{
 | ||
| 				bool canMakeMissingStep = false;
 | ||
| 				StepConfig sc = ii.MyHLS.MyConfig as StepConfig;
 | ||
| 				foreach (EnhancedDocument ed in sc.MyEnhancedDocuments)
 | ||
| 				{
 | ||
| 					if (EnhType == ed.Type)		// the hls has an enhanced linked step of this type, the caution/note can be made:
 | ||
| 					{
 | ||
| 						canMakeMissingStep = true;
 | ||
| 						break;
 | ||
| 					}
 | ||
| 				}
 | ||
| 				if (!canMakeMissingStep)
 | ||
| 				{
 | ||
| 					FlexibleMessageBox.Show("Cannot create the missing enhanced step, the Enhanced Step for the High Level step must be created first.");
 | ||
| 					return null;
 | ||
| 				}
 | ||
| 			}
 | ||
| 			ItemInfo newEnh = ii.DoAddMissingEnhancedItems(EnhType);
 | ||
| 			// if enhanced items were created, then see if they need displayed:
 | ||
| 			if (newEnh != null) AddAllEnhancedItemsToDisplay(MyItemInfo);
 | ||
| 			SetFocus();
 | ||
| 			return newEnh;
 | ||
| 		}
 | ||
| 		private string GetChangeId(ItemInfo iiDest)
 | ||
| 		{
 | ||
| 			// get the change id for the destination's procedure's change id.
 | ||
| 			string chgid = null;
 | ||
| 			if (iiDest.ActiveFormat.PlantFormat.FormatData.ProcData.ChangeBarData.ChangeIds)
 | ||
| 				chgid = MyStepPanel.MyStepTabPanel.MyDisplayTabControl.ItemsChangeIds[iiDest.MyProcedure.ItemID];
 | ||
| 			return chgid;
 | ||
| 		}
 | ||
| 		public void PasteSiblingAfter(int copyStartID)
 | ||
| 		{
 | ||
| 			ItemInfo newItemInfo = MyItemInfo.PasteSiblingAfter(copyStartID, GetChangeId(MyItemInfo));
 | ||
| 			if (newItemInfo.ItemID == MyItemInfo.ItemID) return;
 | ||
| 			EditItem newEditItem = null;
 | ||
| 			switch (_MyChildRelation)
 | ||
| 			{
 | ||
| 				case ChildRelation.After:
 | ||
| 					newEditItem = ActiveParent.AddChildAfter(newItemInfo, MyNextEditItem);
 | ||
| 					break;
 | ||
| 				case ChildRelation.Before:
 | ||
| 					newEditItem = ActiveParent.AddChildBefore(newItemInfo, MyNextEditItem);
 | ||
| 					break;
 | ||
| 				case ChildRelation.RNO:
 | ||
| 					newEditItem = ActiveParent.AddChildRNO(newItemInfo, MyNextEditItem);
 | ||
| 					break;
 | ||
| 				case ChildRelation.SupInfo:
 | ||
| 					newEditItem = ActiveParent.AddChildSupInfo(newItemInfo, MyNextEditItem);
 | ||
| 					break;
 | ||
| 				default: // Need debug
 | ||
| 					break;
 | ||
| 			}
 | ||
| 			MyStepPanel.SelectedEditItem = newEditItem;//Update Screen
 | ||
| 			MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OnItemPaste(this, new vlnTreeItemInfoPasteEventArgs(newItemInfo, copyStartID, ItemInfo.EAddpingPart.After, newItemInfo.MyContent.Type));
 | ||
| 
 | ||
| 			// MyItemInfo is the 'paste from' item, if it has enhanced need to copy and paste the steps in enhanced.
 | ||
| 			//if doing a paste before/after and item being copied is unlinked, item pasted should also be unlinked.
 | ||
| 			ItemInfo tmpCopyStartSourceItem = ItemInfo.Get(copyStartID);
 | ||
| 			ItemInfo newEnh = null;
 | ||
| 			if (tmpCopyStartSourceItem.GetMyEnhancedDocuments().Count > 0)
 | ||
| 			{
 | ||
| 				newEnh = newItemInfo.EnhancedPasteItem(copyStartID, MyItemInfo, ItemInfo.EAddpingPart.After, GetChangeId(MyItemInfo));
 | ||
| 			}
 | ||
| 
 | ||
| 			//B2024-075: When doing Paste Before / After with Enhanced Documents only link from Background document to source was created
 | ||
| 			//since source is done first
 | ||
| 			//this is so that after the steps are created in the enhanced, go back and update the link in the source to point to the correct item
 | ||
| 			//if enhanced document wasn't created then paste happened inside a enhanced Step/background step - so remove any links that shouldn't be there
 | ||
| 			//and don't have a cooresponding spot in the Source
 | ||
| 			if (newEditItem != null && newEnh != null)
 | ||
| 			{
 | ||
| 				FixEnhanceLinkOnSource(newEditItem.MyItemInfo, newEnh, MyItemInfo.GetMyEnhancedDocuments());
 | ||
| 			}
 | ||
| 			else if (newEnh == null && newEditItem != null && newEditItem.MyItemInfo.IsEnhancedStep)
 | ||
| 			{
 | ||
| 				UnlinkEnhanced(newEditItem);
 | ||
| 			}
 | ||
| 			else if (newEnh == null && newEditItem != null)
 | ||
| 			{
 | ||
| 				//if did a paste before/after in a source document that contains enhanced steps
 | ||
| 				//but step being pasted was non-enhanced (unlinked)
 | ||
| 				//then look to see if the background page is open
 | ||
| 				//and if it is, do a refresh so that step numbers update appropriately
 | ||
| 				//without having to close and re-open the background steps
 | ||
| 				foreach (EnhancedDocument edSource in MyItemInfo.GetMyEnhancedDocuments())
 | ||
| 				{
 | ||
| 					ItemInfo exEnh = ItemInfo.Get(edSource.ItemID);
 | ||
| 					DisplayTabItem wndowToRefresh = newEditItem.MyStepPanel.MyStepTabPanel.MyDisplayTabControl.MyBar.Items.Cast<DisplayTabItem>().FirstOrDefault(x => x.MyKey == $"Item - {exEnh.MyProcedure.ItemID}");
 | ||
| 					wndowToRefresh?.MyStepTabPanel.MyStepPanel.Reset(wndowToRefresh.MyItemInfo);
 | ||
| 				}
 | ||
| 			}
 | ||
| 
 | ||
| 			if (newEnh != null) AddAllEnhancedItemsToDisplay(newItemInfo);
 | ||
| 		}
 | ||
| 		public void PasteChild(int copyStartID)
 | ||
| 		{
 | ||
| 			ItemInfo newItemInfo = MyItemInfo.PasteChild(copyStartID, GetChangeId(MyItemInfo));
 | ||
| 
 | ||
| 			E_FromType fromType = E_FromType.Step;
 | ||
| 			if (MyItemInfo.MyContent.Type < 10000)
 | ||
| 				fromType = E_FromType.Procedure;
 | ||
| 			else if (MyItemInfo.MyContent.Type < 20000)
 | ||
| 				fromType = E_FromType.Section;
 | ||
| 			else if (MyItemInfo.MyContent.Type > 19999)
 | ||
| 			{
 | ||
| 				int tmptype = (int)MyItemInfo.MyContent.Type - 20000;
 | ||
| 				if (MyItemInfo.IsCaution) fromType = E_FromType.Caution;
 | ||
| 				else if (MyItemInfo.IsNote) fromType = E_FromType.Note;
 | ||
| 				else if (MyItemInfo.IsTable) fromType = E_FromType.Table;
 | ||
| 				else if (MyItemInfo.IsRNOPart) fromType = E_FromType.RNO;
 | ||
| 				else if (MyItemInfo.IsSupInfoPart) fromType = E_FromType.SupInfo;
 | ||
| 			}
 | ||
| 			EditItem nextItem = GetNextItem(fromType, newItemInfo);
 | ||
| 			EditItem newEditItem;
 | ||
| 
 | ||
| 			switch (fromType)
 | ||
| 			{
 | ||
| 				case E_FromType.Caution:
 | ||
| 					newEditItem = this.AddChildBefore(newItemInfo, nextItem);
 | ||
| 					break;
 | ||
| 				case E_FromType.Note:
 | ||
| 					newEditItem = this.AddChildBefore(newItemInfo, nextItem);
 | ||
| 					break;
 | ||
| 				case E_FromType.Procedure:
 | ||
| 					newEditItem = this.AddChildAfter(newItemInfo, nextItem);
 | ||
| 					break;
 | ||
| 				case E_FromType.RNO:
 | ||
| 					newEditItem = this.AddChildRNO(newItemInfo, nextItem);
 | ||
| 					break;
 | ||
| 				case E_FromType.Section:
 | ||
| 					newEditItem = this.AddChildAfter(newItemInfo, nextItem);
 | ||
| 					break;
 | ||
| 				case E_FromType.Step:
 | ||
| 					newEditItem = this.AddChildAfter(newItemInfo, nextItem);
 | ||
| 					break;
 | ||
| 				case E_FromType.Table:
 | ||
| 					newEditItem = this.AddChildAfter(newItemInfo, nextItem);
 | ||
| 					break;
 | ||
| 				case E_FromType.SupInfo:
 | ||
| 					newEditItem = this.AddChildSupInfo(newItemInfo, nextItem);
 | ||
| 					break;
 | ||
| 				default:
 | ||
| 					newEditItem = this.AddChildAfter(newItemInfo, nextItem);
 | ||
| 					break;
 | ||
| 			}
 | ||
| 			MyStepPanel.SelectedEditItem = newEditItem;//Update Screen
 | ||
| 
 | ||
| 			// MyItemInfo is the 'paste from' item, if it has enhanced need to copy and paste the steps in enhanced.
 | ||
| 			ItemInfo newEnh = newItemInfo.EnhancedPasteItem(copyStartID, MyItemInfo, ItemInfo.EAddpingPart.Child, GetChangeId(MyItemInfo));
 | ||
| 			if (newEnh != null) AddAllEnhancedItemsToDisplay(newItemInfo);
 | ||
| 		}
 | ||
| 		public EditItem PasteReplace(int copyStartID)
 | ||
| 		{
 | ||
| 			if (this is RTBItem) (this as RTBItem).DoingPasteReplace = true;
 | ||
| 			// 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 != null && MyStepPanel.SelectedEditItem.Empty)
 | ||
| 				MyStepPanel.SelectedEditItem.Empty = false;
 | ||
| 			MyStepPanel.SelectedEditItem = null; // Unselect the item to be deleted
 | ||
| 			ChildRelation childRelation = _MyChildRelation;
 | ||
| 			EditItem newFocus = null;
 | ||
| 			EditItem nextEditItem = MyNextEditItem;
 | ||
| 			EditItem prevEditItem = MyPreviousEditItem;
 | ||
| 			EditItem parentEditItem = null; // ActiveParent;
 | ||
| 			try
 | ||
| 			{
 | ||
| 				parentEditItem = ActiveParent ?? MyStepPanel?.SelectedEditItem?.ActiveParent;
 | ||
| 			}
 | ||
| 			catch (NullReferenceException)
 | ||
| 			{
 | ||
| 				// KL 7/11/2024 - Handle the case where ActiveParent throws a Null Reference Exception
 | ||
| 				parentEditItem = MyStepPanel?.SelectedEditItem?.ActiveParent; 
 | ||
| 			}
 | ||
| 
 | ||
| 			StepConfig savOrigPasteConfig = MyItemInfo.MyConfig as StepConfig;
 | ||
| 			int TopMostYBefore = TopMostEditItem.Top;
 | ||
| 			int? TopMostParentY = (MyParentEditItem == null ? null : (int?)(MyParentEditItem.TopMostEditItem.Top));
 | ||
| 			int? ParentY = (MyParentEditItem == null ? null : (int?)(MyParentEditItem.Top));
 | ||
| 			ItemInfo newItemInfo = null;
 | ||
| 			bool gotoFirstTrans = false;
 | ||
| 			try
 | ||
| 			{
 | ||
| 				// B2024-045, 049 and 050:  do not pass in a tree node to Item.PasteReplace
 | ||
| 				newItemInfo = Item.PasteReplace(MyItemInfo, copyStartID, GetChangeId(MyItemInfo), ref gotoFirstTrans);
 | ||
| 				if (gotoFirstTrans)  //B2017-179 could not replace step, we are positioning onto the first transition that needs resolved
 | ||
| 				{
 | ||
| 					MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OpenItem(newItemInfo);
 | ||
| 					if (this is RTBItem) (this as RTBItem).DoingPasteReplace = true;
 | ||
| 					return null;
 | ||
| 				}
 | ||
| 				if (newItemInfo == null)
 | ||
| 				{
 | ||
| 					if (this is RTBItem) (this as RTBItem).DoingPasteReplace = true;
 | ||
| 					return this; // aborted the replace so just return to the step we were trying to replace
 | ||
| 				}
 | ||
| 			}
 | ||
| 			//catch (System.Data.SqlClient.SqlException ex)
 | ||
| 			catch (Exception ex)
 | ||
| 			{
 | ||
| 				if (HandleSqlExceptionOnCopy(ex)) return this;
 | ||
| 				HandleSqlExceptionOnDelete(ex);
 | ||
| 				if (this is RTBItem) (this as RTBItem).DoingPasteReplace = true;
 | ||
| 				return this;
 | ||
| 			}
 | ||
| 			// Remove the EditItem that was the replaced item.
 | ||
| 			RemoveFromParentsChildList();
 | ||
| 			if (MyNextEditItem != null)
 | ||
| 			{
 | ||
| 				if (MyPreviousEditItem != null)
 | ||
| 				{
 | ||
| 					MyNextEditItem.MyPreviousEditItem = MyPreviousEditItem;
 | ||
| 					MyPreviousEditItem = null;
 | ||
| 				}
 | ||
| 				else
 | ||
| 				{
 | ||
| 					MyNextEditItem.MyParentEditItem = MyParentEditItem;
 | ||
| 					MyParentEditItem = null;
 | ||
| 					MyNextEditItem.MyPreviousEditItem = null;
 | ||
| 				}
 | ||
| 				MyNextEditItem = null;
 | ||
| 			}
 | ||
| 			else if (MyPreviousEditItem != null)
 | ||
| 			{
 | ||
| 				MyPreviousEditItem.MyNextEditItem = null;
 | ||
| 				newFocus = MyPreviousEditItem;
 | ||
| 				MyPreviousEditItem = null;
 | ||
| 			}
 | ||
| 			else
 | ||
| 			{
 | ||
| 				newFocus = MyParentEditItem;
 | ||
| 				MyParentEditItem = null;
 | ||
| 			}
 | ||
| 
 | ||
| 			// add copied item to ui where the replaced item was.
 | ||
| 			EditItem newEditItem = null;
 | ||
| 			switch (childRelation)
 | ||
| 			{
 | ||
| 				case ChildRelation.After:
 | ||
| 					newEditItem = parentEditItem.AddChildAfter(newItemInfo, nextEditItem);
 | ||
| 					break;
 | ||
| 				case ChildRelation.Before:
 | ||
| 					newEditItem = parentEditItem.AddChildBefore(newItemInfo, nextEditItem);
 | ||
| 					break;
 | ||
| 				case ChildRelation.RNO:
 | ||
| 					newEditItem = parentEditItem.AddChildRNO(newItemInfo, nextEditItem);
 | ||
| 					break;
 | ||
| 				case ChildRelation.SupInfo:
 | ||
| 					newEditItem = parentEditItem.AddChildSupInfo(newItemInfo, nextEditItem);
 | ||
| 					break;
 | ||
| 				default: // Need debug
 | ||
| 					break;
 | ||
| 			}
 | ||
| 			MyStepPanel.SelectedEditItem = newEditItem;	//Update Screen
 | ||
| 			MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OnItemPaste(this, new vlnTreeItemInfoPasteEventArgs(newItemInfo, copyStartID, ItemInfo.EAddpingPart.Replace, newItemInfo.MyContent.Type));
 | ||
| 			if (this is RTBItem) (this as RTBItem).DoingPasteReplace = true;
 | ||
| 			return newEditItem;
 | ||
| 		}
 | ||
| 		private bool HandleSqlExceptionOnCopy(Exception ex)
 | ||
| 		{
 | ||
| 			if (ex.Message.Contains("This step has been deleted"))
 | ||
| 			{
 | ||
| 				FlexibleMessageBox.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"))
 | ||
| 			{
 | ||
| 				FlexibleMessageBox.Show("The highlighted step has been deleted by another user.", "Cannot Paste Step", MessageBoxButtons.OK, MessageBoxIcon.Hand);
 | ||
| 				return true;
 | ||
| 			}
 | ||
| 			return false;
 | ||
| 		}
 | ||
| 		public void IdentifyChildren(bool highlight)
 | ||
| 		{
 | ||
| 			// Highlight children of EditItem:
 | ||
| 			if (MyAfterEditItems != null)
 | ||
| 			{
 | ||
| 				foreach (EditItem sia in MyAfterEditItems)
 | ||
| 				{
 | ||
| 					sia.IdentifyMe(highlight);
 | ||
| 					sia.IdentifyChildren(highlight);
 | ||
| 				}
 | ||
| 			}
 | ||
| 			// C2017-031:  Support for paste/replace an enhanced step: don't identify/copy before items, i.e. notes/cautions
 | ||
| 			if (MyBeforeEditItems != null && !MyItemInfo.IsEnhancedStep)
 | ||
| 			{
 | ||
| 				foreach (EditItem sib in MyBeforeEditItems)
 | ||
| 				{
 | ||
| 					sib.IdentifyMe(highlight);
 | ||
| 					sib.IdentifyChildren(highlight);
 | ||
| 				}
 | ||
| 			}
 | ||
| 			if (MyRNOEditItems != null)
 | ||
| 			{
 | ||
| 				foreach (EditItem sir in MyRNOEditItems)
 | ||
| 				{
 | ||
| 					sir.IdentifyMe(highlight);
 | ||
| 					sir.IdentifyChildren(highlight);
 | ||
| 				}
 | ||
| 			}
 | ||
| 			if (MySupInfoEditItems != null)
 | ||
| 			{
 | ||
| 				foreach (EditItem sis in MySupInfoEditItems)
 | ||
| 				{
 | ||
| 					sis.IdentifyMe(highlight);
 | ||
| 					sis.IdentifyChildren(highlight);
 | ||
| 				}
 | ||
| 			}
 | ||
| 		}
 | ||
| 		#endregion
 | ||
| 		#region Event Handlers
 | ||
| 		private string WatchThisIndent
 | ||
| 		{
 | ||
| 			get { return "".PadLeft(_WatchThis, '\t'); }
 | ||
| 		}
 | ||
| 		protected bool RNOBelow
 | ||
| 		{
 | ||
| 			get
 | ||
| 			{
 | ||
| 				if (_MyRNOEditItems != null)
 | ||
| 				{
 | ||
| 					return _MyRNOEditItems[0].RNOLevel > _MyItemInfo.ColumnMode;
 | ||
| 					//return _MyRNOEditItems[0].Left == Left;
 | ||
| 				}
 | ||
| 				return false;
 | ||
| 			}
 | ||
| 		}
 | ||
| 		protected bool RNORight
 | ||
| 		{
 | ||
| 			get
 | ||
| 			{
 | ||
| 				if (_MyRNOEditItems != null)
 | ||
| 				{
 | ||
| 					return _MyRNOEditItems[0].RNOLevel <= _MyItemInfo.ColumnMode;
 | ||
| 					//return _MyRNOEditItems[0].Left != Left;
 | ||
| 				}
 | ||
| 				return false;
 | ||
| 			}
 | ||
| 		}
 | ||
| 		protected void MoveRNO()
 | ||
| 		{
 | ||
| 			if (_MyRNOEditItems != null)
 | ||
| 			{
 | ||
| 				if (_MyRNOEditItems[0].TopMostEditItem.Top != Top)
 | ||
| 				{
 | ||
| 					//if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("\r\n'Adjust RNO',{0},'Move',{1}", MyID, _RNO[0].MyID);
 | ||
| 					EditItem rnoTop = _MyRNOEditItems[0].TopMostEditItem;
 | ||
| 					if (rnoTop.RNOLevel <= _MyItemInfo.ColumnMode)
 | ||
| 					{
 | ||
| 						//EditItem tmpBottom = this;
 | ||
| 						//if (_MyAfterEditItems != null) tmpBottom = _MyAfterEditItems[_MyAfterEditItems.Count - 1].BottomMostEditItem;
 | ||
| 						MyStepPanel.ItemMoving++;
 | ||
| 						rnoTop.LastMethodsPush(string.Format("EditItem_Move RNO Right {0}", rnoTop.MyID));
 | ||
| 						//rnoTop.Top = tmpBottom.Bottom;
 | ||
| 						if (rnoTop.Top != Top)
 | ||
| 							rnoTop.Top = Top;
 | ||
| 						rnoTop.LastMethodsPop();
 | ||
| 						MyStepPanel.ItemMoving--;
 | ||
| 					}
 | ||
| 					else
 | ||
| 					{
 | ||
| 						MyStepPanel.ItemMoving++;
 | ||
| 						rnoTop.LastMethodsPush(string.Format("EditItem_Move RNO Below {0} {1} {2}", rnoTop.MyID, BottomMostEditItemNoRNOs.MyID, BottomMostEditItemNoRNOs.Bottom));
 | ||
| 						if (rnoTop.Top != BottomMostEditItemNoRNOs.Bottom)
 | ||
| 							rnoTop.Top = BottomMostEditItemNoRNOs.Bottom;
 | ||
| 						rnoTop.LastMethodsPop();
 | ||
| 						MyStepPanel.ItemMoving--;
 | ||
| 					}
 | ||
| 				}
 | ||
| 			}
 | ||
| 		}
 | ||
| 		protected void MoveSupInfo()		// If the current item has supplemental information, be sure its top location is that of the current item.
 | ||
| 		{
 | ||
| 			if (_MySupInfoEditItems != null && _MySupInfoEditItems.Count > 0)
 | ||
| 			{
 | ||
| 				EditItem supInfoTop = _MySupInfoEditItems[0].TopMostEditItem;
 | ||
| 				if (supInfoTop.Top != Top + supInfoTop.SupInfoTopOffset)
 | ||
| 				{
 | ||
| 					MyStepPanel.ItemMoving++;
 | ||
| 					supInfoTop.LastMethodsPush(string.Format("EditItem_Move SupInfo Right {0}", supInfoTop.MyID));
 | ||
| 					supInfoTop.Top = Top + supInfoTop.SupInfoTopOffset;
 | ||
| 					supInfoTop.LastMethodsPop();
 | ||
| 					MyStepPanel.ItemMoving--;
 | ||
| 				}
 | ||
| 			}
 | ||
| 		}
 | ||
| 		private bool _TryAgainLater = false;
 | ||
| 		public bool TryAgainLater
 | ||
| 		{
 | ||
| 			get { return _TryAgainLater; }
 | ||
| 			set { _TryAgainLater = value; }
 | ||
| 		}
 | ||
| 		//static bool _ShowChanges=false;
 | ||
| 		int _LastTop = 0;
 | ||
| 
 | ||
| 		// Bug Fix:  B2017-059 only turn on the spellchecking if the RTB is visible.  This controls the number of windows handles created durning spellchecking
 | ||
| 		private void TurnOnSpellCheckIfVisible()
 | ||
| 		{
 | ||
| 			if (MyStepRTB != null)
 | ||
| 			{
 | ||
| 				if (this.Top + this.Height > 0 && this.Top < MyStepPanel.Height)
 | ||
| 					MyStepRTB.SpellCheckStatus = true;
 | ||
| 				else
 | ||
| 					MyStepRTB.SpellCheckStatus = false;
 | ||
| 			}
 | ||
| 		}
 | ||
| 		/// <summary>
 | ||
| 		/// Handles movement of the EditItems
 | ||
| 		/// </summary>
 | ||
| 		/// <param name="sender"></param>
 | ||
| 		/// <param name="e"></param>
 | ||
| 		// use the following to debug if two steps are to be displayed one right after the other vertically, but they are getting separated, overwritten,
 | ||
| 		// gaps.  See code below at the beginning of EditItem_Move that uses these.
 | ||
| 		//static EditItem ei_below;
 | ||
| 		//static EditItem ei_above;
 | ||
| 		private void EditItem_Move(object sender, EventArgs e)
 | ||
| 		{
 | ||
| 			//if (MyID == 205300) ei_above = this;
 | ||
| 			//if (MyID == 205306) ei_below = this;
 | ||
| 			//if (ei_below != null && ei_above != null && MyID == ei_below.MyID && ei_below.Top != ei_above.Bottom) Console.WriteLine("here");
 | ||
| 			TurnOnSpellCheckIfVisible();
 | ||
| 			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);
 | ||
| 			if (_LastTop == newTop) return;
 | ||
| 			_LastTop = newTop;
 | ||
| 			int watchThis = _WatchThis;
 | ||
| 			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)
 | ||
| 				{
 | ||
| 					//Console.WriteLine("RNORight");
 | ||
| 					MoveRNO();
 | ||
| 				}
 | ||
| 				AdjustLocation();
 | ||
| 			}
 | ||
| 			Moving = false;
 | ||
| 			EditItem btm = BottomMostEditItem;
 | ||
| 			EditItem supinfo = null;
 | ||
| 			if (MySupInfoEditItems != null && MySupInfoEditItems.Count > 0) supinfo = MySupInfoEditItems[0].BottomMostEditItem;
 | ||
| 			if (supinfo != null && supinfo.Bottom > btm.Bottom) btm = supinfo;
 | ||
| 			if (this != btm)
 | ||
| 				btm.AdjustLocation();
 | ||
| 			//if (_WatchThis > 0 && MyID > _StartingID)
 | ||
| 			//{
 | ||
| 			//  Console.WriteLine("{0}Finish Move  {1},{2}",WatchThisIndent, MyID, this);
 | ||
| 			//}
 | ||
| 			_WatchThis = watchThis;
 | ||
| 		}
 | ||
| 		/// <summary>
 | ||
| 		/// Adjust the locations when the EditItem is resized
 | ||
| 		/// </summary>
 | ||
| 		/// <param name="sender"></param>
 | ||
| 		/// <param name="e"></param>
 | ||
| 		private void EditItem_Resize(object sender, EventArgs e)
 | ||
| 		{
 | ||
| 			if (MyItemInfo == null) return;
 | ||
| 			if (_IgnoreResize) return;
 | ||
| 			AdjustLocation();
 | ||
| 			HandleResize();
 | ||
| 			AdjustAllForSupInfoHeight();
 | ||
| 		}
 | ||
| 		#endregion // Event Handlers
 | ||
| 		#region Private and Protected Methods
 | ||
| 		/// <summary>
 | ||
| 		/// Calculates the table location
 | ||
| 		/// </summary>
 | ||
| 		/// <param name="myParentEditItem"></param>
 | ||
| 		/// <param name="myStepSectionLayoutData"></param>
 | ||
| 		/// <param name="width"></param>
 | ||
| 		/// <returns></returns>
 | ||
| 		protected Point TableLocation(StepSectionLayoutData myStepSectionLayoutData, int width)
 | ||
| 		{
 | ||
| 			// bug fix: B2016-111 - myParentEditItem was getting a null reference error when inserting a figure before/after a figure
 | ||
| 			EditItem myParentEditItem = MyParent;
 | ||
| 			// Should center on parent unless it is a centered table type in the AER column or parent is another table type, then
 | ||
| 			// walk up until finding a non-table type step'.  (B2016-264: insert of centered eq off centered eq was not locating child equation correctly)
 | ||
| 			EditItem aboveForLocation = myParentEditItem;
 | ||
| 			while (aboveForLocation.MyItemInfo.IsFigure || aboveForLocation.MyItemInfo.IsRtfRaw || aboveForLocation.MyItemInfo.IsTable) aboveForLocation = aboveForLocation.MyParent;// B2017-248
 | ||
| 
 | ||
| 			int center = aboveForLocation.ContentLeft + aboveForLocation.ContentWidth / 2;
 | ||
| 			int rightLimit = aboveForLocation.Right;
 | ||
| 			// Then should center on the wid Limit
 | ||
| 			// B2019-049 added check for the table being in a Caution or Note
 | ||
| 			if ((MyItemInfo.FormatStepData.Type.Contains("AER") == false && MyItemInfo.RNOLevel == 0) && !MyItemInfo.IsInSupInfo && !MyItemInfo.IsInCautionOrNote)
 | ||
| 			{
 | ||
| 				// B2017-043 COLR is used as a Width
 | ||
| 				int colR = MyStepPanel.ToDisplay(MyStepSectionLayoutData.ColRTable, MyItemInfo.ColumnMode);
 | ||
| 				rightLimit += colR * MyItemInfo.ColumnMode;
 | ||
| 				center += (colR * MyItemInfo.ColumnMode) / 2;
 | ||
| 				center -= (aboveForLocation.ContentLeft - (int)MyItemInfo.MyDocStyle.Layout.LeftMargin) / 2;
 | ||
| 			}
 | ||
| 
 | ||
| 			// Calulate the x location
 | ||
| 			//int x = myParentEditItem.TextLeft;
 | ||
| 			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);
 | ||
| 			if (x < colT) x = colT;
 | ||
| 			// B2023-025: if x is <= 0, add 20 to it so that left column of table isn't cut-off. 20 was used because lesser numbers
 | ||
| 			//	still cut-off the left column (by trial and error).
 | ||
| 			if (x <= 0) x = 20;
 | ||
| 			int y = FindTop(myParentEditItem.Bottom);
 | ||
| 			return new Point(x, y);
 | ||
| 		}
 | ||
| 		protected void DoMouseWheel(MouseEventArgs e)
 | ||
| 		{
 | ||
| 			MyStepPanel.MouseWheel(e);
 | ||
| 		}
 | ||
| 		protected void InsertPgBrk()
 | ||
| 		{
 | ||
| 			MyStepPanel.MyStepTabPanel.MyStepTabRibbon.btnInsPgBrk_Click(this, new EventArgs());
 | ||
| 			MyStepPropertiesPanel.UpdatePageBreakCheckBox(); // update the checkbox on the Step Properties panel
 | ||
| 			if (!MyStepRTB.ContainsFocus)
 | ||
| 				MyStepRTB.Focus();
 | ||
| 		}
 | ||
| 		protected void ToggleChangeBar()
 | ||
| 		{
 | ||
| 			MyStepPropertiesPanel.ToggleChangeBar(); // update the checkbox on the Step Properties panel
 | ||
| 			if (!MyStepRTB.ContainsFocus)
 | ||
| 				MyStepRTB.Focus();
 | ||
| 		}
 | ||
| 		protected void ToggleContinuousActionSummary()
 | ||
| 		{
 | ||
| 			if (MyStepPropertiesPanel != null) // bug fix B2016-256 check for a null reference incase we are not on a step element
 | ||
| 				MyStepPropertiesPanel.ToggleContActSummary(); // update the checkbox on the Step Properties panel
 | ||
| 			if (!MyStepRTB.ContainsFocus)
 | ||
| 				MyStepRTB.Focus();
 | ||
| 		}
 | ||
| 		protected void TogglePlaceKeeper()
 | ||
| 		{
 | ||
| 			MyStepPropertiesPanel.TogglePlaceKeeper(); // update the checkbox on the Step Properties panel
 | ||
| 			if (!MyStepRTB.ContainsFocus)
 | ||
| 				MyStepRTB.Focus();
 | ||
| 		}
 | ||
| 		protected void TogglePlaceKeeperContAct()
 | ||
| 		{
 | ||
| 			MyStepPropertiesPanel.TogglePlaceKeeperContAct(); // update the checkbox on the Step Properties panel
 | ||
| 			if (!MyStepRTB.ContainsFocus)
 | ||
| 				MyStepRTB.Focus();
 | ||
| 		}
 | ||
| 		protected void ToggleSuperScript()
 | ||
| 		{
 | ||
| 			MyStepPanel.MyStepTabPanel.MyStepTabRibbon.btnSuperscript_Click(this, new EventArgs()); // click the Superscrpt button on the ribbon
 | ||
| 			if (!MyStepRTB.ContainsFocus)
 | ||
| 				MyStepRTB.Focus();
 | ||
| 		}
 | ||
| 		protected void ToggleSubScript()
 | ||
| 		{
 | ||
| 			MyStepPanel.MyStepTabPanel.MyStepTabRibbon.btnSubscript_Click(this, new EventArgs()); // click the Subscrpt button on the ribbon
 | ||
| 			if (!MyStepRTB.ContainsFocus)
 | ||
| 				MyStepRTB.Focus();
 | ||
| 		}
 | ||
| 		protected void OpenAnnotations()
 | ||
| 		{
 | ||
| 			MyStepPanel.MyStepTabPanel.MyStepTabRibbon.btnAnnots_Click(this, new EventArgs());
 | ||
| 		}
 | ||
| 		protected bool CheckClipboard()
 | ||
| 		{
 | ||
| 			return (MyStepPanel.MyStepTabPanel.MyDisplayTabControl.MyCopyStep != null);
 | ||
| 		}
 | ||
| 		protected void CopyStep()
 | ||
| 		{
 | ||
| 			MyStepPanel.MyStepTabPanel.MyStepTabRibbon.DoCopyStep();
 | ||
| 		}
 | ||
| 		/// <summary>
 | ||
| 		/// Finds the last child in a list
 | ||
| 		/// </summary>
 | ||
| 		/// <param name="childEditItems"></param>
 | ||
| 		/// <returns></returns>
 | ||
| 		private static EditItem LastChild(List<EditItem> childEditItems)
 | ||
| 		{
 | ||
| 			return childEditItems[childEditItems.Count - 1];
 | ||
| 		}
 | ||
| 		/// <summary>
 | ||
| 		/// If the selected EditItem is within the window leave it as it is.
 | ||
| 		/// If not, scroll so that the selected window is centered.
 | ||
| 		/// </summary>
 | ||
| 		protected void ScrollToCenter()
 | ||
| 		{
 | ||
| 			//vlnStackTrace.ShowStack("CenterScroll {0} Current {1} Top {2} Bottom {3} Limit {4}", _MyItem.ItemID, _Panel.VerticalScroll.Value, Top, Bottom, _Panel.Height);// Show StackTrace
 | ||
| 			//Console.WriteLine("CenterScroll {0} Current {1} Top {2} Bottom {3} Limit {4}", _MyItem.ItemID, _Panel.VerticalScroll.Value, Top, Bottom, _Panel.Height);
 | ||
| 			if (Top >= 0 && Bottom <= MyStepPanel.Height) return;// Don't move if within screen.
 | ||
| 			// C2023-008: if step is larger than the current step panel height, don't center.  This was shifting step so that
 | ||
| 			//	if text was changed closer to bottom of step, the change was no longer visible.
 | ||
| 			if ((Bottom - Top) > _MyStepPanel.Height) return;
 | ||
| 			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));
 | ||
| 			//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
 | ||
| 		}
 | ||
| 
 | ||
| 		/// <summary>
 | ||
| 		/// Hide a Items Children - Part of colapsing
 | ||
| 		/// </summary>
 | ||
| 		protected void HideChildren()
 | ||
| 		{
 | ||
| 			HideChildren(_MyBeforeEditItems);
 | ||
| 			HideChildren(_MyRNOEditItems);
 | ||
| 			HideChildren(_MySupInfoEditItems);
 | ||
| 			HideChildren(_MyAfterEditItems);
 | ||
| 		}
 | ||
| 		/// <summary>
 | ||
| 		/// Hide a list of children - Part of colapsing
 | ||
| 		/// </summary>
 | ||
| 		/// <param name="childEditItems"></param>
 | ||
| 		private void HideChildren(List<EditItem> childEditItems)
 | ||
| 		{
 | ||
| 			if (childEditItems != null)
 | ||
| 			{
 | ||
| 				foreach (EditItem child in childEditItems)
 | ||
| 				{
 | ||
| 					if (child.Expanded) child.HideChildren();
 | ||
| 					child.Hidden = true;
 | ||
| 				}
 | ||
| 			}
 | ||
| 		}
 | ||
| 		/// <summary>
 | ||
| 		/// Unhide an items Children - Part of expanding
 | ||
| 		/// </summary>
 | ||
| 		/// <param name="expand"></param>
 | ||
| 		protected void UnhideChildren(bool expand)
 | ||
| 		{
 | ||
| 			UnhideChildren(_MyBeforeEditItems, expand);
 | ||
| 			UnhideChildren(_MyRNOEditItems, expand);
 | ||
| 			UnhideChildren(_MySupInfoEditItems, expand);
 | ||
| 			UnhideChildren(_MyAfterEditItems, expand);
 | ||
| 			MatchExpanded();
 | ||
| 
 | ||
| 		}
 | ||
| 		/// <summary>
 | ||
| 		/// Unhide a list of children - part of expanding
 | ||
| 		/// </summary>
 | ||
| 		/// <param name="childEditItems"></param>
 | ||
| 		/// <param name="expand"></param>
 | ||
| 		private void UnhideChildren(List<EditItem> childEditItems, bool expand)
 | ||
| 		{
 | ||
| 			if (childEditItems != null)
 | ||
| 			{
 | ||
| 				foreach (EditItem child in childEditItems)
 | ||
| 				{
 | ||
| 					if (child.Expanded)
 | ||
| 						child.UnhideChildren(expand);
 | ||
| 					else if (expand)
 | ||
| 						child.Expand(expand);
 | ||
| 					child.Hidden = false;
 | ||
| 				}
 | ||
| 			}
 | ||
| 		}
 | ||
| 		/// <summary>
 | ||
| 		/// Move children as necessary
 | ||
| 		/// </summary>
 | ||
| 		protected void AdjustChildren()
 | ||
| 		{
 | ||
| 			AdjustChildren(_MyBeforeEditItems);
 | ||
| 			AdjustChildren(_MyRNOEditItems);
 | ||
| 			AdjustChildren(_MySupInfoEditItems);
 | ||
| 			AdjustChildren(_MyAfterEditItems);
 | ||
| 		}
 | ||
| 		/// <summary>
 | ||
| 		/// Move a list of children
 | ||
| 		/// </summary>
 | ||
| 		/// <param name="childEditItems"></param>
 | ||
| 		private void AdjustChildren(List<EditItem> childEditItems)
 | ||
| 		{
 | ||
| 			if (childEditItems != null)
 | ||
| 			{
 | ||
| 				foreach (EditItem child in childEditItems)
 | ||
| 				{
 | ||
| 					child.AdjustLocation();
 | ||
| 					if (child.Expanded) child.AdjustChildren();
 | ||
| 				}
 | ||
| 			}
 | ||
| 		}
 | ||
| 		/// <summary>
 | ||
| 		/// Expand a list of children
 | ||
| 		/// </summary>
 | ||
| 		/// <param name="childEditItems"></param>
 | ||
| 		private void ExpandChildren(List<EditItem> childEditItems)
 | ||
| 		{
 | ||
| 			if (childEditItems != null)
 | ||
| 			{
 | ||
| 				foreach (EditItem child in childEditItems)
 | ||
| 				{
 | ||
| 					if (child.CanExpand)
 | ||
| 					{
 | ||
| 						child.Expand(true);
 | ||
| 					}
 | ||
| 					child.Hidden = false;
 | ||
| 				}
 | ||
| 			}
 | ||
| 		}
 | ||
| 		/// <summary>
 | ||
| 		/// Expand children
 | ||
| 		/// </summary>
 | ||
| 		private void ExpandChildren()
 | ||
| 		{
 | ||
| 			// Walk though Children performing Expand
 | ||
| 			ExpandChildren(_MyBeforeEditItems);
 | ||
| 			ExpandChildren(_MyRNOEditItems);
 | ||
| 			ExpandChildren(_MySupInfoEditItems);
 | ||
| 			ExpandChildren(_MyAfterEditItems);
 | ||
| 		}
 | ||
| 		private string MyPath
 | ||
| 		{
 | ||
| 			get
 | ||
| 			{
 | ||
| 				if (MyItemInfo.MyContent.Type >= 20000)
 | ||
| 					return MyItemInfo.Path.Substring(MyItemInfo.ActiveSection.Path.Length);
 | ||
| 				return MyItemInfo.MyContent.ToString();
 | ||
| 			}
 | ||
| 		}
 | ||
| 		private EditItem AEREditItem
 | ||
| 		{
 | ||
| 			get
 | ||
| 			{
 | ||
| 				if (RNOLevel == 0) return null;
 | ||
| 				if (MyParentEditItem != null)
 | ||
| 				{
 | ||
| 					if (MyParentEditItem.RNOLevel < RNOLevel)
 | ||
| 						return MyParentEditItem;
 | ||
| 					else
 | ||
| 						return MyParentEditItem.AEREditItem;
 | ||
| 				}
 | ||
| 				else if (MyPreviousEditItem != null)
 | ||
| 				{
 | ||
| 					return MyPreviousEditItem.AEREditItem;
 | ||
| 				}
 | ||
| 				//Volian.Base.Library.vlnStackTrace.ShowStackLocal("'AEREditItem',{0},{1}", MyID, MyItemInfo.DBSequence);
 | ||
| 				return null;
 | ||
| 			}
 | ||
| 		}
 | ||
| 		/// <summary>
 | ||
| 		/// Adjust the Location of all items below the current item.
 | ||
| 		/// </summary>
 | ||
| 		internal void AdjustLocation()
 | ||
| 		{
 | ||
| 			if (MyStepPanel.ShuttingDown) return;
 | ||
| 			if (RNORight) MoveRNO(); // This is needed when an AER is Deleted that has an RNO.
 | ||
| 			MoveSupInfo();		// If the current item has supplemental information, be sure its top location is that of the current item.
 | ||
| 			if (RNOLevel > 0 && AEREditItem != null)
 | ||
| 				AEREditItem.AdjustLocation();
 | ||
| 			EditItem nextEditItem = NextDownEditItem;
 | ||
| 			//if(_LookForID.Contains(MyID))
 | ||
| 			//  Console.WriteLine("{0}AdjustLocation {1},{2},{3} -> {4},{5} ({6}) {7}", WatchThisIndent, MyID, MyItemInfo.Ordinal, MyPath,
 | ||
| 			//    nextEditItem == null ? 0 : nextEditItem.MyID, nextEditItem == null ? 0 : nextEditItem.MyItemInfo.Ordinal, nextEditItem == null ? "Null" : nextEditItem.MyPath,
 | ||
| 			//    _NextDownEditItemPath);
 | ||
| 			if (nextEditItem != null)
 | ||
| 			{
 | ||
| 				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)
 | ||
| 				{
 | ||
| 					if (MyItemInfo.IsCaution || MyItemInfo.IsNote)
 | ||
| 					{
 | ||
| 						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
 | ||
| 						AdjustForDevDocStepHeight();
 | ||
| 					}
 | ||
| 				}
 | ||
| 				// SameRowAsParent - Comanche Peak Step Designator
 | ||
| 				//FormatData fmtdata = MyItemInfo.ActiveFormat.PlantFormat.FormatData;
 | ||
| 				//int formatSteptype = MyItemInfo.FormatStepType;
 | ||
| 				//if (fmtdata.StepDataList[formatSteptype].SameRowAsParent)
 | ||
| 				//if (MyItemInfo.SameRowAsParent && MyItemInfo.IsCaution2)
 | ||
| 				//    bottom = Top;
 | ||
| 
 | ||
| 				// 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.IsSupInfoPart) newTop = Math.Max(bottom, nextEditItem.BottomOfStepImmediatelyAbove());
 | ||
| 				if (MyItemInfo.ActiveFormat.MyStepSectionLayoutData.Dev_Format) // Deviation Document Format
 | ||
| 					if (MyItemInfo.IsStep && nextEditItem.MyItemInfo.IsStep && nextEditItem.MyItemInfo.MyHLS.ItemID != MyItemInfo.MyHLS.ItemID)// Move from one step to another
 | ||
| 						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++;
 | ||
| 					nextEditItem.LastMethodsPush(string.Format("AdjustLocation {0}", MyID));
 | ||
| 					nextEditItem._NextDownEditItemPath = _NextDownEditItemPath;
 | ||
| 					float oldTop = nextEditItem.Top;
 | ||
| 					nextEditItem.ExpandPrefix = 0;// If I move then I have to move my children when I expand
 | ||
| 					// it appears that setting the top doesn't always work.  The logic below checks to see if it does
 | ||
| 					// not work and trys some other things so that the EditItem will be moved to the correct place.
 | ||
| 					// As a last attempt, the EditItem is added to a list to be refreshed from a timer on MyStepPanel.
 | ||
| 					if (nextEditItem.MySupInfoEditItems != null && nextEditItem.MySupInfoEditItems.Count > 0) newTop = nextEditItem.MySupInfoEditItems[0].FindTop(newTop);
 | ||
| 					nextEditItem.Top = newTop;
 | ||
| 					if (nextEditItem.Top != newTop)
 | ||
| 					{
 | ||
| 						_MyLog.InfoFormat("'TryAgainLater',{0},{1},{2},{3},{4},'{5}'",
 | ||
| 						 oldTop, nextEditItem.Top, newTop, MyStepPanel.Height, nextEditItem.MyID, nextEditItem.MyItemInfo.ShortPath);
 | ||
| 						nextEditItem.TryAgainLater = true;
 | ||
| 					}
 | ||
| 					nextEditItem.LastMethodsPop();
 | ||
| 					MyStepPanel.ItemMoving--;
 | ||
| 				}
 | ||
| 			}
 | ||
| 			else  // B2018-072 nextEditItem is null, remove "this" from AdjustItems list, otherwise get infinate loop in ProcessAdjustItems() on last HSL with RNO but no AER substeps
 | ||
| 				if (AdjustItems.Contains(this))	AdjustItems.Remove(this);
 | ||
| 		}
 | ||
| 		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
 | ||
| 		{
 | ||
| 			get { return _DevDocHeight; }
 | ||
| 			set { _DevDocHeight = value; }
 | ||
| 		}
 | ||
| 		public void TryAgainNow(int bottom)
 | ||
| 		{
 | ||
| 			TryToSetTop(bottom - 10);
 | ||
| 			//TryToSetTop(bottom+10);
 | ||
| 			TryToSetTop(bottom);
 | ||
| 		}
 | ||
| 		private void TryToSetTop(int offset)
 | ||
| 		{
 | ||
| 			Top = offset;
 | ||
| 			if (Top != offset)
 | ||
| 				_MyLog.InfoFormat("Didn't work - Top {0} != offset {1} {2}", Top, offset, MyStepPanel.VerticalScroll.Value);
 | ||
| 		}
 | ||
| 		/// <summary>
 | ||
| 		/// Automatically expands Steps if not currently expanded
 | ||
| 		/// </summary>
 | ||
| 		internal void AutoExpand()
 | ||
| 		{
 | ||
| 			if (CanExpand && Expanded == false)// TODO: May need to do some additional checking for subsections
 | ||
| 			{
 | ||
| 				if (MyStepPanel.AutoExpand)
 | ||
| 					Expand((_ContentType >= 20000) || MyItemInfo.ActiveFormat.MyStepSectionLayoutData.Dev_Format);
 | ||
| 				else
 | ||
| 					Expand(false);
 | ||
| 				//Console.WriteLine("<AutoExpand ID {0} - Can {1} Expanded {2}",_MyItem.ItemID, CanExpand, Expanded);
 | ||
| 			}
 | ||
| 		}
 | ||
| 		#endregion // Private Methods
 | ||
| 		#region Public Methods
 | ||
| 		/// <summary>
 | ||
| 		/// Expand an item and it's children
 | ||
| 		/// <para/>If the children have been loaded then just expand them
 | ||
| 		/// <para/>If not, load the children and expand their children etc.
 | ||
| 		/// </summary>
 | ||
| 		/// <param name="expand">normally equal to _Type > = 20000 (Step)</param>
 | ||
| 		public void Expand(bool expand)
 | ||
| 		{
 | ||
| 			//// TIMING: DisplayItem.TimeIt("Expand Start");
 | ||
| 			if (_ChildrenLoaded)
 | ||
| 			{
 | ||
| 				// Unhide Children
 | ||
| 				MyExpandingStatus = ExpandingStatus.Showing;
 | ||
| 				UnhideChildren(expand);
 | ||
| 				if (ExpandPrefix != 0)
 | ||
| 				{
 | ||
| 					MyStepPanel.ItemMoving++;
 | ||
| 					if (TopMostEditItem.Top != Top)
 | ||
| 						TopMostEditItem.Top = Top;
 | ||
| 					MyStepPanel.ItemMoving--;
 | ||
| 				}
 | ||
| 				else
 | ||
| 					TopMostEditItem.AdjustLocation();
 | ||
| 				//_ShowChanges = true;
 | ||
| 				AdjustChildren();
 | ||
| 				//_ShowChanges = false;
 | ||
| 				//if(_Before != null ) 
 | ||
| 				//  Top = _Before[_Before.Count - 1].BottomMost.Bottom;
 | ||
| 			}
 | ||
| 			else
 | ||
| 			{
 | ||
| 				if (MyItemInfo.IsHigh) MyStepPanel.ExpandingHLS = MyItemInfo;
 | ||
| 				MyExpandingStatus = ExpandingStatus.Expanding;
 | ||
| 				_ChildrenLoaded = true;
 | ||
| 				//_Panel.SuspendLayout();
 | ||
| 				AddChildBefore(MyItemInfo.Cautions, expand);
 | ||
| 				AddChildBefore(MyItemInfo.Notes, expand);
 | ||
| 				AddChildAfter(MyItemInfo.Procedures, expand);
 | ||
| 				if (MyItemInfo.RNOs != null && MyItemInfo.RNOLevel < MyItemInfo.ColumnMode)
 | ||
| 					AddChildRNO(MyItemInfo.RNOs, expand);
 | ||
| 				if (MyItemInfo.RNOs != null && ((MyItemInfo.ActiveFormat.PlantFormat.FormatData.PurchaseOptions.Value & E_PurchaseOptions.EnhancedBackgrounds) == E_PurchaseOptions.EnhancedBackgrounds))
 | ||
| 					AddChildAfter(MyItemInfo.RNOs, expand);
 | ||
| 				AddChildSupInfo(MyItemInfo.SupInfos, expand);
 | ||
| 				AddChildAfter(MyItemInfo.Tables, expand);
 | ||
| 				// get the config item for the steps section. there is an 'editable'
 | ||
| 				// flag used in metasections to define whether the steps should print.
 | ||
| 				// this flag can be toggle on the section's properties dialog.
 | ||
| 				// 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 EditSteps = !hasMetaSubs || (MyItemInfo.MyConfig is SectionConfig && (MyItemInfo.MyConfig as SectionConfig).SubSection_Edit == "Y");
 | ||
| 				if (EditSteps) AddChildAfter(MyItemInfo.Steps, expand);
 | ||
| 
 | ||
| 				if (MyItemInfo.RNOs != null && MyItemInfo.RNOLevel >= MyItemInfo.ColumnMode &&
 | ||
| 					!((MyItemInfo.ActiveFormat.PlantFormat.FormatData.PurchaseOptions.Value & E_PurchaseOptions.EnhancedBackgrounds) == E_PurchaseOptions.EnhancedBackgrounds))
 | ||
| 					AddChildRNO(MyItemInfo.RNOs, expand);
 | ||
| 				AddChildAfter(MyItemInfo.Sections, expand);
 | ||
| 				MatchExpanded();
 | ||
| 				if (MyItemInfo.IsHigh) MyStepPanel.ExpandingHLS = null;
 | ||
| 			}
 | ||
| 			MyExpandingStatus = ExpandingStatus.Done;
 | ||
| 			BottomMostEditItem.AdjustLocation();
 | ||
| 			if (MyItemInfo.IsHigh)
 | ||
| 				ProcessAdjustItems(); // B2017-175 Adjust after expanding
 | ||
| 			MyExpandingStatus = ExpandingStatus.No;
 | ||
| 			//// TIMING: DisplayItem.TimeIt("Expand End");
 | ||
| 		}
 | ||
| 		public EditItem BeforeItem
 | ||
| 		{
 | ||
| 			get
 | ||
| 			{
 | ||
| 				if (_MyAfterEditItems != null)
 | ||
| 				{
 | ||
| 					foreach (EditItem EditItem in _MyAfterEditItems)
 | ||
| 					{
 | ||
| 						if (EditItem._MyBeforeEditItems != null)
 | ||
| 							return EditItem.TopMostEditItem;
 | ||
| 						EditItem beforeItem = EditItem.BeforeItem;
 | ||
| 						if (beforeItem != null) return beforeItem;
 | ||
| 					}
 | ||
| 				}
 | ||
| 				return null;
 | ||
| 			}
 | ||
| 		}
 | ||
| 		public EditItem ItemAbove
 | ||
| 		{
 | ||
| 			get
 | ||
| 			{
 | ||
| 				if (_MyChildRelation == ChildRelation.Before) return _MyParentEditItem.ItemAbove;
 | ||
| 				if (_MyPreviousEditItem != null) return _MyPreviousEditItem.BottomMostEditItem;
 | ||
| 				if (_MyChildRelation == ChildRelation.After) return _MyParentEditItem;
 | ||
| 				if (_MyChildRelation == ChildRelation.RNO) return _MyParentEditItem;
 | ||
| 				if (_MyChildRelation == ChildRelation.SupInfo) return _MyParentEditItem;
 | ||
| 				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 _MyRNOEditItems[0].FindRight();
 | ||
| 		}
 | ||
| 		public int? BottomOfParentRNO()
 | ||
| 		{
 | ||
| 			int? bottom = null;
 | ||
| 			EditItem EditItem = this;
 | ||
| 			if (!MyItemInfo.IsTablePart)
 | ||
| 			{
 | ||
| 				if (EditItem._MyChildRelation == ChildRelation.None)
 | ||
| 					return null;
 | ||
| 				if (EditItem._MyChildRelation == ChildRelation.After && !RNORight)
 | ||
| 					return null;
 | ||
| 			}
 | ||
| 			while (EditItem != null && EditItem._MyChildRelation != ChildRelation.None && EditItem._MyChildRelation != ChildRelation.After)
 | ||
| 				EditItem = EditItem.UpOneEditItem;
 | ||
| 			if (EditItem == null || EditItem._MyChildRelation == ChildRelation.None)
 | ||
| 				return null;
 | ||
| 			EditItem parent = EditItem.UpOneEditItem;
 | ||
| 			int right = FindRight();
 | ||
| 			bool centeredTable = (MyItemInfo.IsTablePart && MyItemInfo.FormatStepData.Type.Contains("AER") == false && MyItemInfo.RNOLevel == 0);
 | ||
| 			while (parent != null && parent.MyItemInfo.IsSection == false && parent._MyChildRelation != ChildRelation.Before)
 | ||
| 			{
 | ||
| 				if (parent._MyRNOEditItems != null)
 | ||
| 				{
 | ||
| 					if (centeredTable || right > parent._MyRNOEditItems[0].Left)
 | ||
| 					{
 | ||
| 						if (parent._MyRNOEditItems[0].BottomMostEditItem.RNOLevel > RNOLevel && RNOLevel < _MyItemInfo.ColumnMode)
 | ||
| 							bottom = max(bottom, parent._MyRNOEditItems[0].BottomMostEditItem.Bottom);
 | ||
| 					}
 | ||
| 				}
 | ||
| 				parent = parent.UpOneEditItem;
 | ||
| 			}
 | ||
| 			return bottom;
 | ||
| 		}
 | ||
| 		public int? BottomOfParentSupInfo()
 | ||
| 		{
 | ||
| 			int? bottom = null;
 | ||
| 			if (Colapsing) return null;
 | ||
| 			EditItem parent = this;
 | ||
| 			while (parent != null && parent.MyItemInfo.IsSection == false && parent._MyChildRelation != ChildRelation.Before)
 | ||
| 			{
 | ||
| 				if (parent._MySupInfoEditItems != null) return parent._MySupInfoEditItems[0].BottomMostEditItem.Bottom;
 | ||
| 				parent = parent.UpOneEditItem;
 | ||
| 			}
 | ||
| 			return bottom;
 | ||
| 		}
 | ||
| 		private string _NextDownEditItemPath = "None";
 | ||
| 		public string NextDownEditItemPath
 | ||
| 		{
 | ||
| 			get { return _NextDownEditItemPath; }
 | ||
| 		}
 | ||
| 		/// <summary>
 | ||
| 		/// This finds the next EditItem down.
 | ||
| 		/// </summary>
 | ||
| 		public EditItem NextDownEditItem
 | ||
| 		{
 | ||
| 			get
 | ||
| 			{
 | ||
| 				EditItem EditItem = this;
 | ||
| 				_NextDownEditItemPath = "Path 1";
 | ||
| 				// If this item appears before it's parent, and it doesn't have anything below it, return the parent
 | ||
| 				if (MyNextEditItem == null && MyAfterEditItems == null && FirstSiblingEditItem._MyChildRelation == ChildRelation.Before)
 | ||
| 					return UpOneEditItem;
 | ||
| 				_NextDownEditItemPath = "Path 2";
 | ||
| 				if (Expanded && _MyAfterEditItems != null)// check to see if there is a _After
 | ||
| 					return MyAfterEditItems[0].TopMostEditItem;// if there is, go that way
 | ||
| 				_NextDownEditItemPath = "Path 3";
 | ||
| 				if (Expanded && MyRNOEditItems != null && MyItemInfo.RNOLevel >= MyItemInfo.ColumnMode)// check to see if there is a _After
 | ||
| 					return MyRNOEditItems[0].TopMostEditItem;// if there is, go that way
 | ||
| 				while (EditItem != null && EditItem.MyNextEditItem == null) // if no Next walk up the parent path
 | ||
| 				{
 | ||
| 					bool lastWasRNO = (EditItem._MyChildRelation == ChildRelation.RNO);
 | ||
| 					EditItem = EditItem.UpOneEditItem;
 | ||
| 					_NextDownEditItemPath = "Path 4";
 | ||
| 					if (EditItem == null) // No Parent
 | ||
| 						return null;
 | ||
| 					_NextDownEditItemPath = string.Format("Path 5 {0}, {1}", EditItem.MyExpandingStatus, EditItem.Moving);
 | ||
| 					if (EditItem.MyExpandingStatus == ExpandingStatus.Expanding || EditItem.Moving) // Parent Expanding or Moving - Wait
 | ||
| 						return null;
 | ||
| 					_NextDownEditItemPath = "Path 5 RNO";
 | ||
| 					if (EditItem.RNOBelow && !Ancestor(EditItem.MyRNOEditItems[0]))
 | ||
| 						return EditItem.MyRNOEditItems[0];
 | ||
| 					_NextDownEditItemPath = "Path 6";
 | ||
| 					if (EditItem.MyNextEditItem == null && EditItem.FirstSiblingEditItem._MyChildRelation == ChildRelation.Before)
 | ||
| 						return EditItem.UpOneEditItem;
 | ||
| 					EditItem btm = EditItem.BottomMostEditItem; // Find the Bottom EditItem of this ancestor
 | ||
| 					EditItem beforeItem = EditItem.BeforeItem;
 | ||
| 					if (lastWasRNO && beforeItem != null)
 | ||
| 					{
 | ||
| 						_NextDownEditItemPath = "Path 7";
 | ||
| 						if (beforeItem.ItemAbove.Bottom > this.Bottom) return null;
 | ||
| 						_NextDownEditItemPath = "Path 8";
 | ||
| 						return beforeItem;
 | ||
| 					}
 | ||
| 					if (this != btm) // If this is not the bottom, then just adjust things with respect to the bottom
 | ||
| 					{
 | ||
| 						EditItem btmNext = btm.NextDownEditItem;
 | ||
| 						//if (EditItem.MyNextEditItem != null && EditItem.MyNextEditItem.TopMostEditItem.Top != btm.Bottom)
 | ||
| 						if (btmNext != null)
 | ||
| 						{
 | ||
| 							int bottom = btmNext.FindTop(btm.Bottom);
 | ||
| 							if (btmNext.MySupInfoEditItems != null && btmNext.MySupInfoEditItems.Count > 0)
 | ||
| 							{
 | ||
| 								int btmSupInfo = btmNext.MySupInfoEditItems[0].FindTop(btm.Bottom);
 | ||
| 								if (btmSupInfo > bottom) bottom = btmSupInfo;
 | ||
| 							}
 | ||
| 							if (btmNext.Top != bottom)
 | ||
| 							{
 | ||
| 								MyStepPanel.ItemMoving++;
 | ||
| 								//EditItem.MyNextEditItem.TopMostEditItem.Top = btm.Bottom;
 | ||
| 								//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)
 | ||
| 									btmNext.Top = bottom;
 | ||
| 								btmNext.LastMethodsPop();
 | ||
| 								MyStepPanel.ItemMoving--;
 | ||
| 							}
 | ||
| 						}
 | ||
| 						_NextDownEditItemPath = string.Format("Path 9 {0}", btm);
 | ||
| 						return null; // Not the bottom - don't adjust anything else
 | ||
| 					}
 | ||
| 					//else
 | ||
| 					//{
 | ||
| 					//}
 | ||
| 				}
 | ||
| 				if (EditItem != null)
 | ||
| 				{
 | ||
| 					// Need to verify that the bottom of the parents RNO does not excede the bottom of this item.
 | ||
| 					EditItem next = EditItem.MyNextEditItem.TopMostEditItem;
 | ||
| 					_NextDownEditItemPath = "Path A";
 | ||
| 					//if (Bottom >= (BottomOfParentRNO(next) ?? Bottom))
 | ||
| 					return next;// if no _After - check to see if there is a Next
 | ||
| 					//_NextDownEditItemPath = "Path B";
 | ||
| 					//return null;
 | ||
| 				}
 | ||
| 				_NextDownEditItemPath = "Path C";
 | ||
| 				return null;
 | ||
| 			}
 | ||
| 		}
 | ||
| 
 | ||
| 		private bool Ancestor(EditItem EditItem)
 | ||
| 		{
 | ||
| 			if (MyID == EditItem.MyID) return true;
 | ||
| 			if (MyItemInfo.IsHigh) return false;
 | ||
| 			return UpOneEditItem.Ancestor(EditItem);
 | ||
| 		}
 | ||
| 		public override string ToString()
 | ||
| 		{
 | ||
| 			return _MyItemInfo == null ? base.ToString() : string.Format("{0},'{1}',{2},{3}", MyID, MyPath, Top, Bottom); // + "-" + MyItemInfo.MyContent.Text;
 | ||
| 		}
 | ||
| 		#endregion
 | ||
| 		#region Abstract Methods and Properties
 | ||
| 		public abstract int TableWidth { get; }
 | ||
| 		public abstract int BorderWidth { get; }
 | ||
| 		public abstract Point ContentLocation { get; set; }
 | ||
| 		public abstract string TabFormat { get; set; }
 | ||
| 		public abstract void AdjustTableWidthAndLocation();
 | ||
| 		public abstract void SetToolTip(string tip);
 | ||
| 		public abstract void RefreshContent();
 | ||
| 		//public abstract EditItem MyPreviousEditItem { get; set; }
 | ||
| 		public abstract int ItemLeft { get; set; }
 | ||
| 		public abstract int ContentLeft { get; }
 | ||
| 		public abstract int ContentWidth { get; set; }
 | ||
| 		public abstract Point ItemLocation { get; set; }
 | ||
| 		public abstract int ItemWidth { get; set; }
 | ||
| 		public abstract void RefreshOrdinal();
 | ||
| 		public abstract bool Expanded { get; set; }
 | ||
| 		public abstract void RefreshTab();
 | ||
| 		public abstract void SetFocus();
 | ||
| 		public abstract void SaveContents();
 | ||
| 		public abstract bool CanExpand { get; set; }
 | ||
| 		public abstract void HandleResize();
 | ||
| 		public abstract void MatchExpanded();
 | ||
| 		public abstract void ItemSelect();
 | ||
| 		public abstract void ItemShow();
 | ||
| 		public abstract StepRTB MyStepRTB { get; }
 | ||
| 		public abstract DialogResult ReplaceText(string rpltxt, string fndstr, bool caseSensitive, bool matchWholeWord, bool reverse, bool prompt, IWin32Window fndrpldlg);
 | ||
| 		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 bool SpellCheckNext();
 | ||
| 		public abstract void IdentifyMe(bool highlight);
 | ||
| 		public abstract void SetActive();
 | ||
| 		public abstract bool Empty { get; set; }
 | ||
| 		//public abstract bool IsEmpty();
 | ||
| 		//public abstract void MakeNotEmpty();
 | ||
| 		public abstract void RefreshDisplay(bool activeMode);
 | ||
| 		public abstract void ToggleEditView(E_ViewMode vwMode);
 | ||
| 		public abstract int TabLeft { get; set; }
 | ||
| 		public abstract Font TabFont { get; set; }
 | ||
| 		public abstract string TabText { get; }
 | ||
| 		public abstract Point TabLocation { get; }
 | ||
| 		public abstract Font ContentFont { get; set; }
 | ||
| 		public abstract float ContentTop { get; }
 | ||
| 		public abstract void SetupHeader(ItemInfo itemInfo);
 | ||
| 		public abstract void ShowExpanded();
 | ||
| 		public abstract void SetText();
 | ||
| 		public abstract void SetExpandAndExpander(ItemInfo itemInfo);
 | ||
| 		public abstract void SaveCurrentAndContents();
 | ||
| 		public abstract void ToolTipOnOff();
 | ||
| 
 | ||
| 		#endregion
 | ||
| 		private int SupInfoTopOffset
 | ||
| 		{
 | ||
| 			get
 | ||
| 			{
 | ||
| 				return _MyParentEditItem.MyStepRTB.Location.Y - MyStepRTB.Location.Y;
 | ||
| 			}
 | ||
| 		}
 | ||
| 		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 = BottomMostEditItem.Bottom;// RHM 20170216 Get the bottom most step of a High Level step (RNOs and Substeps)
 | ||
| 				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;
 | ||
| 				while (eitm != null && !eitm.MyItemInfo.IsHigh) eitm = eitm.MyParent;
 | ||
| 				if (eitm != null && eitm.MyBeforeEditItems != null)
 | ||
| 					foreach (EditItem eitmTmp in eitm.MyBeforeEditItems)
 | ||
| 						y = Math.Max(y, eitmTmp.Bottom);
 | ||
| 				return y;
 | ||
| 			}
 | ||
| 		}
 | ||
| 		/// <summary>
 | ||
| 		/// Sets the parent and postions the item with respect to the parent
 | ||
| 		/// </summary>
 | ||
| 		public EditItem MyParentEditItem
 | ||
| 		{
 | ||
| 			get { return _MyParentEditItem; }
 | ||
| 			set
 | ||
| 			{
 | ||
| 				LastMethodsPush("set_MyParentRTBItem");
 | ||
| 				_MyParentEditItem = value;
 | ||
| 				if (_MyParentEditItem != null)
 | ||
| 				{
 | ||
| 					switch (_MyChildRelation)
 | ||
| 					{
 | ||
| 						case ChildRelation.None: // Same as after 
 | ||
| 						case ChildRelation.After:			// Procedures, sections, substeps, and tables/figures
 | ||
| 							// The size depends upon the parent type
 | ||
| 							int iType = (int)_MyParentEditItem.ContentType;
 | ||
| 
 | ||
| 							switch (iType / 10000)
 | ||
| 							{
 | ||
| 								case 0: // Procedure
 | ||
| 									ItemLocation = new Point(_MyParentEditItem.ItemLocation.X + 20, _MyParentEditItem.Bottom);
 | ||
| 									int widt = MyStepPanel.ToDisplay(MyStepSectionLayoutData.WidT);
 | ||
| 									int wids = MyStepPanel.ToDisplay(MyStepSectionLayoutData.WidSTableEdit, 0);
 | ||
| 									int width = Math.Max(widt, wids);
 | ||
| 									ItemWidth = MyStepPanel.ToDisplay(MyStepSectionLayoutData.ColT) + width;
 | ||
| 									break;
 | ||
| 								case 1: // Section
 | ||
| 									if (this == TopMostEditItem)
 | ||
| 									{
 | ||
| 										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;
 | ||
| 													}
 | ||
| 												}
 | ||
| 												// B2017-043 Account for the Horizonal Scroll position when locating the step
 | ||
| 												ItemLocation = new Point(MyStepPanel.DisplayRectangle.X + MyStepPanel.ToDisplay(MyItemInfo.ActiveFormat.MyStepSectionLayoutData.ColS) + 50, ei.Bottom);
 | ||
| 											}
 | ||
| 											else
 | ||
| 												// B2017-043 Account for the Horizonal Scroll position when locating the step
 | ||
| 												ItemLocation = new Point(MyStepPanel.DisplayRectangle.X + MyStepPanel.ToDisplay(MyItemInfo.ActiveFormat.MyStepSectionLayoutData.ColS) + 50, _MyParentEditItem.Bottom);
 | ||
| 										}
 | ||
| 										else
 | ||
| 											ItemLocation = new Point(_MyParentEditItem.ItemLocation.X + 20, _MyParentEditItem.Bottom);
 | ||
| 									}
 | ||
| 									else
 | ||
| 										TopMostEditItem.ItemLocation = new Point(TopMostEditItem.ItemLocation.X, _MyParentEditItem.Bottom);
 | ||
| 									//TextWidth = _WidthAdjust + borderWidth + MyStepPanel.ToDisplay(_MyStepSectionLayoutData.WidSTableEdit, Convert.ToInt32(_MyStepSectionLayoutData.PMode) - 1);
 | ||
| 									ContentWidth = _WidthAdjust + BorderWidth + MyStepPanel.ToDisplay(MyStepSectionLayoutData.WidSTableEdit, MyItemInfo.ColumnMode);
 | ||
| 									break;
 | ||
| 								case 2: // Step
 | ||
| 									// if Table then determine width and location based upon it's parent's location
 | ||
| 									if (MyStepData.Type == "Table" || MyStepData.ParentType == "Table")
 | ||
| 									{
 | ||
| 										AdjustTableWidthAndLocation();
 | ||
| 									}
 | ||
| 									else if (MyStepData.Type.Contains("Figure"))
 | ||
| 									{
 | ||
| 										AdjustTableWidthAndLocation();
 | ||
| 									}
 | ||
| 									else if (MyItemInfo.IsRtfRaw)
 | ||
| 									{
 | ||
| 										AdjustTableWidthAndLocation();
 | ||
| 									}
 | ||
| 									else
 | ||
| 									{
 | ||
| 										if (MyItemInfo.FormatStepData.StepLayoutData.AlignWithParentTab || (MyItemInfo.IsFirstSubStep && MyItemInfo.MyParent.IsHigh && MyItemInfo.MyParent.FormatStepData.AppendDotZero))
 | ||
| 											// Paul Linn made the request on 6/4/12 to align the Component Description &
 | ||
| 											// Required Position under the Component Number.
 | ||
| 											// F2018-025 added check for high level step being used as a section number/title (tab ends with ".0") for Westinghouse wst1 format step type 50
 | ||
| 											ItemLocation = new Point(_MyParentEditItem.ItemLocation.X, _MyParentEditItem.Bottom);
 | ||
| 										// part of F2017-011, for enhanced backgrounds, always align the TitleWithTextRight and TitleWithTextBelow with the parent tab (on the screen)
 | ||
| 										else if ((MyItemInfo.FormatStepData.Type == "TitleWithTextRight" || MyItemInfo.FormatStepData.Type == "TitleWithTextBelow") && ((MyItemInfo.ActiveFormat.PlantFormat.FormatData.PurchaseOptions.Value & E_PurchaseOptions.EnhancedBackgrounds) == E_PurchaseOptions.EnhancedBackgrounds)) // align with parent tab if in background document
 | ||
| 											ItemLocation = new Point(_MyParentEditItem.ItemLocation.X, _MyParentEditItem.Bottom);
 | ||
| 										else if (MyItemInfo.FormatStepData.Type == "TitleWithTextRight" && (MyItemInfo.Steps == null || MyItemInfo.Steps.Count == 0))  // this code is run for siblings within a HLS (but not last sibling).
 | ||
| 											ItemLocation = new Point(_MyParentEditItem.ItemLocation.X, _MyParentEditItem.Bottom);
 | ||
| 										else if (MyItemInfo.MyParent.FormatStepData.Type == "TitleWithTextRight")
 | ||
| 											ItemLocation = new Point(_MyParentEditItem.ItemLocation.X + _MyParentEditItem.ItemWidth + 10, _MyParentEditItem.ItemLocation.Y); // F2017-011 added 10 to fix positoning of Purpose text on sceen (enhanced backgrounds)
 | ||
| 										else if (MyItemInfo.MyTab.Offset != 0)
 | ||
| 											ContentLocation = new Point(_MyParentEditItem.ContentLocation.X + 10, _MyParentEditItem.Bottom);
 | ||
| 										//ItemLocation = new Point(_MyParentEditItem.ItemLocation.X+10, _MyParentEditItem.Bottom);
 | ||
| 										else
 | ||
| 										{
 | ||
| 											// B2016-134 Fix - If a previous step exists, use it to locate the current step
 | ||
| 											if (_MyPreviousEditItem != null)
 | ||
| 												ItemLocation = new Point(_MyParentEditItem.ContentLeft, _MyPreviousEditItem.BottomMostEditItem.Bottom);
 | ||
| 											else
 | ||
| 											{
 | ||
| 												ItemLocation = new Point(_MyParentEditItem.ContentLeft, _MyParentEditItem.Bottom);
 | ||
| 												// if inserting a substep within supplemental information, then may  have to adjust steps too:
 | ||
| 												if (MyItemInfo.IsInSupInfo)
 | ||
| 												{
 | ||
| 													AdjustLocation();
 | ||
| 													// find parent of supinfo & adjust its location:
 | ||
| 													ItemInfo supInfoPart = MyItemInfo;
 | ||
| 													while (!supInfoPart.IsSupInfoPart) supInfoPart = supInfoPart.MyParent;
 | ||
| 													EditItem eitmp = MyStepPanel._LookupEditItems[supInfoPart.ItemID];
 | ||
| 													eitmp.MyParentEditItem.AdjustLocation();
 | ||
| 												}
 | ||
| 											}
 | ||
| 										}
 | ||
| 										bool specialTplSupport = ((MyItemInfo.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DSS_PageListSpBckgrnd) == E_DocStructStyle.DSS_PageListSpBckgrnd) ||
 | ||
| 											(MyItemInfo.MyDocStyle.LandscapePageList && MyItemInfo.MyDocStyle.ComponentList);
 | ||
| 										bool wecTplSupport = ((MyItemInfo.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DSS_ChklstEditSize) == E_DocStructStyle.DSS_ChklstEditSize);
 | ||
| 										if (MyItemInfo.FormatStepData.ReadOnly)
 | ||
| 										{
 | ||
| 											Graphics g = CreateGraphics();
 | ||
| 											SizeF sz = g.MeasureString(MyItemInfo.MyContent.Text, MyItemInfo.FormatStepData.Font.WindowsFont);
 | ||
| 											ItemWidth = (int)sz.Width;
 | ||
| 										}
 | ||
| 										else if (MyItemInfo.FormatStepData.Type == "TitleWithTextRight" && specialTplSupport)
 | ||
| 										{
 | ||
| 											Graphics g = CreateGraphics();
 | ||
| 											SizeF sz = g.MeasureString(MyItemInfo.MyContent.Text, MyItemInfo.FormatStepData.Font.WindowsFont);
 | ||
| 											ItemWidth = (int)sz.Width + 5;
 | ||
| 										}
 | ||
| 										else if (MyItemInfo.FormatStepData.Type == "TitleWithTextBelow" && specialTplSupport)
 | ||
| 										{
 | ||
| 											ItemWidth = MyStepPanel.ToDisplay(MyStepSectionLayoutData.WidSTableEdit, 0);
 | ||
| 										}
 | ||
| 										else if (wecTplSupport || (MyItemInfo.MyParent.FormatStepData.Type == "TitleWithTextBelow" && specialTplSupport))
 | ||
| 										{
 | ||
| 											ItemWidth = MyParentEditItem.ItemWidth - RTBItem.RTBMargin;
 | ||
| 										}
 | ||
| 										else if (MyItemInfo.MyParent.FormatStepData.Type == "TitleWithTextRight" &&
 | ||
| 										((MyItemInfo.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DSS_PageListSpBckgrnd) == E_DocStructStyle.DSS_PageListSpBckgrnd))
 | ||
| 										{
 | ||
| 											ItemWidth = MyParentEditItem.MyParentEditItem.ContentWidth - MyParentEditItem.ItemWidth;
 | ||
| 										}
 | ||
| 										else if (MyItemInfo.MyParent.FormatStepData.Type == "TitleWithTextRight")
 | ||
| 										{
 | ||
| 											ItemWidth = MyStepPanel.ToDisplay(MyStepSectionLayoutData.ColT) + MyStepPanel.ToDisplay(MyStepSectionLayoutData.WidSTableEdit, 0);
 | ||
| 											ItemWidth = ItemWidth - ItemLocation.X;
 | ||
| 										}
 | ||
| 										else if (MyParentEditItem != null && MyParentEditItem.MyItemInfo.FormatStepData.ReadOnly)
 | ||
| 											ItemWidth = MyStepPanel.ToDisplay(MyStepSectionLayoutData.ColT) + MyStepPanel.ToDisplay(MyStepSectionLayoutData.WidSTableEdit, 0);
 | ||
| 										else if (MyItemInfo.MyTab != null && MyItemInfo.MyTab.Offset != 0)
 | ||
| 										{
 | ||
| 											// Farley - part of bug fix B2015-123 alignment of tabs on the edit screen (Farly is only one using tab offset)
 | ||
| 											ContentWidth = _MyParentEditItem.ContentWidth;
 | ||
| 											int xOffTabNew = (MyItemInfo.MyParent.MyTab != null ? MyItemInfo.MyParent.MyTab.Offset : MyItemInfo.MyParent.OffsetTab) + MyItemInfo.MyTab.Offset;
 | ||
| 											xOffTabNew += MyItemInfo.MyParent.MyTab == null ? 0 : MyItemInfo.MyParent.MyTab.Offset;
 | ||
| 											int xIncrement = xOffTabNew - MyItemInfo.MyTab.Offset;
 | ||
| 											MyStepRTB.Location = new Point(MyStepRTB.Location.X + xIncrement, MyStepRTB.Location.Y);
 | ||
| 										}
 | ||
| 										else
 | ||
| 											ItemWidth = _MyParentEditItem.ContentWidth;
 | ||
| 									}
 | ||
| 									break;
 | ||
| 							}
 | ||
| 							break;
 | ||
| 						case ChildRelation.SupInfo:		// on a supplemental info item
 | ||
| 							EditItem high = MyStepPanel._LookupEditItems[MyItemInfo.MyHLS.ItemID];
 | ||
| 							if (_MyParentEditItem.MyItemInfo.IsNote || _MyParentEditItem.MyItemInfo.IsCaution)
 | ||
| 							{
 | ||
| 								ContentWidth = high.ContentWidth - high.ContentLocation.X;
 | ||
| 							}
 | ||
| 							else
 | ||
| 								ContentWidth = _MyParentEditItem.ContentWidth;
 | ||
| 							// Currently on the supinfo, so MyParentEditItem is the step the supinfo is related to.  
 | ||
| 							// From this MyParentEditItem, need to find what is the bottom of the 'previous step' on the screen where 'previous step' can be: 
 | ||
| 							//	1) The bottom most EditItem from a caution/note, i.e. MyBeforeEditItems.  This must be checked first.
 | ||
| 							//	2) If there is a MyParentEditItem, use it (only MyParentEditItem or MyPreviousEditItem can be set), if going to parent don't use
 | ||
| 							//			BottomMostEditItem because that will take it onto this step or subsequent substeps. So just use its bottom.  Note that there
 | ||
| 							//			are special cases if on a Note/Caution (see below for comments)
 | ||
| 							//	3) If there is no MyBeforeEditItems & no MyParentEditItems, there must be a MyPreviousEditItems.  Use its MyBottomMostEditItem's bottom
 | ||
| 							//		  since this previous may have substeps.
 | ||
| 							int btm = MyParentEditItem.BottomOfStepImmediatelyAbove();
 | ||
| 							int topp = FindTop(btm, false);
 | ||
| 							if (topp != 0)
 | ||
| 							{
 | ||
| 								MyStepPanel.ItemMoving++;
 | ||
| 								_MyParentEditItem.Top = (int)topp;
 | ||
| 								if (_MyParentEditItem.MyItemInfo.Steps != null && _MyParentEditItem.MyItemInfo.Steps.Count > 0)
 | ||
| 								{
 | ||
| 									EditItem chtmp = GetEditItemFromItemID(_MyParentEditItem.MyItemInfo.Steps[0].ItemID);
 | ||
| 									if (chtmp != null && chtmp._MyParentEditItem != null)
 | ||
| 									{
 | ||
| 										chtmp.Top = chtmp._MyParentEditItem.Bottom;
 | ||
| 										chtmp.AdjustLocation();
 | ||
| 									}
 | ||
| 								}
 | ||
| 								_MyParentEditItem.AdjustLocation();
 | ||
| 								MyStepPanel.ItemMoving--;
 | ||
| 							}
 | ||
| 							ContentLocation = new Point(high.ContentLeft + high.Width + 36, (int)_MyParentEditItem.Top + SupInfoTopOffset);  // account for Caution/Note tab above caution/note
 | ||
| 							break;
 | ||
| 						case ChildRelation.RNO:
 | ||
| 							// this is set so that TextWidth command below will be correct.  TextWidth uses
 | ||
| 							// the tab start & tab width to calculate the overall width.
 | ||
| 							TabFormat = "";	// this is set so that TextWidth command below will be correct
 | ||
| 							_IgnoreResize = true;
 | ||
| 							// Use the RNOWidthAlt value if it exists instead of the default RNO width
 | ||
| 							// Note that I needed to add 1 to the ToDisplay() value to be closer to the needed
 | ||
| 							// 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;
 | ||
| 							if (MyStepSectionLayoutData.RNOWidthAlt != null && ovrRNOWidth > 1 && MyItemInfo.ColumnMode != 0)
 | ||
| 								ContentWidth = ovrRNOWidth;
 | ||
| 							else
 | ||
| 								ContentWidth = _MyParentEditItem.ContentWidth;
 | ||
| 							_IgnoreResize = false;
 | ||
| 							if (RNOLevel <= MyItemInfo.ColumnMode)
 | ||
| 							{
 | ||
| 								//int colR = MyStepPanel.ToDisplay(_MyStepSectionLayoutData.ColRTable, Convert.ToInt32(_MyStepSectionLayoutData.PMode) - 1);
 | ||
| 								int colR = MyStepPanel.ToDisplay(MyStepSectionLayoutData.ColRTable, MyItemInfo.ColumnMode);
 | ||
| 								if (colR - _MyParentEditItem.Width < 0) colR = _MyParentEditItem.Width + 0;
 | ||
| 								MyStepPanel.ItemMoving++;
 | ||
| 								//Left = _MyParentRTBItem.ItemLeft + RNOLevel * colR;
 | ||
| 								//ItemLocation = new Point(_MyParentRTBItem.ItemLeft + RNOLevel * colR, _MyParentRTBItem.Top);
 | ||
| 								LastMethodsPush(string.Format("set_MyParentRTBItem RNO Right {0}", MyID));
 | ||
| 								ItemLocation = new Point(_MyParentEditItem.ItemLeft + RNOLevel * colR, _MyParentEditItem.Top);
 | ||
| 								int top = _MyParentEditItem.FindTop(_MyParentEditItem.Top);
 | ||
| 								if (top != _MyParentEditItem.Top)
 | ||
| 								{
 | ||
| 									_MyParentEditItem.LastMethodsPush(string.Format("set_MyParentRTBItem RNO Right {0}", MyID));
 | ||
| 									if (_MyParentEditItem.Top != top)
 | ||
| 										_MyParentEditItem.Top = top;
 | ||
| 									_MyParentEditItem.LastMethodsPop();
 | ||
| 									Top = top;
 | ||
| 								}
 | ||
| 								LastMethodsPop();
 | ||
| 								MyStepPanel.ItemMoving--;
 | ||
| 							}
 | ||
| 							else
 | ||
| 							{
 | ||
| 								MyStepPanel.ItemMoving++;
 | ||
| 								LastMethodsPush(string.Format("set_MyParentRTBItem RNO Below {0} {1} {2}", MyID, _MyParentEditItem.BottomMostEditItem.MyID, _MyParentEditItem.BottomMostEditItem.Bottom));
 | ||
| 								ContentLocation = new Point(_MyParentEditItem.ContentLeft, _MyParentEditItem.BottomMostEditItem.Bottom);
 | ||
| 								LastMethodsPop();
 | ||
| 								//TextLocation = new Point(_MyParentRTBItem.TextLeft, FindTop(_MyParentRTBItem.Top));
 | ||
| 								MyStepPanel.ItemMoving--;
 | ||
| 							}
 | ||
| 							// Same size as the Parent
 | ||
| 							break;
 | ||
| 						case ChildRelation.Before:		// Cautions and Notes
 | ||
| 							//if(_WatchThis > 0 && MyID > 2111)
 | ||
| 							//  Console.WriteLine("Setting MyParent: \r\n\tParent {0},{1} \r\n\tTopMostItem {2},{3} \r\n\tNext {4}, {5}", _MyParentRTBItem.MyID, _MyParentRTBItem
 | ||
| 							//    ,_MyParentRTBItem.TopMostRTBItem.MyID,_MyParentRTBItem.TopMostRTBItem
 | ||
| 							//    , _MyNextRTBItem == null ? 0 : _MyNextRTBItem.MyID, _MyNextRTBItem == null ? "None"  : _MyNextRTBItem.ToString());
 | ||
| 
 | ||
| 							//Location = new Point(_MyParentRTBItem.Left + 20, max(_MyParentRTBItem.Top, (_MyNextRTBItem == null ? 0 : _MyNextRTBItem.Top )) ?? 0);
 | ||
| 							_IgnoreResize = true;
 | ||
| 							int spaceToRTB = 23;
 | ||
| 							_IgnoreResize = false;
 | ||
| 							MyStepPanel.ItemMoving++;
 | ||
| 							//Location = new Point(_MyParentRTBItem.Left + 20, FindTop(_MyParentRTBItem.Top));
 | ||
| 							int myTop = 0;
 | ||
| 							if (MyNextEditItem == null)
 | ||
| 								myTop = _MyParentEditItem.Top;
 | ||
| 							else
 | ||
| 								myTop = MyNextEditItem.Top;
 | ||
| 
 | ||
| 							//if (MyItemInfo.SameRowAsParent && MyItemInfo.IsCaution2)
 | ||
| 							//{
 | ||
| 							//    if (MyItemInfo.WidthOverride > 0)
 | ||
| 							//        Width = MyStepPanel.ToDisplay(MyItemInfo.WidthOverride) + spaceToRTB;
 | ||
| 							//}
 | ||
| 							if (MyItemInfo.ActiveFormat.MyStepSectionLayoutData.Dev_Format && (MyItemInfo.IsCaution || MyItemInfo.IsNote))
 | ||
| 							{
 | ||
| 								// B2017-043 account for Horizontal Scroll
 | ||
| 								int x = MyStepPanel.DisplayRectangle.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
 | ||
| 								Location = new Point(_MyParentEditItem.Left + 20, FindTop(myTop));
 | ||
| 							// ip2bck's needed the width to be set slightly differently to get the correct width.
 | ||
| 							int widthtpl = MyStepPanel.ToDisplay(MyStepSectionLayoutData.WidT) + spaceToRTB;
 | ||
| 							if (MyItemInfo.FormatStepData != null && MyItemInfo.FormatStepData.UseOldTemplate &&
 | ||
| 								((MyItemInfo.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DSS_PageListSpBckgrnd) == E_DocStructStyle.DSS_PageListSpBckgrnd))
 | ||
| 								widthtpl = MyParentEditItem.Width + MyParentEditItem.Left - Left;
 | ||
| 							Width = widthtpl; // MyStepPanel.ToDisplay(MyStepSectionLayoutData.WidT) + spaceToRTB;
 | ||
| 							MyStepPanel.ItemMoving--;
 | ||
| 							//_MyParentRTBItem.Top = Bottom;
 | ||
| 							// Could be a Caution or Note - Need to get WidT
 | ||
| 							break;
 | ||
| 					}
 | ||
| 				}
 | ||
| 				LastMethodsPop();
 | ||
| 			}
 | ||
| 		}
 | ||
| 		private int BottomOfStepImmediatelyAbove()
 | ||
| 		{
 | ||
| 			int btm = 0;
 | ||
| 			if (MyBeforeEditItems != null && MyBeforeEditItems.Count > 0)			// Notes & Cautions before
 | ||
| 				btm = MyBeforeEditItems[MyBeforeEditItems.Count - 1].BottomMostEditItem.Bottom;
 | ||
| 			else
 | ||
| 			{
 | ||
| 				// if  on a caution or note, (the first one), need to go up to either previous step or the section to find its bottom
 | ||
| 				// _MyParentEditItem is a way to find that the structure supports this, i.e. there can be a caution or note:
 | ||
| 				if (_MyParentEditItem != null
 | ||
| 					&& _MyParentEditItem.MyBeforeEditItems != null && _MyParentEditItem.MyBeforeEditItems.Count > 0  // this part checks that there are cautions/notes
 | ||
| 					&& _MyParentEditItem.MyBeforeEditItems[0].MyID == MyID)		// first caution or note, i.e. index of MyBeforeItems == 0
 | ||
| 				{
 | ||
| 					if (_MyParentEditItem._MyPreviousEditItem == null)		// this part checks for first HLS
 | ||
| 						btm = _MyParentEditItem._MyParentEditItem.Bottom;			// bottom of the section
 | ||
| 					else
 | ||
| 						btm = _MyParentEditItem._MyPreviousEditItem.BottomMostEditItem.Bottom;		// bottom of previous step
 | ||
| 				}
 | ||
| 				else
 | ||
| 				{
 | ||
| 					btm = MyParentEditItem != null ? MyParentEditItem.Bottom : MyPreviousEditItem.BottomMostEditItem.Bottom;
 | ||
| 				}
 | ||
| 			}
 | ||
| 			return btm;
 | ||
| 		}
 | ||
| 		/// <summary>
 | ||
| 		/// Sets the previous item and adjusts locations
 | ||
| 		/// </summary>
 | ||
| 		public /*override*/ EditItem MyPreviousEditItem
 | ||
| 		{
 | ||
| 			get { return _MyPreviousEditItem; }
 | ||
| 			set
 | ||
| 			{
 | ||
| 				LastMethodsPush("set_MyPreviousRTBItem");
 | ||
| 				_MyPreviousEditItem = value;
 | ||
| 				if (_MyPreviousEditItem != null)
 | ||
| 				{
 | ||
| 					_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")) ||
 | ||
| 						(MyStepData.Type.ToLower().Contains("equation") || MyStepData.ParentType.ToLower().Contains("equation"))))
 | ||
| 					{
 | ||
| 						ItemWidth = TableWidth;
 | ||
| 						Location = new Point(_MyPreviousEditItem.Left, FindTop(_MyPreviousEditItem.BottomMostEditItem.Bottom));
 | ||
| 					}
 | ||
| 					else if (value.MyItemInfo.IsTablePart)
 | ||
| 					{
 | ||
| 						// B2019-179: if more than 1 table, get to the first that has the parent:
 | ||
| 						EditItem cur = (EditItem)value;
 | ||
| 						while (cur.MyPreviousEditItem != null) cur = cur.MyPreviousEditItem;
 | ||
| 						ItemLocation = new Point(cur.MyParentEditItem.ContentLeft, cur.Bottom);
 | ||
| 						ItemWidth = cur.MyParentEditItem.ContentWidth;
 | ||
| 					}
 | ||
| 					else
 | ||
| 					{
 | ||
| 						if (MyItemInfo.FormatStepData != null && MyItemInfo.FormatStepData.ReadOnly)
 | ||
| 						{
 | ||
| 							Graphics g = CreateGraphics();
 | ||
| 							SizeF sz = g.MeasureString(MyItemInfo.MyContent.Text, MyItemInfo.FormatStepData.Font.WindowsFont);
 | ||
| 							ItemWidth = (int)sz.Width;
 | ||
| 						}
 | ||
| 						else if (MyPreviousEditItem != null && MyPreviousEditItem.MyItemInfo.FormatStepData != null && MyPreviousEditItem.MyItemInfo.FormatStepData.ReadOnly)
 | ||
| 							ItemWidth = MyStepPanel.ToDisplay(MyStepSectionLayoutData.ColT) + MyStepPanel.ToDisplay(MyStepSectionLayoutData.WidSTableEdit, 0);
 | ||
| 						// RHM The following lines were commented-out for Facing Pages (Supplemental Information) to test follow the instructions 
 | ||
| 						//else if (MyItemInfo.MyTab.Offset != 0) // Farley - part of bug fix B2015-123 alignment of tabs on the edit screen  (Farly is only one using tab offset)
 | ||
| 						//	ContentWidth = (MyPreviousEditItem.MyItemInfo.MyTab.Offset != 0) ? MyPreviousEditItem.ContentWidth : MyPreviousEditItem.ContentWidth + 10;
 | ||
| 						else
 | ||
| 							Width = MyPreviousEditItem.Width;
 | ||
| 
 | ||
| 						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)))
 | ||
| 							{
 | ||
| 								// B2017-043 account for Horizontal Scroll
 | ||
| 								int x = MyStepPanel.DisplayRectangle.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
 | ||
| 								AdjustForDevDocStepHeight();
 | ||
| 								AdjustAllForSupInfoHeight();
 | ||
| 							}
 | ||
| 						}
 | ||
| 						else
 | ||
| 							TopMostEditItem.Location = new Point(TopMostEditItem.Left, FindTop(_MyPreviousEditItem.BottomMostEditItem.Bottom));
 | ||
| 					}
 | ||
| 					_IgnoreResize = false;
 | ||
| 					//ShowMe("");
 | ||
| 					//if (MyID > _StartingID)
 | ||
| 					//  Console.WriteLine("{0}-->Setting MyPreviousRTBItem {1},{2},{3},{4},{5},{6},{7}", WatchThisIndent, MyID, this
 | ||
| 					//    , _MyPreviousRTBItem
 | ||
| 					//    ,Top
 | ||
| 					//    , _MyPreviousRTBItem.BottomMostRTBItem.Bottom
 | ||
| 					//    , FindTop(_MyPreviousRTBItem.BottomMostRTBItem.Bottom)
 | ||
| 					//    , _MyPreviousRTBItem.Bottom);
 | ||
| 					//Location = new Point(_MyPreviousRTBItem.Left, _MyPreviousRTBItem.BottomMostRTBItem.Bottom);
 | ||
| 					switch (_MyChildRelation)
 | ||
| 					{
 | ||
| 						case ChildRelation.None:
 | ||
| 							break;
 | ||
| 						case ChildRelation.After:
 | ||
| 							break;
 | ||
| 						case ChildRelation.RNO:
 | ||
| 							break;
 | ||
| 						case ChildRelation.SupInfo:
 | ||
| 							break;
 | ||
| 						case ChildRelation.Before:
 | ||
| 							//MyStepPanel.ItemMoving++;
 | ||
| 							//UpOneRTBItem.Top = BottomMostRTBItem.Bottom;
 | ||
| 							//MyStepPanel.ItemMoving--;
 | ||
| 							break;
 | ||
| 					}
 | ||
| 					if (_MyPreviousEditItem.MyNextEditItem != this) _MyPreviousEditItem.MyNextEditItem = this;
 | ||
| 				}
 | ||
| 				LastMethodsPop();
 | ||
| 			}
 | ||
| 		}
 | ||
| 		// AdjustAllForSupInfoHeight & AdjustFOrSupInfoHeight go from current edit item down, adjusting any of the edit items' top
 | ||
| 		// location to account for any supplemental informations that items may have so that either the step or its supplemental information
 | ||
| 		// does not overwrite other steps on screen.
 | ||
| 		private void AdjustAllForSupInfoHeight()
 | ||
| 		{
 | ||
| 			EditItem ei = this;
 | ||
| 			while (ei != null)
 | ||
| 			{
 | ||
| 				ei = ei.AdjustForSupInfoHeight();
 | ||
| 			}
 | ||
| 		}
 | ||
| 		private EditItem AdjustForSupInfoHeight()
 | ||
| 		{
 | ||
| 			if (MyStepPanel._LookupEditItems.ContainsKey(MyID) && MyItemInfo.IsInSupInfo)  // only do this if it is displayed (in LookupEditItems and in sup info column
 | ||
| 			{
 | ||
| 				ItemInfo supInfoPart = MyItemInfo;
 | ||
| 				while (!supInfoPart.IsSupInfoPart) supInfoPart = supInfoPart.MyParent;
 | ||
| 				EditItem EIsupInfoPartAbove = MyStepPanel._LookupEditItems[supInfoPart.ItemID];
 | ||
| 
 | ||
| 				// find first edititem below this (EIWsupInfoBelow) or a sibling or child child that have sup info
 | ||
| 				//   if found, adjust top of this item to the bottommost edititem above this
 | ||
| 				EditItem EIWsupInfoBelow = null;
 | ||
| 				EIWsupInfoBelow = EIsupInfoPartAbove.MyParentEditItem.FindFirstChildWithSupInfo(EIsupInfoPartAbove.MyParentEditItem.MyItemInfo);
 | ||
| 				if (EIWsupInfoBelow == null)
 | ||
| 					EIWsupInfoBelow = EIsupInfoPartAbove.MyParentEditItem.FindSiblingOrParentSiblingWithSupInfo(EIsupInfoPartAbove.MyParentEditItem.MyItemInfo);
 | ||
| 
 | ||
| 				if (EIWsupInfoBelow != null)		// for editiem below, find bottom of step & subinfo column and take the max of these:
 | ||
| 				{
 | ||
| 					int bottomOfAboveSupInfoColumn = EIsupInfoPartAbove.BottomMostEditItem.Bottom;
 | ||
| 					int bottomOfImmediatelyAbove = EIWsupInfoBelow.BottomOfStepImmediatelyAbove();
 | ||
| 					MyStepPanel.ItemMoving++;
 | ||
| 					EIWsupInfoBelow.Top = Math.Max(bottomOfAboveSupInfoColumn, bottomOfImmediatelyAbove);
 | ||
| 					EIWsupInfoBelow.AdjustLocation();
 | ||
| 					MyStepPanel.ItemMoving--;
 | ||
| 					return EIWsupInfoBelow.MySupInfoEditItems == null ? null : EIWsupInfoBelow.MySupInfoEditItems[0];
 | ||
| 				}
 | ||
| 			}
 | ||
| 			return null;
 | ||
| 		}
 | ||
| 		private EditItem CheckForExpanded(EditItem ei)
 | ||
| 		{
 | ||
| 			ItemInfo hls = ei.MyItemInfo.MyHLS;
 | ||
| 			EditItem hlsEI = GetEditItemFromItemID(hls.ItemID);
 | ||
| 			if (hlsEI == null) return null;
 | ||
| 			return ei;
 | ||
| 		}
 | ||
| 		// FindSiblingOrParentSiblingWithSupInfo will find the next edititem below me on the screen that has a supinfo
 | ||
| 		private EditItem FindSiblingOrParentSiblingWithSupInfo(ItemInfo itm)
 | ||
| 		{
 | ||
| 			if (itm == null || itm.IsProcedure) return null;
 | ||
| 			if (itm.NextItem == null)
 | ||
| 			{
 | ||
| 				return FindSiblingOrParentSiblingWithSupInfo(itm.ActiveParent as ItemInfo);
 | ||
| 			}
 | ||
| 			EditItem chldOfNext = null;
 | ||
| 			// if section, handle notes/cautions on section and if none, look for hls (children of section)
 | ||
| 			if (itm.NextItem.IsSection)
 | ||
| 			{
 | ||
| 				if (itm.NextItem.Steps == null || itm.NextItem.Steps.Count == 0) return null;
 | ||
| 				chldOfNext = FindFirstCautionOrNoteWithSupInfo(itm.NextItem);
 | ||
| 				if (chldOfNext != null) return CheckForExpanded(chldOfNext);
 | ||
| 				chldOfNext = FindFirstChildWithSupInfo(itm.NextItem);
 | ||
| 				if (chldOfNext != null) return CheckForExpanded(chldOfNext);
 | ||
| 				return null;
 | ||
| 			}
 | ||
| 			// Handle caution/note off of itm.nextitem.  See if any of those have supinfos.
 | ||
| 			chldOfNext = FindFirstCautionOrNoteWithSupInfo(itm.NextItem);
 | ||
| 			if (chldOfNext != null) return CheckForExpanded(chldOfNext);
 | ||
| 
 | ||
| 			// this is step side (parent) of supinfo part.  This step does not have any children with supinfo.
 | ||
| 			// See if any of my next siblings have supinfo
 | ||
| 			if (itm.NextItem.SupInfos != null && itm.NextItem.SupInfos.Count > 0)
 | ||
| 			{
 | ||
| 				return GetEditItemFromItemID(itm.NextItem.ItemID);
 | ||
| 			}
 | ||
| 			// no longer looking at next, go to children.
 | ||
| 			chldOfNext = FindFirstChildWithSupInfo(itm.NextItem);
 | ||
| 			if (chldOfNext != null) return CheckForExpanded(chldOfNext);
 | ||
| 			return FindSiblingOrParentSiblingWithSupInfo(itm.NextItem);
 | ||
| 		}
 | ||
| 		// FindFirstChildWithSupinfo finds the first child going down the screen that has a supinfo.  It checks for cautions and
 | ||
| 		// notes first.
 | ||
| 		private EditItem FindFirstChildWithSupInfo(ItemInfo itm)
 | ||
| 		{
 | ||
| 			// If on a caution, see if there are any notes below me on the screen that have supinfo.
 | ||
| 			// B2017-237 Should use isCautionPart rather than IsCaution for BGE Mixed Cautions and Notes
 | ||
| 			if (itm.IsCautionPart && (itm.ActiveParent as ItemInfo).Notes != null && (itm.ActiveParent as ItemInfo).Notes.Count > 0)
 | ||
| 			{
 | ||
| 				foreach (ItemInfo inote in (itm.ActiveParent as ItemInfo).Notes)
 | ||
| 				{
 | ||
| 						if (inote.SupInfos != null && inote.SupInfos.Count > 0)
 | ||
| 							return GetEditItemFromItemID(inote.ItemID);
 | ||
| 					EditItem chld = FindFirstChildWithSupInfo(inote);
 | ||
| 						if (chld != null) return CheckForExpanded(chld);
 | ||
| 				}
 | ||
| 			}
 | ||
| 			// if on a caution or note check the step below me, which is really my activeparent (cautions/notes are above their respective parent)
 | ||
| 			if ((itm.IsCaution || itm.IsNote) && itm.NextItem == null && (itm.ActiveParent as ItemInfo).SupInfos != null && (itm.ActiveParent as ItemInfo).SupInfos.Count > 0)
 | ||
| 				return GetEditItemFromItemID((itm.ActiveParent as ItemInfo).ItemID);
 | ||
| 
 | ||
| 			// Finally check substeps:
 | ||
| 			if (itm.Steps == null || itm.Steps.Count == 0) return null;
 | ||
| 			foreach (ItemInfo ii in itm.Steps)
 | ||
| 			{
 | ||
| 				if (ii.SupInfos != null && ii.SupInfos.Count > 0)
 | ||
| 					return GetEditItemFromItemID(ii.ItemID);
 | ||
| 				EditItem chld = FindFirstChildWithSupInfo(ii);
 | ||
| 				if (chld != null) return CheckForExpanded(chld);
 | ||
| 			}
 | ||
| 			return null;
 | ||
| 		}
 | ||
| 		// FindFirstCautionOrNoteWithSupInfo looks for first caution or note going down the screen that has supInfo 
 | ||
| 		private EditItem FindFirstCautionOrNoteWithSupInfo(ItemInfo itm)
 | ||
| 		{
 | ||
| 			if (itm.Cautions != null && itm.Cautions.Count > 0)
 | ||
| 			{
 | ||
| 				foreach (ItemInfo ii in itm.Cautions)
 | ||
| 				{
 | ||
| 					if (ii.SupInfos != null && ii.SupInfos.Count > 0)
 | ||
| 						return GetEditItemFromItemID(ii.ItemID);
 | ||
| 					EditItem chld = FindFirstChildWithSupInfo(ii);
 | ||
| 					if (chld != null) return CheckForExpanded(chld);
 | ||
| 				}
 | ||
| 			}
 | ||
| 			if (itm.Notes != null && itm.Notes.Count > 0)
 | ||
| 			{
 | ||
| 				foreach (ItemInfo ii in itm.Notes)
 | ||
| 				{
 | ||
| 					if (ii.SupInfos != null && ii.SupInfos.Count > 0)
 | ||
| 						return GetEditItemFromItemID(ii.ItemID);
 | ||
| 					EditItem chld = FindFirstChildWithSupInfo(ii);
 | ||
| 					if (chld != null) return CheckForExpanded(chld);
 | ||
| 				}
 | ||
| 			}
 | ||
| 			return null;
 | ||
| 		}
 | ||
| 		private EditItem GetEditItemFromItemID(int itemid)
 | ||
| 		{
 | ||
| 			if (!MyStepPanel._LookupEditItems.ContainsKey(itemid)) return null;
 | ||
| 			return MyStepPanel._LookupEditItems[itemid];
 | ||
| 		}
 | ||
| 		/// <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
 | ||
| 		// If note exists return note
 | ||
| 		private EditItem NextDevDocStep
 | ||
| 		{
 | ||
| 			get
 | ||
| 			{
 | ||
| 				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)
 | ||
| 				{
 | ||
| 					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;
 | ||
| 							ei = eic;
 | ||
| 						}
 | ||
| 						else if (ei.MyItemInfo.Notes != null)//Look at notes
 | ||
| 						{
 | ||
| 							EditItem ein = MyStepPanel._LookupEditItems[ei.MyItemInfo.Notes[0].ItemID].BottomMostEditItem;
 | ||
| 							ei = ein;
 | ||
| 						}
 | ||
| 					}
 | ||
| 				}
 | ||
| 				return ei;
 | ||
| 			}
 | ||
| 		}
 | ||
| 		// RHM 20170216 Find Parent by walking up MyPrevious
 | ||
| 		private EditItem MyParent
 | ||
| 		{
 | ||
| 			get
 | ||
| 			{
 | ||
| 				if (MyParentEditItem != null) return MyParentEditItem;
 | ||
| 				return MyPreviousEditItem.MyParent;
 | ||
| 			}
 | ||
| 		}
 | ||
| 		// C2021-018 used to display Alarm Point Table RO values in the editor
 | ||
| 		//           Get the RO value for the given RO AccPageID and multiple Return Value option
 | ||
| 		private string ROLookupForEditorView(SectionInfo MySection, string accpageid, string multiid, string deflt)
 | ||
| 		{
 | ||
| 			ROFSTLookup myLookup = MySection.MyDocVersion.DocVersionAssociations[0].MyROFst.GetROFSTLookup(MySection.MyDocVersion, null);
 | ||
| 
 | ||
| 			string accpgid = accpageid;
 | ||
| 			
 | ||
| 			//B2022 - 083: Support Conditional RO Values
 | ||
| 			ROFSTLookup.rochild roc = myLookup.GetROChildByAccPageID(string.Format("<{0}.{1}>", accpgid, multiid), MySection.MyDocVersion.DocVersionConfig.RODefaults_setpointprefix, MySection.MyDocVersion.DocVersionConfig.RODefaults_graphicsprefix);
 | ||
| 
 | ||
| 			if (roc.value == null)
 | ||
| 			{
 | ||
| 				accpgid = accpgid.Replace(@"\u8209?", "-");
 | ||
| 				roc = myLookup.GetROChildByAccPageID(string.Format("<{0}.{1}>", accpgid, multiid), MySection.MyDocVersion.DocVersionConfig.RODefaults_setpointprefix, MySection.MyDocVersion.DocVersionConfig.RODefaults_graphicsprefix);
 | ||
| 			}
 | ||
| 
 | ||
| 			if (!deflt.StartsWith("[") && !string.IsNullOrEmpty(roc.value) && roc.value.Trim().Length > 0) // don't return val if it's an empty or blank string - jsj 01-28-2019
 | ||
| 			{
 | ||
| 				roc.value = roc.value.Replace("[xB3]", "\xB3");
 | ||
| 				roc.value = roc.value.Replace("[xB2]", "\xB2");
 | ||
| 				return roc.value;
 | ||
| 			}
 | ||
| 
 | ||
| 			return deflt;
 | ||
| 		}
 | ||
| 		// C2021-018 used to display Alarm Point Table RO values in the editor
 | ||
| 		private string ResolveUnitApp(DocVersionInfo dvi, string str)
 | ||
| 		{
 | ||
| 			if (dvi == null) return str;
 | ||
| 			// B2024-025 - process all of the applicability token (<U-xxx>, <U>, <ID>)
 | ||
| 			str = VEPROMS.CSLA.Library.DisplayText.ResolveUnitSpecific(dvi, str);
 | ||
| 			// look for un-resolved tokens and replace less/greater than chars with "*?" and "?*" respectively 
 | ||
| 			string tmp = str.ToUpper();
 | ||
| 			int sindx = tmp.IndexOf("<U");
 | ||
| 			int eindx = tmp.IndexOf(">", sindx + 1);
 | ||
| 			string reptmp;
 | ||
| 			while (sindx > -1 && eindx > -1) // B2022-007 added while loop to process more than one <U- RO value
 | ||
| 			{
 | ||
| 				reptmp = str.Substring(sindx, eindx - sindx + 1);
 | ||
| 				tmp = reptmp.ToUpper();
 | ||
| 				str = str.Replace(reptmp, tmp.Replace("<", "*?").Replace(">", "?*")); // unresolved token
 | ||
| 				tmp = str.ToUpper();
 | ||
| 				sindx = tmp.IndexOf("<U");
 | ||
| 				eindx = tmp.IndexOf(">", sindx + 1);
 | ||
| 			}
 | ||
| 			//string tmp = str.ToUpper();
 | ||
| 			//int sindx = tmp.IndexOf("<U");
 | ||
| 			//int eindx = tmp.IndexOf(">", sindx + 1);
 | ||
| 			//string reptmp;
 | ||
| 			//while (sindx > -1 && eindx > -1) // B2022-007 added while loop to process more than one <U- RO value
 | ||
| 			//{
 | ||
| 			//	reptmp = str.Substring(sindx, eindx - sindx + 1);
 | ||
| 			//	tmp = reptmp.ToUpper();
 | ||
| 			//	if (tmp == "<U>") str = str.Replace(reptmp, dvi.DocVersionConfig.Unit_Number);
 | ||
| 			//	else if (tmp == "<U-TEXT>") str = str.Replace(reptmp, dvi.DocVersionConfig.Unit_Text);
 | ||
| 			//	else if (tmp == "<U-NUMBER>") str = str.Replace(reptmp, dvi.DocVersionConfig.Unit_Number);
 | ||
| 			//	else if (tmp == "<U-NAME>") str = str.Replace(reptmp, dvi.DocVersionConfig.Unit_Name);
 | ||
| 			//	else if (tmp == "<U-ID>") str = str.Replace(reptmp, dvi.DocVersionConfig.Unit_ID);
 | ||
| 			//	// B2021-145: For applicability, the tree view & pdf file name are not getting resolved when using any of the <20>OTHER<45> tokens
 | ||
| 			//	else if (tmp == "<U-OTHERTEXT>") str = str.Replace(reptmp, dvi.DocVersionConfig.Other_Unit_Text);
 | ||
| 			//	else if (tmp == "<U-OTHERNUMBER>") str = str.Replace(reptmp, dvi.DocVersionConfig.Other_Unit_Number);
 | ||
| 			//	else if (tmp == "<U-OTHERNAME>") str = str.Replace(reptmp, dvi.DocVersionConfig.Other_Unit_Name);
 | ||
| 			//	else if (tmp == "<U-OTHERID>") str = str.Replace(reptmp, dvi.DocVersionConfig.Other_Unit_ID);
 | ||
| 			//	else str = str.Replace(reptmp, tmp.Replace("<", "*?").Replace(">", "?*"));
 | ||
| 			//	tmp = str.ToUpper();
 | ||
| 			//	sindx = tmp.IndexOf("<U");
 | ||
| 			//	eindx = tmp.IndexOf(">", sindx + 1);
 | ||
| 			//}
 | ||
| 			return str;
 | ||
| 		}
 | ||
| 		// C2021-018 used to display Alarm Point Table RO values in the editor
 | ||
| 		//           translate pagelist tokens that are used in the parameters for the RO Lookup calls
 | ||
| 		private bool ProcessROLookupCfgParams(VEPROMS.CSLA.Library.SectionInfo section, ref string plstr, string token)
 | ||
| 		{
 | ||
| 			bool retval = true;
 | ||
| 
 | ||
| 			// Paglist token inside a PS= conditional are surrounded by square brackets instead of curley
 | ||
| 			// ex. [BOX3] instead of {BOX3}, thus the redunant looking cases
 | ||
| 			switch (token)
 | ||
| 			{
 | ||
| 				case "{EOPNUM}":
 | ||
| 				case "[EOPNUM]":
 | ||
| 				case "{PREDELIMEOPNUM}":
 | ||
| 				case "[PREDELIMEOPNUM]":
 | ||
| 				case "{EOPNUMROLU}":
 | ||
| 				case "[EOPNUMROLU]":
 | ||
| 						string eopnum = section.MyProcedure.MyContent.Number;
 | ||
| 						if (eopnum.ToUpper().Contains(@"<U"))
 | ||
| 						{
 | ||
| 						// C2021-064 If we are processing the EOP number or an ROLookUp in the pagelist, then strip out the Parent/Child unit tokens
 | ||
| 						// so that we are left with just the EOP number.  This is used along with  Parent/Child RO Values (in RO Editor)
 | ||
| 						if ((token.Equals("{EOPNUMROLU}") || token.Equals("[EOPNUMROLU]")))
 | ||
| 						{
 | ||
| 							// copied Rgex from DisplayText and modifed to remove the Parent/Child Unit information
 | ||
| 							// i.e. <U>, <U-ID>, <U-NAME>, <U-TEXT>, <U-NUMBER>, <U-OTHERID>, <U-OTHERNAME>, <U-OTHERTEXT>, <U-OTHERNUMBER>
 | ||
| 							// F2023-078 - for Vogtle Units 3 & 4 Alarms - also remove dash after unit number
 | ||
| 							eopnum = Regex.Replace(eopnum, @"\<U\>(-|\\u8209\?)", "", RegexOptions.IgnoreCase);
 | ||
| 							eopnum = Regex.Replace(eopnum, @"\<U\>", "", RegexOptions.IgnoreCase);
 | ||
| 							eopnum = Regex.Replace(eopnum, @"\<(U(-|\\u8209\?)ID)\>(-|\\u8209\?)", "", RegexOptions.IgnoreCase);
 | ||
| 							eopnum = Regex.Replace(eopnum, @"\<(U(-|\\u8209\?)NAME)\>(-|\\u8209\?)", "", RegexOptions.IgnoreCase);
 | ||
| 							eopnum = Regex.Replace(eopnum, @"\<(U(-|\\u8209\?)TEXT)\>(-|\\u8209\?)", "", RegexOptions.IgnoreCase);
 | ||
| 							eopnum = Regex.Replace(eopnum, @"\<(U(-|\\u8209\?)NUMBER)\>(-|\\u8209\?)", "", RegexOptions.IgnoreCase);
 | ||
| 							// B2021-148 remove space character after "OTHER"
 | ||
| 							eopnum = Regex.Replace(eopnum, @"\<(U(-|\\u8209\?)OTHERID)\>(-|\\u8209\?)", "", RegexOptions.IgnoreCase);
 | ||
| 							eopnum = Regex.Replace(eopnum, @"\<(U(-|\\u8209\?)OTHERNAME)\>(-|\\u8209\?)", "", RegexOptions.IgnoreCase);
 | ||
| 							eopnum = Regex.Replace(eopnum, @"\<(U(-|\\u8209\?)OTHERTEXT)\>(-|\\u8209\?)", "", RegexOptions.IgnoreCase);
 | ||
| 							eopnum = Regex.Replace(eopnum, @"\<(U(-|\\u8209\?)OTHERNUMBER)\>(-|\\u8209\?)", "", RegexOptions.IgnoreCase);
 | ||
| 						}
 | ||
| 						else
 | ||
| 							eopnum = section.MyProcedure.DisplayNumber;// B2021-066: found and fixed during proc pc/pc work
 | ||
| 						}
 | ||
| 					// B2022-066 the "{PREDELIMEOPNUM}" token was not being processed because there was a space after the "{"
 | ||
| 					if (token.Equals("{PREDELIMEOPNUM}"))
 | ||
| 					{
 | ||
| 						// only use up to the first non-alphanumeric character of the procedur number
 | ||
| 						// Prairie Island (NSP) Alarms use this token
 | ||
| 						int idx = 0;
 | ||
| 						while (idx < eopnum.Length && char.IsLetterOrDigit(eopnum[idx])) idx++;
 | ||
| 						if (idx < eopnum.Length)
 | ||
| 							eopnum = eopnum.Substring(0, idx);
 | ||
| 					}
 | ||
| 					plstr = plstr.Replace(token, eopnum);
 | ||
| 					break;
 | ||
| 				default:
 | ||
| 					if (token.Contains(@"SI-"))   // procedure set specific information.  (at folder or working draft levels)
 | ||
| 					{
 | ||
| 						DocVersionConfig dvConfig = new DocVersionConfig(section.MyProcedure.MyDocVersion.Config);
 | ||
| 						FolderConfig folderConfig = new FolderConfig(section.MyProcedure.MyDocVersion.MyFolder.Config);
 | ||
| 						if (dvConfig != null || folderConfig != null)
 | ||
| 						{
 | ||
| 							int indx = token.IndexOf("-");
 | ||
| 							int qindx = token.IndexOf("?", indx);
 | ||
| 							string val = null;
 | ||
| 							if (qindx == -1)
 | ||
| 							{
 | ||
| 								val = DocVersionInfo.GetInheritedSIValue(section.MyProcedure, token.Substring(4, token.Length - 5));
 | ||
| 								// C2021-051: Applicability tokens in Procedure Set and Folder Specific Information
 | ||
| 								if (val.ToUpper().Contains("<U>") || val.ToUpper().Contains("<U-")) // Replace token with the applicable unit information
 | ||
| 								{
 | ||
| 									string unbr3 = ResolveUnitApp(section.MyDocVersion, val);
 | ||
| 									plstr = unbr3 ?? "";
 | ||
| 								}
 | ||
| 								plstr = plstr.Replace(token, val);
 | ||
| 								break; // B2019-134 break out of switch statement after processing the <SI- token so that it can loop and handle any other tokens on the same line
 | ||
| 							}
 | ||
| 							else
 | ||
| 							{
 | ||
| 								string pstok = token.Substring(indx + 1, qindx - indx - 1);
 | ||
| 								plstr = DocVersionInfo.GetInheritedSIValue(section.MyProcedure, pstok);
 | ||
| 								// C2021-051: Applicability tokens in Procedure Set and Folder Specific Information
 | ||
| 								if (plstr.ToUpper().Contains("<U>") || val.ToUpper().Contains("<U-")) // Replace token with the applicable unit information
 | ||
| 								{
 | ||
| 									string unbr3 = ResolveUnitApp(section.MyDocVersion, val);
 | ||
| 									plstr = unbr3 ?? "";
 | ||
| 								}
 | ||
| 							}
 | ||
| 						}
 | ||
| 					}
 | ||
| 					if (token.Contains(@"PS-"))
 | ||
| 					{
 | ||
| 						ProcedureConfig procConfig = new ProcedureConfig(section.MyProcedure.MyContent.Config);
 | ||
| 						if (procConfig != null)
 | ||
| 						{
 | ||
| 							int indx = token.IndexOf("-");
 | ||
| 							int qindx = token.IndexOf("?", indx);
 | ||
| 							string val = null;
 | ||
| 							if (qindx == -1)
 | ||
| 							{
 | ||
| 								val = procConfig.GetValue("PSI", token.Substring(4, token.Length - 5));
 | ||
| 								// F2021-034: Resolve applicability unit tokens (not just '<u>')
 | ||
| 								if (val.ToUpper().Contains("<U>") || val.ToUpper().Contains("<U-")) // Replace token with the applicable unit information
 | ||
| 								{
 | ||
| 									string unbr3 = ResolveUnitApp(section.MyDocVersion, val);
 | ||
| 									val = unbr3 ?? "";
 | ||
| 								}
 | ||
| 								plstr = plstr.Replace(token, val);
 | ||
| 							}
 | ||
| 							else
 | ||
| 							{
 | ||
| 								string pstok = token.Substring(indx + 1, qindx - indx - 1);
 | ||
| 								plstr = procConfig.GetValue("PSI", pstok);
 | ||
| 							}
 | ||
| 						}
 | ||
| 					}
 | ||
| 					if (plstr == "") retval = false;
 | ||
| 					break;
 | ||
| 			}
 | ||
| 			return retval;
 | ||
| 		}
 | ||
| 		private static Regex regexFindToken = new Regex("{[^{}]*}");
 | ||
| 		// C2021-018 used to display Alarm Point Table RO values in the editor
 | ||
| 		//           Spin through the pagelist for this seciton and grap the Alarm Point Information
 | ||
| 		protected string GetAlarmPointTableInfo(ItemInfo itmInfo)
 | ||
| 		{
 | ||
| 			SectionInfo section = itmInfo.GetSectionInfo();
 | ||
| 			StringBuilder strAlrmPtTableInfo = new StringBuilder();
 | ||
| 			// get alarm point data from pagelist
 | ||
| 			bool usePSIvalue = false; // C2021-065 used with ROLkUpMatch pagelist flag (Barakah Alarms)
 | ||
| 			int lastRow = -1;
 | ||
| 			string otherChildUnit = ""; // C2021-065 used when OTHER applicability information is used for the ROLookUp
 | ||
| 			foreach (VEPROMS.CSLA.Library.PageItem pageItem in itmInfo.MyDocStyle.pagestyle.PageItems)
 | ||
| 			{
 | ||
| 				if (pageItem.Token == null) continue;   // can be null if token is dependent on PSI lookup!
 | ||
| 														//DidHLSText = false;    // reset to false for this group of tokens.
 | ||
| 														//if (pageItem.Token.Contains("HLSTEXT"))
 | ||
| 														//    Console.WriteLine("{0} - PageList Token", pageItem.Token);
 | ||
| 
 | ||
| 				// C2019-006 - Moved and modified the RO_Lookup() logic here, before we process the tokens in the page list
 | ||
| 				// this allows us to use RO_Lookup() in a "PS=" conditional token (is usually a PSI check box)
 | ||
| 				// A while loop was also added to the we can have more than one call to RO_Lookup() on a pagelist line
 | ||
| 				// this logic was put in for Barakah Alarms
 | ||
| 				// Note that each Alarm is defined as its own RO in the Referenced Object database, with multiple return values
 | ||
| 				// to define the Window ID, Alarm, Source, Setpoint, etc. for example.
 | ||
| 				string pltok = pageItem.Token;
 | ||
| 				bool bDoUnderline = true; // F2023-078 new logic to also support Vogtle Units 3 & 4 Alarms - flag to underline pagelist text used as a tag/title
 | ||
| 				while (pltok.Contains("RO_Lookup("))
 | ||
| 				{
 | ||
| 					bDoUnderline = false;
 | ||
| 					int idxstart = pltok.IndexOf("RO_Lookup(");
 | ||
| 					int idxend = pltok.Substring(idxstart).IndexOf(")");
 | ||
| 					string ROLookupstr = pltok.Substring(idxstart, idxend + 1);
 | ||
| 					string parms = ROLookupstr.Substring(10, ROLookupstr.Length - 11);
 | ||
| 					MatchCollection sm = regexFindToken.Matches(parms);
 | ||
| 					foreach (Match m in sm) // resolve pagelist tokens that are parameters for ROLookup()
 | ||
| 					{
 | ||
| 						string tnk = m.Value;
 | ||
| 						ProcessROLookupCfgParams(section, ref parms, tnk); // translate the tokens in the parameters
 | ||
| 					}
 | ||
| 					string[] parts = parms.Split(",".ToCharArray());// split on comma
 | ||
| 																	// B2019-031 Support commas embedded in Alarm ID (Procedure Number)
 | ||
| 																	// B2019-075: Added the check for commas in the procedure number - this code was causing a bug in other alarms.
 | ||
| 					if (parts.Length > 3 && section.MyProcedure.DisplayNumber.IndexOf(",") > 0)// If extra commas combine first part to account for it
 | ||
| 					{
 | ||
| 						int n = parts.Length - 3;
 | ||
| 						string part0 = parts[0];
 | ||
| 						for (int i = 0; i < n; i++) // append parts based upon the number of parts (commas)
 | ||
| 							part0 += "," + parts[i + 1];
 | ||
| 						parts[0] = part0;
 | ||
| 						parts[1] = parts[n + 1];// Get the last 2 parts
 | ||
| 						parts[2] = parts[n + 2];
 | ||
| 					}
 | ||
| 					string ROLookupVal = "";
 | ||
| 					// parts[0] - the RO to look up - for Alarms, is usually the EOP number thus uses the "{EOPNUM}" token
 | ||
| 					// parts[1] - Which of the multiple return value from the RO to return 
 | ||
| 					// parts[2] - the value to use if not found in ROs - usually defined in a PSI field for that Alarm procedure
 | ||
| 
 | ||
| 					// C2021-065 Barakah Alarms - check if child RO alarm ID matches the resolved procedure number
 | ||
| 					// if not, then use the values stored in the PSI instead of the value returned for ROLookup()
 | ||
| 					// for all of the Alarm Point window items (ROLookup() items) in the pagelist for this section (BNPP Alarms format)
 | ||
| 					// Note only one pagelist item has this flag and this special pagelist item needs to be listed before any other ROLoopUP items
 | ||
| 					if (pageItem.ROLkUpMatch) // check for paglist flag
 | ||
| 					{
 | ||
| 						string rawPrcNum = section.MyProcedure.MyContent.Number;
 | ||
| 						// C2021-065 see if we need to get the Other child info from ROLookUp
 | ||
| 						if (rawPrcNum.ToUpper().StartsWith("<U\\U8209?OTHER")) // proc number has <u-otherxxx> in its definiation (procedure property page)
 | ||
| 						{
 | ||
| 							string procnum = section.MyProcedure.DisplayNumber; // get the cooked (resolved) procedure number
 | ||
| 							int idx = procnum.IndexOf('-');
 | ||
| 							otherChildUnit = procnum.Substring(0, idx); // we need to get RO info for the Other child applicability - this gets child's number
 | ||
| 						}
 | ||
| 						ROLookupVal = ROLookupForEditorView(section, parts[0], parts[1], ""); // will return empty string if alarm point is not found in RO database
 | ||
| 						usePSIvalue = (ROLookupVal == null || ROLookupVal.Length == 0);//!= section.MyProcedure.DisplayNumber); // use PSI value if child alarm ID not found or does not match resolved procedure number (alarm point)
 | ||
| 					}
 | ||
| 					// C2021-065 if usePSIvalue is true, then we know alarm point info is not in the RO database, so just use the default (PSI) value
 | ||
| 					if (usePSIvalue)
 | ||
| 						ROLookupVal = parts[2]; // C2021-065 use the value defined in the PSI
 | ||
| 					else
 | ||
| 						ROLookupVal = ROLookupForEditorView(section, parts[0], parts[1], parts[2]);
 | ||
| 
 | ||
| 					// F2021-053: Do replace words for Page List items.  This uses a DisplayText constructor that flags this case
 | ||
| 					//	and gets the resulting replaced words
 | ||
| 					if (pageItem.RepWords)
 | ||
| 					{
 | ||
| 						DisplayText dt1 = new DisplayText(itmInfo, ROLookupVal, false, true);
 | ||
| 						ROLookupVal = dt1.StartText;
 | ||
| 					}
 | ||
| 					// replace the pagelist token with ROLookupVal
 | ||
| 					pltok = pltok.Substring(0, idxstart) + ROLookupVal + ((idxstart + idxend < pltok.Length) ? pltok.Substring(idxstart + idxend + 1) : "");
 | ||
| 				}
 | ||
| 				// C2021-065 (BNPP Alarms format) we are processing a paglist flag (ROLkUpMatch) to determine how to get Alarm Point information
 | ||
| 				//           Nothing else is on this page list item, so use "continue" to jump to the next pagelist item as nothing gets printed for this item
 | ||
| 				if (!pageItem.ROLkUpMatch && pageItem.ROLkUpInEditor)
 | ||
| 				{
 | ||
| 					// F2023-078 (displaying Alarm Point Table RO information on the edit screen)
 | ||
| 					//           New logic is simplified to support both BNPP and Vogtle Units 3 & 4 alarms
 | ||
| 					if (bDoUnderline)
 | ||
| 					{
 | ||
| 						if (lastRow != -1)
 | ||
| 							strAlrmPtTableInfo.Append("\r\n");
 | ||
| 						pltok = pltok.TrimEnd(':');
 | ||
| 						strAlrmPtTableInfo.Append(string.Format("\\ul {0}\\ulnone :  ", pltok));
 | ||
| 						lastRow = (int)pageItem.Row;
 | ||
| 					}
 | ||
| 					else
 | ||
| 						strAlrmPtTableInfo.Append(pltok);
 | ||
| 				}
 | ||
| 			}
 | ||
| 					return strAlrmPtTableInfo.ToString();
 | ||
| 		}
 | ||
| 		// C2021-018 used to display Alarm Point Table RO values in the editor
 | ||
| 		//           we use a read-only note type, off of step section, to display the Alarm Point table RO information
 | ||
| 		//           create the note if it does not exist, update if it does
 | ||
| 		//           The docstyle for the step section must have the ShowAlarmPointWindowInfo flag
 | ||
| 		protected void SetupAlarmTableView(ItemInfo iteminfo)
 | ||
| 		{
 | ||
| 			if (iteminfo.IsStepSection && iteminfo.MyDocStyle.ShowAlarmPointWindowInfo)
 | ||
| 			{
 | ||
| 				string alrPtTblInfo = GetAlarmPointTableInfo(iteminfo);
 | ||
| 				if (!iteminfo.HasCautionOrNote) // BNPP Alarm format does not allow notes/cautions off of sections
 | ||
| 				{
 | ||
| 					ItemInfo tmpinfo = iteminfo.InsertChild(E_FromType.Note, 20028, alrPtTblInfo);
 | ||
| 					(tmpinfo.MyConfig as StepConfig).MasterSlave_Applicability = Volian.Base.Library.BigNum.MakeBigNum("0"); // set applicability to none
 | ||
| 					(tmpinfo.MyConfig as StepConfig).Step_CBOverride = "Off"; // turn of the change bar
 | ||
| 					MyItemInfo = tmpinfo; // SaveConfig() uses MyItemInfo which is null at this point, so set it to our new step item
 | ||
| 					SaveConfig();
 | ||
| 				}
 | ||
| 				else
 | ||
| 				{
 | ||
| 					if (iteminfo.Notes != null && iteminfo.Notes[0] != null)
 | ||
| 					{
 | ||
| 						ContentInfo cntinfo = iteminfo.Notes[0].MyContent;
 | ||
| 						if (!cntinfo.Text.Equals(alrPtTblInfo))
 | ||
| 							cntinfo.UpdateAlarmTableInfoView(alrPtTblInfo); // update with the new alarm point table information
 | ||
| 					}
 | ||
| 				}
 | ||
| 			}
 | ||
| 		}
 | ||
| 		protected void SetupEditItem(ItemInfo itemInfo, StepPanel myStepPanel, EditItem myParentEditItem, ChildRelation myChildRelation, bool expand, EditItem nextEditItem, bool addFirstChld)
 | ||
| 		{
 | ||
| 			if (myStepPanel.TopMostEditItem == null) myStepPanel.TopMostEditItem = this;
 | ||
| 			//if (itemInfo.ItemID == 10366) Console.WriteLine("Here");
 | ||
| 			//if (itemInfo.ItemID == 225) _MyStepRTB.Resize += new EventHandler(_MyStepRTB_Resize);
 | ||
| 			//_MyStepRTB.MyRTBItem = this;
 | ||
| 			//// TIMING: DisplayItem.TimeIt("CSLARTB InitComp");
 | ||
| 			BackColor = myStepPanel.PanelColor;
 | ||
| 			//_MyStepRTB.BackColor = myStepPanel.InactiveColor;
 | ||
| 			// TODO: Adjust top based upon format
 | ||
| 			// TODO: Remove Label and just output ident on the paint event
 | ||
| 			TabLeft = 20;
 | ||
| 			if (!itemInfo.IsStep)  // C2025-036 reduce un-needed processing - this will prevent duplicat calls that generate step tabs when loading a procedure
 | ||
| 				SetupHeader(itemInfo);
 | ||
| 			SetupAlarmTableView(itemInfo); // C2021-018 display alarm point table information in the step editor (if the format flag is set)
 | ||
| 			this.Paint -= new PaintEventHandler(EditItem_Paint);
 | ||
| 			this.Paint += new PaintEventHandler(EditItem_Paint);
 | ||
| 			this.BackColorChanged -= new EventHandler(EditItem_BackColorChanged);
 | ||
| 			this.BackColorChanged += new EventHandler(EditItem_BackColorChanged);
 | ||
| 			this.Move -= new EventHandler(EditItem_Move);
 | ||
| 			this.Move += new EventHandler(EditItem_Move);
 | ||
| 			this.Resize -= new EventHandler(EditItem_Resize);
 | ||
| 			this.Resize += new EventHandler(EditItem_Resize);
 | ||
| 			if (itemInfo != null)
 | ||
| 			{
 | ||
| 				ContentType = (int)itemInfo.MyContent.Type;
 | ||
| 				switch (ContentType / 10000)
 | ||
| 				{
 | ||
| 					case 0: // Procedure
 | ||
| 						ContentFont = myStepPanel.ProcFont;// lblTab.Font = myStepPanel.ProcFont;
 | ||
| 						TabFont = itemInfo.MyTab.MyFont.WindowsFont;
 | ||
| 						break;
 | ||
| 					case 1: // Section
 | ||
| 						ContentFont = myStepPanel.SectFont;// lblTab.Font = myStepPanel.SectFont;
 | ||
| 						TabFont = itemInfo.MyTab.MyFont.WindowsFont;
 | ||
| 						break;
 | ||
| 					case 2: // Steps
 | ||
| 						// Fix for B2016-037: there were '<NewID>'s in saved content text.  This was caused by a bug in code that
 | ||
| 						// did not resolve these correctly if there was more than 1 in the text.  So if, when loading the text, this
 | ||
| 						// is found, resolve them:
 | ||
| 						if (itemInfo.MyContent.Text.Contains("<NewID>"))
 | ||
| 						{
 | ||
| 							DisplayText vlntxt = new DisplayText(itemInfo, E_EditPrintMode.Edit, E_ViewMode.Edit, false, E_FieldToEdit.StepText, true, null, null, false);
 | ||
| 							vlntxt.SetDTS = false;
 | ||
| 							vlntxt.CleanUpNewIDs();
 | ||
| 							vlntxt = null;
 | ||
| 						}
 | ||
| 						ContentFont = myStepPanel.StepFont;//lblTab.Font = myStepPanel.StepFont;
 | ||
| 						if (itemInfo.MyTab != null) TabFont = itemInfo.MyTab.MyFont.WindowsFont;
 | ||
| 						MyStepData = itemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList[ContentType % 10000];
 | ||
| 						break;
 | ||
| 				}
 | ||
| 				//this.Move += new EventHandler(DisplayItem_Move);
 | ||
| 			}
 | ||
| 			else
 | ||
| 			{
 | ||
| 				if (myStepPanel.MyFont != null) ContentFont = TabFont = myStepPanel.MyFont;
 | ||
| 			}
 | ||
| 			if (expand) ShowExpanded();
 | ||
| 			MyStepPanel = myStepPanel;
 | ||
| 			if (itemInfo != null && !myStepPanel._LookupEditItems.ContainsKey(itemInfo.ItemID)) myStepPanel._LookupEditItems.Add(itemInfo.ItemID, this);
 | ||
| 			_MyChildRelation = myChildRelation;
 | ||
| 			if (myParentEditItem != null) RNOLevel = myParentEditItem.RNOLevel;
 | ||
| 			if (itemInfo != null)
 | ||
| 			{
 | ||
| 				//// TIMING: DisplayItem.TimeIt("CSLARTB before _Layout");
 | ||
| 				MyStepSectionLayoutData = itemInfo.ActiveFormat.MyStepSectionLayoutData;
 | ||
| 				//// TIMING: DisplayItem.TimeIt("CSLARTB _Layout");
 | ||
| 				if (myParentEditItem != null)
 | ||
| 					SeqLevel = myParentEditItem.SeqLevel + ((myChildRelation == ChildRelation.After || myChildRelation == ChildRelation.Before) && itemInfo.IsSequential ? 1 : 0);
 | ||
| 				//// TIMING: DisplayItem.TimeIt("CSLARTB seqLevel");
 | ||
| 				MyItemInfo = itemInfo;
 | ||
| 				MyItemInfo.MyConfig.PropertyChanged -= new PropertyChangedEventHandler(MyConfig_PropertyChanged);
 | ||
| 				MyItemInfo.MyConfig.PropertyChanged += new PropertyChangedEventHandler(MyConfig_PropertyChanged);
 | ||
| 			}
 | ||
| 			//// TIMING: DisplayItem.TimeIt("CSLARTB MyItem");
 | ||
| 			myStepPanel.Controls.Add(this);
 | ||
| 			switch (myChildRelation)
 | ||
| 			{
 | ||
| 				case ChildRelation.After:
 | ||
| 					AddItem(myParentEditItem, ref myParentEditItem._MyAfterEditItems, nextEditItem, addFirstChld);
 | ||
| 					break;
 | ||
| 				case ChildRelation.Before:
 | ||
| 					AddItem(myParentEditItem, ref myParentEditItem._MyBeforeEditItems, nextEditItem, addFirstChld);
 | ||
| 					break;
 | ||
| 				case ChildRelation.RNO:
 | ||
| 					RNOLevel = myParentEditItem.RNOLevel + 1;
 | ||
| 					AddItem(myParentEditItem, ref myParentEditItem._MyRNOEditItems, nextEditItem, addFirstChld);
 | ||
| 					break;
 | ||
| 				case ChildRelation.SupInfo:
 | ||
| 					AddItem(myParentEditItem, ref myParentEditItem._MySupInfoEditItems, nextEditItem, addFirstChld);
 | ||
| 					break;
 | ||
| 				case ChildRelation.None:
 | ||
| 					break;
 | ||
| 			}
 | ||
| 			if (itemInfo != null)
 | ||
| 			{
 | ||
| 				// ip2bck's needed the ContentWidth set to get the edit windows to size correctly.
 | ||
| 				if (itemInfo.IsStep && itemInfo.FormatStepData.Type == "TitleWithTextBelow" &&
 | ||
| 				 ((itemInfo.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DSS_PageListSpBckgrnd) == E_DocStructStyle.DSS_PageListSpBckgrnd))
 | ||
| 					ContentWidth = myParentEditItem.ContentWidth;
 | ||
| 				if (itemInfo.IsStep && itemInfo.MyParent.IsFigure)
 | ||
| 				{
 | ||
| 					// B2018-076 _ Handle Multiple Tables or Figure where Parent is null and Previous is not null
 | ||
| 					EditItem mypar = myParentEditItem;
 | ||
| 					while (mypar.MyParentEditItem == null && mypar.MyPreviousEditItem != null)
 | ||
| 						mypar = mypar.MyPreviousEditItem;
 | ||
| 					ContentWidth = mypar.MyParentEditItem.ContentWidth;
 | ||
| 					Left = mypar.MyParentEditItem.Left + mypar.MyParentEditItem.TabLeft; // B2017-129 fixed null reference
 | ||
| 				}
 | ||
| 
 | ||
| 				if (myChildRelation == ChildRelation.None)
 | ||
| 				{
 | ||
| 					if (ContentType == 0 && MyStepSectionLayoutData != null)
 | ||
| 					{
 | ||
| 						LastMethodsPush(string.Format("SetupRTBItem {0}", MyID));
 | ||
| 						int widt = MyStepPanel.ToDisplay(MyStepSectionLayoutData.WidT);
 | ||
| 						int wids = MyStepPanel.ToDisplay(MyStepSectionLayoutData.WidSTableEdit, 0);
 | ||
| 						ItemWidth = Math.Max(widt, wids);
 | ||
| 					}
 | ||
| 				}
 | ||
| 			}
 | ||
| 			//// TIMING: DisplayItem.TimeIt("CSLARTB Parent");
 | ||
| 			SetText();
 | ||
| 			if (itemInfo.IsSupInfoPart)
 | ||
| 			{
 | ||
| 				EditItem high = MyStepPanel._LookupEditItems[itemInfo.MyHLS.ItemID];
 | ||
| 				ContentLocation = new Point(high.ContentLeft + high.Width + 36, (int)_MyParentEditItem.Top + SupInfoTopOffset);
 | ||
| 			}
 | ||
| 			// B2020-012:  table location for sibling table is not correct, and possible first table.
 | ||
| 			if (itemInfo.IsTable) ItemLocation = TableLocation(MyStepSectionLayoutData, this.Width);
 | ||
| 			//// TIMING: DisplayItem.TimeIt("CSLARTB SetText");
 | ||
| 			if (itemInfo != null)
 | ||
| 			{
 | ||
| 				Name = string.Format("Item-{0}", itemInfo.ItemID);
 | ||
| 				SetExpandAndExpander(itemInfo);
 | ||
| 				if (expand && (itemInfo.MyContent.ContentPartCount != 0)) // If it should expand and it can expand
 | ||
| 					Expand(true);
 | ||
| 				else
 | ||
| 					if (myParentEditItem == null)// If it is the top node
 | ||
| 						if (ContentType >= 20000) // and it is a step - fully expand
 | ||
| 							Expand(true);
 | ||
| 						else // otherwise only expand one level
 | ||
| 							Expand(false);
 | ||
| 			}
 | ||
| 			//// TIMING: DisplayItem.TimeIt("CSLARTB before Controls Add");
 | ||
| 			//myStepPanel.Controls.Add(this);
 | ||
| 			// If on the first Caution/Note and the parent has a previous, for example a caution off of 5th HLS, go to the
 | ||
| 			// bottom on the previous parent.  In the example, the bottom of the 4th HLS.
 | ||
| 			int btm = myStepPanel.DisplayRectangle.Y;
 | ||
| 			int top = FindTop(btm);
 | ||
| 			if (MyItemInfo.ActiveFormat.MyStepSectionLayoutData.Dev_Format)
 | ||
| 				if (MyItemInfo.IsCaution || MyItemInfo.IsNote)
 | ||
| 					top = myParentEditItem.TopMostEditItem.Top;
 | ||
| 			//if ((MyItemInfo.SameRowAsParent && MyItemInfo.IsCaution2) || (MyItemInfo.ActiveFormat.MyStepSectionLayoutData.Dev_Format && (MyItemInfo.IsCaution || MyItemInfo.IsNote)))
 | ||
| 			//        top = myParentEditItem.TopMostEditItem.Top;
 | ||
| 			if (Top < top)
 | ||
| 			{
 | ||
| 				LastMethodsPush("SetupRTBItem");
 | ||
| 				MyStepPanel.ItemMoving++;
 | ||
| 				Top = top;
 | ||
| 				MyStepPanel.ItemMoving--;
 | ||
| 				LastMethodsPop();
 | ||
| 			}
 | ||
| 			this.Enabled = this.MyItemInfo.IsApplicable(MyStepPanel.ApplDisplayMode);
 | ||
| 			_Loading = false;
 | ||
| 			//// TIMING: DisplayItem.TimeIt("CSLARTB Controls Add");
 | ||
| 		}
 | ||
| 		void MyConfig_PropertyChanged(object sender, PropertyChangedEventArgs e)
 | ||
| 		{
 | ||
| 			SaveConfig();
 | ||
| 		}
 | ||
| 		public void SaveConfig()
 | ||
| 		{
 | ||
| 			if (!MyItemInfo.MyConfig.IsDirty) return;
 | ||
| 			using (Item itm = MyItemInfo.Get())
 | ||
| 			{
 | ||
| 				itm.MyContent.Config = MyItemInfo.MyConfig.ToString();
 | ||
| 				if (ChangeBarForConfigItemChange)
 | ||
| 					itm.MyContent.DTS = DateTime.Now;
 | ||
| 				itm.MyContent.UserID = Volian.Base.Library.VlnSettings.UserID;
 | ||
| 				itm.Save();
 | ||
| 			}
 | ||
| 			MyItemInfo.MyConfig.IsDirty = false;
 | ||
| 		}
 | ||
| 		/// <summary>
 | ||
| 		/// If the background changes, change the background of the RichTextBox
 | ||
| 		/// </summary>
 | ||
| 		/// <param name="sender"></param>
 | ||
| 		/// <param name="e"></param>
 | ||
| 		void EditItem_BackColorChanged(object sender, EventArgs e)
 | ||
| 		{
 | ||
| 			//IdentifyMe(false);
 | ||
| 		}
 | ||
| 		// TODO: the format of the circles, Checkoffs and Changebars should come from the format file
 | ||
| 		/// <summary>
 | ||
| 		/// This adds drawing items to the RTBItem as needed including
 | ||
| 		/// Circle around the Tab Number
 | ||
| 		/// Check-Offs
 | ||
| 		/// Change Bars
 | ||
| 		/// </summary>
 | ||
| 		/// <param name="sender"></param>
 | ||
| 		/// <param name="e"></param>
 | ||
| 		private void EditItem_Paint(object sender, PaintEventArgs e)
 | ||
| 		{
 | ||
| 			Graphics g = e.Graphics;
 | ||
| 			g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
 | ||
| 			//g.DrawString(lblTab.Text, MyItemInfo.MyTab.MyFont.WindowsFont, Brushes.Red, new RectangleF(new PointF(MyStepPanel.MyStepPanelSettings.NumberLocationX, MyStepPanel.MyStepPanelSettings.NumberLocationY), MyStepPanel.MyStepPanelSettings.NumberSize), StringFormat.GenericDefault);
 | ||
| 			// adjust x location of label by 7, to position correctly.
 | ||
| 			//g.DrawString(lblTab.Text, MyItemInfo.MyTab.MyFont.WindowsFont, Brushes.Blue, new RectangleF(new PointF(Convert.ToSingle(lblTab.Location.X-7), Convert.ToSingle(lblTab.Location.Y)), MyStepPanel.MyStepPanelSettings.NumberSize), StringFormat.GenericDefault);
 | ||
| 			//g.DrawLine(Pens.DarkGreen, lblTab.Location.X-7, 0, lblTab.Location.X-7, this.Height);
 | ||
| 			// Show a small E to indicate Enhanced Steps
 | ||
| 			DVEnhancedDocuments dveds = MyItemInfo.MyDocVersion.DocVersionConfig.MyEnhancedDocuments;
 | ||
| 			float x = 0;
 | ||
| 			float y = 0;
 | ||
| 			foreach (EnhancedDocument ed in MyItemInfo.GetMyEnhancedDocuments())
 | ||
| 			{
 | ||
| 				DVEnhancedDocument dved = dveds.GetByType(ed.Type);
 | ||
| 				// follow through in fixing an Out of Window Handles bug, use new function to see if 
 | ||
| 				// we can retrieve the font from a dictionary instead a doing a New and using another
 | ||
| 				// window handle B2017-117
 | ||
| 				Font fnt = VE_Font.GetWinSysFont("Arial", 5);
 | ||
| 				//g.DrawLine(Pens.DarkGreen, 18, 1, 18, 6);
 | ||
| 				//g.DrawLine(Pens.DarkGreen, 18, 1, 21, 1);
 | ||
| 				//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);
 | ||
| 				if (y > 0)
 | ||
| 				{
 | ||
| 					x += 18;
 | ||
| 					y = 0;
 | ||
| 				}
 | ||
| 				else
 | ||
| 					y = 14;
 | ||
| 			}
 | ||
| 			//g.DrawLine(Pens.DarkGreen, MyStepRTB.Location.X - 7, 0, MyStepRTB.Location.X - 7, this.Height);
 | ||
| 			//g.DrawString(TabText, MyItemInfo.MyTab.MyFont.WindowsFont, Brushes.Black, new RectangleF(new PointF(Convert.ToSingle(TabLocation.X), Convert.ToSingle(TabLocation.Y)), MyStepPanel.MyStepPanelSettings.NumberSize), StringFormat.GenericDefault);
 | ||
| 			Font myWFont = (MyItemInfo.MyTab != null) ? MyItemInfo.MyTab.MyFont.WindowsFont : MyItemInfo.FormatStepData.Font.WindowsFont;
 | ||
| 
 | ||
| 			// added Try/Catch when working on B2017-143, kept in to prevent PROMS from crashing after printing a procedure that has a seq tab with a different font style
 | ||
| 			try
 | ||
| 			{
 | ||
| 				g.DrawString(TabText, myWFont, Brushes.Black, new RectangleF(new PointF(Convert.ToSingle(TabLocation.X), Convert.ToSingle(TabLocation.Y)), this.Size), StringFormat.GenericDefault);
 | ||
| 			}
 | ||
| 			catch (Exception ex)
 | ||
| 			{
 | ||
| 				_MyLog.Warn("EditItem DrawString", ex);
 | ||
| 			}
 | ||
| 
 | ||
| 			//g.DrawLine(Pens.DarkGreen, lblTab.Location.X, 0, lblTab.Location.X, this.Height);
 | ||
| 			//g.DrawLine(Pens.DarkGreen, MyStepRTB.Location.X, 0, MyStepRTB.Location.X, this.Height); 
 | ||
| 			if (Circle)
 | ||
| 			{
 | ||
| 				Pen penC = new Pen(MyStepPanel.MyStepPanelSettings.CircleColor, MyStepPanel.MyStepPanelSettings.CircleWeight);
 | ||
| 				g.DrawArc(penC, TabLeft + 1, 0, MyStepPanel.MyStepPanelSettings.CircleDiameter, MyStepPanel.MyStepPanelSettings.CircleDiameter, 0F, 360F);
 | ||
| 			}
 | ||
| 			if (CheckOff)
 | ||
| 			{
 | ||
| 				Pen penCO = new Pen(MyStepPanel.MyStepPanelSettings.CheckOffColor, MyStepPanel.MyStepPanelSettings.CheckOffWeight);
 | ||
| 				g.DrawRectangle(penCO, MyStepPanel.MyStepPanelSettings.CheckOffX, MyStepPanel.MyStepPanelSettings.CheckOffY, MyStepPanel.MyStepPanelSettings.CheckOffSize, MyStepPanel.MyStepPanelSettings.CheckOffSize);
 | ||
| 			}
 | ||
| 			if (ChangeBar)
 | ||
| 			{
 | ||
| 				Pen penCB = new Pen(MyStepPanel.MyStepPanelSettings.ChangeBarColor, MyStepPanel.MyStepPanelSettings.ChangeBarWeight);
 | ||
| 				if (ChangeBarPosition == E_ChangeBarPosition.Left)
 | ||
| 					g.DrawLine(penCB, 0, ContentTop, 0, Height);  // left, top, right, bottom.  
 | ||
| 				else
 | ||
| 				{
 | ||
| 					float X;
 | ||
| 					float H;
 | ||
| 					if (this is GridItem)
 | ||
| 					{
 | ||
| 						GridItem gi = this as GridItem;
 | ||
| 						X = gi.MyFlexGrid.Right + 2;
 | ||
| 						H = gi.MyFlexGrid.Height;
 | ||
| 					}
 | ||
| 					else if (this is RtfRawItem)
 | ||
| 					{
 | ||
| 						RtfRawItem ri = this as RtfRawItem;
 | ||
| 						X = ri.MyStepRTB.Right + 4;
 | ||
| 						H = ri.MyStepRTB.Height;
 | ||
| 					}
 | ||
| 					else if (this is ImageItem)
 | ||
| 					{
 | ||
| 						ImageItem ii = this as ImageItem;
 | ||
| 						X = ii.MyPictureBox.Right + 4;
 | ||
| 						H = ii.MyPictureBox.Height;
 | ||
| 					}
 | ||
| 					else
 | ||
| 					{
 | ||
| 						RTBItem ri = this as RTBItem;
 | ||
| 						X = ri.MyStepRTB.Right + 2;
 | ||
| 						H = ri.MyStepRTB.Height;
 | ||
| 					}
 | ||
| 					g.DrawLine(penCB, X, ContentTop, X, ContentTop + H); //Height);
 | ||
| 				}
 | ||
| 			}
 | ||
| 			if (UserCheckOff)
 | ||
| 			{
 | ||
| 				PointF location;
 | ||
| 				if (this is GridItem)
 | ||
| 				{
 | ||
| 					GridItem gi = this as GridItem;
 | ||
| 					location = new PointF(gi.MyFlexGrid.Left + gi.MyFlexGrid.Width + 2, gi.MyFlexGrid.Top);
 | ||
| 				}
 | ||
| 				else if (this is RtfRawItem)
 | ||
| 				{
 | ||
| 					RtfRawItem rr = this as RtfRawItem;
 | ||
| 					// SkipSpaces puts the checkoff macro (if specified in the format) next to the step tab
 | ||
| 					// this is used for Bryon and Braidwood
 | ||
| 					if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.ProcData.CheckOffData.SkipSpaces)
 | ||
| 						location = new PointF(rr.MyStepRTB.Left - 50, rr.MyStepRTB.Top);
 | ||
| 					else
 | ||
| 						location = new PointF(rr.MyStepRTB.Left + rr.MyStepRTB.Width + 2, rr.MyStepRTB.Top);
 | ||
| 				}
 | ||
| 				else if (this is ImageItem)
 | ||
| 				{
 | ||
| 					ImageItem ii = this as ImageItem;
 | ||
| 					if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.ProcData.CheckOffData.SkipSpaces)
 | ||
| 						location = new PointF(ii.MyPictureBox.Left - 50, ii.MyPictureBox.Top);
 | ||
| 					else
 | ||
| 						location = new PointF(ii.MyPictureBox.Left + ii.MyPictureBox.Width + 2, ii.MyPictureBox.Top);
 | ||
| 				}
 | ||
| 				else
 | ||
| 				{
 | ||
| 					RTBItem ri = this as RTBItem;
 | ||
| 					// SkipSpaces puts the checkoff macro (if specified in the format) next to the step tab
 | ||
| 					// this is used for Bryon and Braidwood
 | ||
| 					if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.ProcData.CheckOffData.SkipSpaces)
 | ||
| 						location = new PointF(ri.MyStepRTB.Left - 50, ri.MyStepRTB.Top);
 | ||
| 					else
 | ||
| 						location = new PointF(ri.MyStepRTB.Left + ri.MyStepRTB.Width + 2, ri.MyStepRTB.Top);
 | ||
| 				}
 | ||
| 				CheckOff co = MyItemInfo.GetCheckOffStep();
 | ||
| 				// There may have been a data change in the setting of which checkoff to use (property 
 | ||
| 				// change in the config data), or whether a checkoff is used at all. Need to set the 
 | ||
| 				// 'UserCheckOff' or 'UserCheckOffChar' properties to reflect that.
 | ||
| 				if (co != null && co.UIMark != null)
 | ||
| 				{
 | ||
| 					UserCheckOffChar = (char)co.UIMark;
 | ||
| 					Font myFont = new Font("VolianDraw", MyItemInfo.MyTab.MyFont.WindowsFont.Size);
 | ||
| 					g.DrawString(UserCheckOffChar.ToString(), myFont, Brushes.DarkGreen, new RectangleF(location, MyStepPanel.MyStepPanelSettings.NumberSize), StringFormat.GenericDefault);
 | ||
| 				}
 | ||
| 				else if (co == null) UserCheckOff = false;
 | ||
| 			}
 | ||
| 		}
 | ||
| 	}
 | ||
| }
 |