2395 lines
		
	
	
		
			82 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			2395 lines
		
	
	
		
			82 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;
 | 
						|
 | 
						|
namespace Volian.Controls.Library
 | 
						|
{
 | 
						|
	#region Enums
 | 
						|
	public enum ChildRelation : int
 | 
						|
	{
 | 
						|
		None = 0,
 | 
						|
		After = 1,
 | 
						|
		Before = 2,
 | 
						|
		RNO = 3
 | 
						|
	}
 | 
						|
	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();
 | 
						|
		}
 | 
						|
 | 
						|
		public EditItem(IContainer container)
 | 
						|
		{
 | 
						|
			container.Add(this);
 | 
						|
			InitializeComponent();
 | 
						|
		}
 | 
						|
		#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
 | 
						|
		{
 | 
						|
			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; }
 | 
						|
		}
 | 
						|
		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 int _ExpandSuffix = 0;
 | 
						|
		public int ExpandSuffix
 | 
						|
		{
 | 
						|
			get { return _ExpandSuffix; }
 | 
						|
			set { _ExpandSuffix = 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; }
 | 
						|
		}
 | 
						|
		/// <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 = _MyParentEditItem.MySectionRTBItem;
 | 
						|
				}
 | 
						|
				return _MySectionRTBItem;
 | 
						|
			}
 | 
						|
			set { _MySectionRTBItem = value; }
 | 
						|
		}
 | 
						|
		/// <summary>
 | 
						|
		/// Gets or Sets ItemInfo
 | 
						|
		/// </summary>
 | 
						|
		public ItemInfo MyItemInfo
 | 
						|
		{
 | 
						|
			get { return _MyItemInfo; }
 | 
						|
			set
 | 
						|
			{
 | 
						|
				_MyItemInfo = value;
 | 
						|
				if (VlnSettings.StepTypeToolType) SetToolTip(_MyItemInfo.ToolTip);
 | 
						|
				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.MyProcedure.MyContent.Changed += new ContentInfoEvent(MyContent_Changed);
 | 
						|
				// Deal with change in item data
 | 
						|
				value.Changed += new ItemInfoEvent(value_Changed);
 | 
						|
				value.OrdinalChanged += new ItemInfoEvent(value_OrdinalChanged);
 | 
						|
			}
 | 
						|
		}
 | 
						|
		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; }
 | 
						|
		}
 | 
						|
		/// <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)
 | 
						|
		{
 | 
						|
			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);
 | 
						|
		}
 | 
						|
		/// <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;
 | 
						|
				}
 | 
						|
				else // Add to the middle of the list before a particular item
 | 
						|
				{
 | 
						|
					EditItem prevChild = nextEditItem.MyPreviousEditItem;
 | 
						|
					EditItem parent = nextEditItem.MyParentEditItem;
 | 
						|
					siblingEditItems.Insert(siblingEditItems.IndexOf(nextEditItem), this);
 | 
						|
					MyStepPanel.ItemMoving++;
 | 
						|
					_MyNextEditItem = nextEditItem;
 | 
						|
					nextEditItem._MyPreviousEditItem = this;
 | 
						|
					MyPreviousEditItem = prevChild;// If a previous exists - this will adjust the location and width of the EditItem
 | 
						|
					nextEditItem.MyParentEditItem = null;
 | 
						|
					MyParentEditItem = parent; // If a parent exists - this will adjust the location and width of the EditItem
 | 
						|
					//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) foreach (EditItem chld in _MyAfterEditItems) chld.SetAllTabs();
 | 
						|
			if (_MyNextEditItem != null) _MyNextEditItem.SetAllTabs();
 | 
						|
			// Update the RNO tab if it exists - RHM 20100106
 | 
						|
			if (_MyRNOEditItems != null) foreach (EditItem chld in _MyRNOEditItems) 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();
 | 
						|
			}
 | 
						|
		}
 | 
						|
		public void RemoveItem()
 | 
						|
		{
 | 
						|
			//Volian.Base.Library.VlnTimer _MyTimer = new VlnTimer();
 | 
						|
			BeingRemoved = true;
 | 
						|
			MyStepPanel.SelectedEditItem = null; // Unselect the item to be deleted
 | 
						|
			//ShowTops("\r\n");
 | 
						|
			int TopMostYBefore = TopMostEditItem.Top;
 | 
						|
			//_MyTimer.ActiveProcess = "DeleteItem";
 | 
						|
			EditItem newFocus = DeleteItem();
 | 
						|
			if (newFocus == null) return;
 | 
						|
			//_MyTimer.ActiveProcess = "SetFocus";
 | 
						|
			newFocus.SetFocus();
 | 
						|
			//_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");
 | 
						|
		}
 | 
						|
		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;
 | 
						|
			}
 | 
						|
			// 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
 | 
						|
				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;
 | 
						|
				MyPreviousEditItem = null;
 | 
						|
				//Console.Write(",\"Previous\",");
 | 
						|
			}
 | 
						|
			else
 | 
						|
			{
 | 
						|
				newFocus = MyParentEditItem;
 | 
						|
				MyParentEditItem = null;
 | 
						|
				//Console.Write(",\"Parent\",");
 | 
						|
			}
 | 
						|
			//_MyTimer.ShowElapsedTimes("DeleteItem");
 | 
						|
			return newFocus;
 | 
						|
		}
 | 
						|
 | 
						|
		private void HandleSqlExceptionOnDelete(System.Data.SqlClient.SqlException ex)
 | 
						|
		{
 | 
						|
			if (ex.Message.Contains("has External Transitions and has no next step"))
 | 
						|
			{
 | 
						|
				using (TransitionInfoList exTrans = TransitionInfoList.GetExternalTransitions(MyID))
 | 
						|
				{
 | 
						|
					DialogResult ans = MessageBox.Show("Transitions exist to this step and cannot be adjusted automatically." +
 | 
						|
						"\r\n\r\nDo you want to be placed on the " + (exTrans.Count > 1 ? "first " : "") + "substep with the problem Transition?" +
 | 
						|
						"\r\n\r\nSubsteps with Problem Transitions" +
 | 
						|
						exTrans.Summarize(),
 | 
						|
						"Cannot Delete This Step", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
 | 
						|
					if (ans == DialogResult.Yes)
 | 
						|
					{
 | 
						|
						MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OpenItem(exTrans[0].MyContent.ContentItems[0]);
 | 
						|
 | 
						|
					}
 | 
						|
					else
 | 
						|
						SetFocus();
 | 
						|
				}
 | 
						|
			}
 | 
						|
			else if (ex.Message.Contains("has External Transitions to it's children"))
 | 
						|
			{
 | 
						|
				using (TransitionInfoList exTrans = TransitionInfoList.GetExternalTransitionsToChildren(MyID))
 | 
						|
				{
 | 
						|
					DialogResult ans = MessageBox.Show("Transitions exist to substeps of this step and cannot be adjusted automatically." +
 | 
						|
						"\r\n\r\nDo you want to be placed on the " + (exTrans.Count > 1 ? "first " : "") + "substep with the problem Transition?" +
 | 
						|
						"\r\n\r\nSubsteps with Problem Transitions:" +
 | 
						|
						exTrans.Summarize(),
 | 
						|
						"Cannot Delete This Step", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
 | 
						|
					if (ans == DialogResult.Yes)
 | 
						|
					{
 | 
						|
						MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OpenItem(exTrans[0].MyContent.ContentItems[0]);
 | 
						|
					}
 | 
						|
				}
 | 
						|
			}
 | 
						|
			else
 | 
						|
				MessageBox.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;
 | 
						|
			}
 | 
						|
			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);
 | 
						|
		}
 | 
						|
		/// <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);
 | 
						|
		}
 | 
						|
		/// <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.MyContent.ContentGridCount != 0)
 | 
						|
			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.MyContent.ContentGridCount != 0)
 | 
						|
			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.MyContent.ContentGridCount != 0)
 | 
						|
			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;
 | 
						|
		}
 | 
						|
		/// <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);
 | 
						|
			DoAddSiblingAfter(newItemInfo, updateStatus);
 | 
						|
		}
 | 
						|
		public void AddSiblingAfter(int? type, bool updateStatus)
 | 
						|
		{
 | 
						|
			SaveContents();
 | 
						|
			ItemInfo newItemInfo = MyItemInfo.InsertSiblingAfter("", "", type);
 | 
						|
			DoAddSiblingAfter(newItemInfo, updateStatus);
 | 
						|
		}
 | 
						|
		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;
 | 
						|
				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(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);
 | 
						|
			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;
 | 
						|
				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;
 | 
						|
		}
 | 
						|
		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.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;
 | 
						|
				default:
 | 
						|
					newEditItem = this.AddChildAfter(newItemInfo, nextItem);
 | 
						|
					break;
 | 
						|
			}
 | 
						|
			MyStepPanel.SelectedEditItem = newEditItem;//Update Screen
 | 
						|
		}
 | 
						|
		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);
 | 
						|
			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;
 | 
						|
				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));
 | 
						|
 | 
						|
		}
 | 
						|
		public void PasteSiblingAfter(int copyStartID)
 | 
						|
		{
 | 
						|
			ItemInfo newItemInfo = MyItemInfo.PasteSiblingAfter(copyStartID);
 | 
						|
			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;
 | 
						|
				default: // Need debug
 | 
						|
					break;
 | 
						|
			}
 | 
						|
			MyStepPanel.SelectedEditItem = newEditItem;//Update Screen
 | 
						|
			MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OnItemPaste(this, new vlnTreeItemInfoPasteEventArgs(newItemInfo, copyStartID, ItemInfo.EAddpingPart.After, newItemInfo.MyContent.Type));
 | 
						|
 | 
						|
		}
 | 
						|
		public EditItem PasteReplace(int copyStartID)
 | 
						|
		{
 | 
						|
			// To allow a Paste Step into an empty (new) step/substep, we need to add a character to the the Text field
 | 
						|
			// to simulate replacing an existing step -  otherwise we will get null references.
 | 
						|
			if (MyStepPanel.SelectedEditItem.Empty)
 | 
						|
				MyStepPanel.SelectedEditItem.Empty=false;
 | 
						|
			MyStepPanel.SelectedEditItem = null; // Unselect the item to be deleted
 | 
						|
			ChildRelation childRelation = _MyChildRelation;
 | 
						|
			EditItem newFocus = null;
 | 
						|
			EditItem nextEditItem = MyNextEditItem;
 | 
						|
			EditItem prevEditItem = MyPreviousEditItem;
 | 
						|
			EditItem parentEditItem = ActiveParent;
 | 
						|
 | 
						|
			int TopMostYBefore = TopMostEditItem.Top;
 | 
						|
			int? TopMostParentY = (MyParentEditItem == null ? null : (int?)(MyParentEditItem.TopMostEditItem.Top));
 | 
						|
			int? ParentY = (MyParentEditItem == null ? null : (int?)(MyParentEditItem.Top));
 | 
						|
			ItemInfo newItemInfo = null;
 | 
						|
			try
 | 
						|
			{
 | 
						|
				newItemInfo = Item.PasteReplace(MyItemInfo, copyStartID);
 | 
						|
			}
 | 
						|
			catch (System.Data.SqlClient.SqlException ex)
 | 
						|
			{
 | 
						|
				HandleSqlExceptionOnDelete(ex);
 | 
						|
				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;
 | 
						|
				default: // Need debug
 | 
						|
					break;
 | 
						|
			}
 | 
						|
			MyStepPanel.SelectedEditItem = newEditItem;	//Update Screen
 | 
						|
			MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OnItemPaste(this, new vlnTreeItemInfoPasteEventArgs(newItemInfo, copyStartID, ItemInfo.EAddpingPart.Replace, newItemInfo.MyContent.Type));
 | 
						|
			return newEditItem;
 | 
						|
		}
 | 
						|
		public void IdentifyChildren(bool highlight)
 | 
						|
		{
 | 
						|
			// Highlight children of EditItem:
 | 
						|
			if (MyAfterEditItems != null)
 | 
						|
			{
 | 
						|
				foreach (EditItem sia in MyAfterEditItems)
 | 
						|
				{
 | 
						|
					sia.IdentifyMe(highlight);
 | 
						|
					sia.IdentifyChildren(highlight);
 | 
						|
				}
 | 
						|
			}
 | 
						|
			if (MyBeforeEditItems != null)
 | 
						|
			{
 | 
						|
				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);
 | 
						|
				}
 | 
						|
			}
 | 
						|
		}
 | 
						|
		#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;
 | 
						|
						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));
 | 
						|
						rnoTop.Top = BottomMostEditItemNoRNOs.Bottom;
 | 
						|
						rnoTop.LastMethodsPop();
 | 
						|
						MyStepPanel.ItemMoving--;
 | 
						|
					}
 | 
						|
				}
 | 
						|
			}
 | 
						|
		}
 | 
						|
		private bool _TryAgainLater = false;
 | 
						|
		public bool TryAgainLater
 | 
						|
		{
 | 
						|
			get { return _TryAgainLater; }
 | 
						|
			set { _TryAgainLater = value; }
 | 
						|
		}
 | 
						|
		/// <summary>
 | 
						|
		/// Handles movement of the EditItems
 | 
						|
		/// </summary>
 | 
						|
		/// <param name="sender"></param>
 | 
						|
		/// <param name="e"></param>
 | 
						|
		private void EditItem_Move(object sender, EventArgs e)
 | 
						|
		{
 | 
						|
			int watchThis = _WatchThis;
 | 
						|
			//if (MyID == 136)
 | 
						|
			//{
 | 
						|
			//  vlnStackTrace.ShowStack("{0} Move TO {1}", MyID, Top);
 | 
						|
			//  //vlnStackTrace.ShowStack("{0} Move TO {1} - {2}, BottomMost {3}", MyID, Top, MyPath, BottomMostRTBItem.MyPath);
 | 
						|
			//  //Console.WriteLine("{0} Move TO {1} - {2}, BottomMost {3}", MyID, Top, MyPath, BottomMostRTBItem.MyPath);
 | 
						|
			//}
 | 
						|
			//if (MyID > _StartingID)
 | 
						|
			//  Console.WriteLine("{0}--------------- {1} Top = {2} Bottom {3}", WatchThisIndent, MyID, Top, Bottom);
 | 
						|
			if (MyStepPanel.ItemMoving == 0 && !TryAgainLater)
 | 
						|
			{
 | 
						|
				//vlnStackTrace.ScrollInStack();
 | 
						|
				return; // If 0 - Indicates scrolling which requires no action.
 | 
						|
			}
 | 
						|
			TryAgainLater = false;
 | 
						|
			//ShowMe("Move");
 | 
						|
			if (MyItemInfo == null)
 | 
						|
				return;
 | 
						|
			//if (_WatchThis > 0 && MyID > _StartingID)
 | 
						|
			//{
 | 
						|
 | 
						|
			//  Console.WriteLine("{0}Start Move  {1},{2}", WatchThisIndent, MyID, this);
 | 
						|
			//  if (MyID == _LookForID)
 | 
						|
			//    Console.WriteLine("{0}---------------", WatchThisIndent,MyID, this);
 | 
						|
			//  _WatchThis++;
 | 
						|
			//}
 | 
						|
			if (MyExpandingStatus == ExpandingStatus.Expanding)
 | 
						|
			{
 | 
						|
				_WatchThis = watchThis;
 | 
						|
				return;
 | 
						|
			}
 | 
						|
			Moving = true;
 | 
						|
			EditItem tmp = (EditItem)sender;
 | 
						|
			if (tmp.MyPreviousEditItem == null && tmp.MyParentEditItem == null)
 | 
						|
			{
 | 
						|
				_WatchThis = watchThis;
 | 
						|
				return;
 | 
						|
			}
 | 
						|
			if (RNOBelow) // Adjust substeps first
 | 
						|
			{
 | 
						|
				//Console.WriteLine("RNOBelow"); 
 | 
						|
				AdjustLocation();
 | 
						|
				MoveRNO();
 | 
						|
			}
 | 
						|
			else // Adjust RNO First
 | 
						|
			{
 | 
						|
				if (RNORight)
 | 
						|
				{
 | 
						|
					//Console.WriteLine("RNORight");
 | 
						|
					MoveRNO();
 | 
						|
				}
 | 
						|
				AdjustLocation();
 | 
						|
			}
 | 
						|
			Moving = false;
 | 
						|
			EditItem btm = BottomMostEditItem;
 | 
						|
			if (this != btm)
 | 
						|
				btm.AdjustLocation();
 | 
						|
			//if (_WatchThis > 0 && MyID > _StartingID)
 | 
						|
			//{
 | 
						|
			//  Console.WriteLine("{0}Finish Move  {1},{2}",WatchThisIndent, MyID, this);
 | 
						|
			//}
 | 
						|
			_WatchThis = watchThis;
 | 
						|
		}
 | 
						|
		/// <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();
 | 
						|
 | 
						|
		}
 | 
						|
		#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(EditItem myParentEditItem, StepSectionLayoutData myStepSectionLayoutData, int width)
 | 
						|
		{
 | 
						|
			// Should center on parent unless it is a centered table in the AER column
 | 
						|
			int center = myParentEditItem.ContentLeft + myParentEditItem.ContentWidth / 2;
 | 
						|
			int rightLimit = myParentEditItem.Right;
 | 
						|
			// Then should center on the wid Limit
 | 
						|
			if (MyItemInfo.FormatStepData.Type.Contains("AER") == false && MyItemInfo.RNOLevel == 0)
 | 
						|
			{
 | 
						|
				int colR = MyStepPanel.ToDisplay(MyStepSectionLayoutData.ColRTable, MyItemInfo.ColumnMode);
 | 
						|
				
 | 
						|
				rightLimit += colR * MyItemInfo.ColumnMode;
 | 
						|
				center += (colR * MyItemInfo.ColumnMode) / 2;
 | 
						|
				center -= (myParentEditItem.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;
 | 
						|
			int colT = MyStepPanel.ToDisplay((int)myStepSectionLayoutData.ColT);
 | 
						|
			if (x < colT) x = colT;
 | 
						|
			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());
 | 
						|
		}
 | 
						|
		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.
 | 
						|
			int scrollValue = MyStepPanel.VerticalScroll.Value + (Top - (MyStepPanel.Height / 2)); // calculate scroll center for the item
 | 
						|
			//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(_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(_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(_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(_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()
 | 
						|
		{
 | 
						|
			//Console.WriteLine("'AdjustLocation',{0},{1},'{2}'", MyID, MyItemInfo.DBSequence, Volian.Base.Library.vlnStackTrace.CalledFrom4);
 | 
						|
			if (RNORight) MoveRNO(); // This is needed when an AER is Deleted that has an RNO.
 | 
						|
			if (RNOLevel > 0 && AEREditItem != null)
 | 
						|
				AEREditItem.AdjustLocation();
 | 
						|
			EditItem nextEditItem = NextDownEditItem;
 | 
						|
			//if (MyID == 2138)
 | 
						|
			//	Console.WriteLine("2138");
 | 
						|
			//if (_WatchThis > 0 && MyID > _StartingID)
 | 
						|
			//if((nextEditItem == null ? 0 : nextEditItem.MyID) == MyID)
 | 
						|
			//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 (_WatchThis && MyID == 2119)
 | 
						|
			//	Console.WriteLine("I'm here");
 | 
						|
			//if (MyID > 2120)
 | 
						|
			//	Console.WriteLine("{0}\t{1}", MyID, nextEditItem == null ? 0 : nextEditItem.MyID);
 | 
						|
			if (nextEditItem != null)
 | 
						|
			{
 | 
						|
				//int bottom = BottomMostEditItem.Bottom;
 | 
						|
				if (nextEditItem != null)
 | 
						|
				{
 | 
						|
					//if (MyID == 2123)
 | 
						|
					//	_LookForID = 2123;
 | 
						|
					int bottom = nextEditItem.FindTop(Bottom);
 | 
						|
					if (nextEditItem.Top != bottom)
 | 
						|
					//	if (nextEditItem != null && !nextEditItem.Moving && nextEditItem.Top != bottom)
 | 
						|
					{
 | 
						|
						MyStepPanel.ItemMoving++;
 | 
						|
						nextEditItem.LastMethodsPush(string.Format("AdjustLocation {0}", MyID));
 | 
						|
						nextEditItem._NextDownEditItemPath = _NextDownEditItemPath;
 | 
						|
						nextEditItem.Top = bottom;
 | 
						|
						// We found that the 64 Bit version of windows did not always set the Top correctly.
 | 
						|
						// We also found that if we could simply watch for the next time that it was set, we
 | 
						|
						// could set the Flag "TryAgainLater" the change would propogate the changes through its
 | 
						|
						// children and siblings.
 | 
						|
						if (nextEditItem.Top != bottom)
 | 
						|
						{
 | 
						|
							nextEditItem.TryAgainLater = true;
 | 
						|
							_MyLog.InfoFormat("Setting nextEditItem.Top = bottom for ID {0}, ({1}) did not work, TryAgainLater", nextEditItem.MyID, nextEditItem.MyItemInfo.SearchPath);
 | 
						|
						}
 | 
						|
						nextEditItem.LastMethodsPop();
 | 
						|
						MyStepPanel.ItemMoving--;
 | 
						|
					}
 | 
						|
				}
 | 
						|
				else
 | 
						|
				{
 | 
						|
					Console.WriteLine("{0}**  No Adjustment next = {1}, moving = {2}", WatchThisIndent, nextEditItem, nextEditItem == null ? false : nextEditItem.Moving);
 | 
						|
				}
 | 
						|
			}
 | 
						|
		}
 | 
						|
		/// <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
 | 
						|
			{
 | 
						|
				//vlnStackTrace.ShowStack(">AutoExpand ID {0} - Can {1} Expanded {2}", _MyItem.ItemID, CanExpand, Expanded);
 | 
						|
				Expand(_ContentType >= 20000);
 | 
						|
				//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++;
 | 
						|
					TopMostEditItem.Top = Top;
 | 
						|
					MyStepPanel.ItemMoving--;
 | 
						|
				}
 | 
						|
				else
 | 
						|
					TopMostEditItem.AdjustLocation();
 | 
						|
				AdjustChildren();
 | 
						|
				//if(_Before != null ) 
 | 
						|
				//  Top = _Before[_Before.Count - 1].BottomMost.Bottom;
 | 
						|
			}
 | 
						|
			else
 | 
						|
			{
 | 
						|
				MyExpandingStatus = ExpandingStatus.Expanding;
 | 
						|
				_ChildrenLoaded = true;
 | 
						|
				//_Panel.SuspendLayout();
 | 
						|
				AddChildBefore(MyItemInfo.Cautions, expand);
 | 
						|
				AddChildBefore(MyItemInfo.Notes, expand);
 | 
						|
				AddChildAfter(MyItemInfo.Procedures, expand);
 | 
						|
				if (MyItemInfo.ItemID == 317) Console.WriteLine("EditItem: id = {0}, ColumnMode = {1}", MyItemInfo.MyItemInfoUnique, MyItemInfo.ColumnMode);
 | 
						|
				if (MyItemInfo.RNOs != null && MyItemInfo.RNOLevel < MyItemInfo.ColumnMode)
 | 
						|
					AddChildRNO(MyItemInfo.RNOs, 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)
 | 
						|
					AddChildRNO(MyItemInfo.RNOs, expand);
 | 
						|
				AddChildAfter(MyItemInfo.Sections, expand);
 | 
						|
				MatchExpanded();
 | 
						|
			}
 | 
						|
			MyExpandingStatus = ExpandingStatus.Done;
 | 
						|
			BottomMostEditItem.AdjustLocation();
 | 
						|
			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;
 | 
						|
				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;
 | 
						|
		}
 | 
						|
		private string _NextDownEditItemPath = "None";
 | 
						|
		/// <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.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)));
 | 
						|
								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}'", MyID, MyPath); // + "-" + 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();
 | 
						|
		#endregion
 | 
						|
		protected string _TabFormat;
 | 
						|
		private static int _WidthAdjust = 5;
 | 
						|
		protected bool _IgnoreResize = false;
 | 
						|
		/// <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);
 | 
						|
									ItemWidth = MyStepPanel.ToDisplay(MyStepSectionLayoutData.ColT) + MyStepPanel.ToDisplay(MyStepSectionLayoutData.WidT);
 | 
						|
									break;
 | 
						|
								case 1: // Section
 | 
						|
									if (this == TopMostEditItem)
 | 
						|
										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
 | 
						|
									{
 | 
						|
										ItemLocation = new Point(_MyParentEditItem.ContentLeft, _MyParentEditItem.Bottom);
 | 
						|
										ItemWidth = _MyParentEditItem.ContentWidth;
 | 
						|
									}
 | 
						|
									break;
 | 
						|
							}
 | 
						|
							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;
 | 
						|
							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));
 | 
						|
									_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;
 | 
						|
							Width = MyStepPanel.ToDisplay(MyStepSectionLayoutData.WidT);
 | 
						|
							_IgnoreResize = false;
 | 
						|
							MyStepPanel.ItemMoving++;
 | 
						|
							//Location = new Point(_MyParentRTBItem.Left + 20, FindTop(_MyParentRTBItem.Top));
 | 
						|
							int myTop = MyNextEditItem == null ? _MyParentEditItem.Top : MyNextEditItem.Top;
 | 
						|
							Location = new Point(_MyParentEditItem.Left + 20, FindTop(myTop));
 | 
						|
							MyStepPanel.ItemMoving--;
 | 
						|
							//_MyParentRTBItem.Top = Bottom;
 | 
						|
							// Could be a Caution or Note - Need to get WidT
 | 
						|
							break;
 | 
						|
					}
 | 
						|
				}
 | 
						|
				LastMethodsPop();
 | 
						|
			}
 | 
						|
		}
 | 
						|
		/// <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;
 | 
						|
					if (MyStepData != null && (MyStepData.Type.ToLower().Contains("table") || MyStepData.ParentType.ToLower().Contains("table")))
 | 
						|
					{
 | 
						|
						ItemWidth = TableWidth;
 | 
						|
						Location = new Point(_MyPreviousEditItem.Left, FindTop(_MyPreviousEditItem.BottomMostEditItem.Bottom));
 | 
						|
					}
 | 
						|
					else if (value.MyItemInfo.IsTablePart)
 | 
						|
					{
 | 
						|
						ItemLocation = new Point(value.MyParentEditItem.ContentLeft, value.MyParentEditItem.Bottom);
 | 
						|
						ItemWidth = value.MyParentEditItem.ContentWidth;
 | 
						|
					}
 | 
						|
					else
 | 
						|
					{
 | 
						|
						Width = MyPreviousEditItem.Width;
 | 
						|
						if (TopMostEditItem == this)
 | 
						|
							Location = new Point(_MyPreviousEditItem.Left, FindTop(_MyPreviousEditItem.BottomMostEditItem.Bottom));
 | 
						|
						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.Before:
 | 
						|
							//MyStepPanel.ItemMoving++;
 | 
						|
							//UpOneRTBItem.Top = BottomMostRTBItem.Bottom;
 | 
						|
							//MyStepPanel.ItemMoving--;
 | 
						|
							break;
 | 
						|
					}
 | 
						|
					if (_MyPreviousEditItem.MyNextEditItem != this) _MyPreviousEditItem.MyNextEditItem = this;
 | 
						|
				}
 | 
						|
				LastMethodsPop();
 | 
						|
			}
 | 
						|
		}
 | 
						|
		protected void SetupEditItem(ItemInfo itemInfo, StepPanel myStepPanel, EditItem myParentEditItem, ChildRelation myChildRelation, bool expand, EditItem nextEditItem, bool addFirstChld)
 | 
						|
		{
 | 
						|
			//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;
 | 
						|
			SetupHeader(itemInfo);
 | 
						|
			this.Paint += new PaintEventHandler(EditItem_Paint);
 | 
						|
			this.BackColorChanged += new EventHandler(EditItem_BackColorChanged);
 | 
						|
			this.Move += new EventHandler(EditItem_Move);
 | 
						|
			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
 | 
						|
						ContentFont = myStepPanel.StepFont;//lblTab.Font = myStepPanel.StepFont;
 | 
						|
						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);
 | 
						|
			}
 | 
						|
			//// 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.None:
 | 
						|
					break;
 | 
						|
			}
 | 
						|
			if (itemInfo != null)
 | 
						|
			{
 | 
						|
				if (myChildRelation == ChildRelation.None)
 | 
						|
				{
 | 
						|
					if (ContentType == 0 && MyStepSectionLayoutData != null)
 | 
						|
					{
 | 
						|
						LastMethodsPush(string.Format("SetupRTBItem {0}", MyID));
 | 
						|
						Width = MyStepPanel.ToDisplay(MyStepSectionLayoutData.WidT);
 | 
						|
					}
 | 
						|
				}
 | 
						|
			}
 | 
						|
			//// TIMING: DisplayItem.TimeIt("CSLARTB Parent");
 | 
						|
			SetText();
 | 
						|
			//// 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);
 | 
						|
			int top = FindTop(0);
 | 
						|
			if (Top < top)
 | 
						|
			{
 | 
						|
				LastMethodsPush("SetupRTBItem");
 | 
						|
				MyStepPanel.ItemMoving++;
 | 
						|
				Top = top;
 | 
						|
				MyStepPanel.ItemMoving--;
 | 
						|
				LastMethodsPop();
 | 
						|
			}
 | 
						|
			_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();
 | 
						|
				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);
 | 
						|
			//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);
 | 
						|
			//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
 | 
						|
					{
 | 
						|
						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
 | 
						|
				{
 | 
						|
					RTBItem ri = this as RTBItem;
 | 
						|
					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;
 | 
						|
			}
 | 
						|
		}
 | 
						|
	}
 | 
						|
}
 |