Bug fix B2016-014 where a change bar was set when you check the CAS checkbox or the Page Break check box Bug Fix B2016-011 where a change bar a compressed table was too short Bug Fix B2015-184 where generate PDF would bomb when it tried to print a change bar related to a null step element.
2899 lines
106 KiB
C#
2899 lines
106 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();
|
|
this.Enter += EditItem_Enter;
|
|
}
|
|
|
|
// This event was added to better control enabling or disabling of the Insert and Copy Step buttons on the ribbon
|
|
void EditItem_Enter(object sender, EventArgs e)
|
|
{
|
|
bool allow = (MyStepPanel.VwMode == E_ViewMode.Edit);
|
|
StepTabRibbon str = MyStepPanel.MyStepTabPanel.MyStepTabRibbon;
|
|
str.SiblingsButtonsEnabled = allow;
|
|
str.InsertButtonsEnabled = allow && !(MyItemInfo.IsProcedure || MyItemInfo.IsSection);
|
|
}
|
|
|
|
public EditItem(IContainer container)
|
|
{
|
|
container.Add(this);
|
|
InitializeComponent();
|
|
this.Enter += EditItem_Enter;
|
|
}
|
|
#endregion
|
|
#region Properties
|
|
private bool _RTBLastFocus = true;
|
|
public bool RTBLastFocus
|
|
{
|
|
get { return _RTBLastFocus; }
|
|
set { _RTBLastFocus = value; }
|
|
}
|
|
protected static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
|
protected ChildRelation _MyChildRelation;
|
|
public ChildRelation MyChildRelation
|
|
{
|
|
get { return _MyChildRelation; }
|
|
set { _MyChildRelation = value; }
|
|
}
|
|
protected bool _Loading = true;
|
|
protected EditItem _MyParentEditItem = null;
|
|
protected EditItem _MySectionRTBItem;
|
|
protected EditItem _MyPreviousEditItem = null;
|
|
protected EditItem _MyNextEditItem = null;
|
|
private bool _ChildrenLoaded = false;
|
|
public bool HasChildren
|
|
{
|
|
get { return _MyBeforeEditItems != null || _MyRNOEditItems != null || _MyAfterEditItems != null; }
|
|
}
|
|
internal List<EditItem> _MyBeforeEditItems;
|
|
public List<EditItem> MyBeforeEditItems
|
|
{
|
|
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 bool _Colapsing = false;
|
|
/// <summary>
|
|
/// Gets or sets colapsing
|
|
/// </summary>
|
|
public bool Colapsing
|
|
{
|
|
get { return _Colapsing; }
|
|
set { _Colapsing = value; }
|
|
}
|
|
private bool _Moving = false;
|
|
private int _RNOLevel = 0;
|
|
private int _SeqLevel = 0;
|
|
private int _ContentType;
|
|
public int ContentType
|
|
{
|
|
get { return _ContentType; }
|
|
set { _ContentType = value; }
|
|
}
|
|
private bool _Circle = false;
|
|
private bool _CheckOff = false;
|
|
private bool _UserCheckOff = false;
|
|
private bool _ChangeBar = false;
|
|
private StepPanel _MyStepPanel;
|
|
public StepPanel MyStepPanel
|
|
{
|
|
get { return _MyStepPanel; }
|
|
set { _MyStepPanel = value; }
|
|
}
|
|
|
|
private DisplayTags _MyStepPropertiesPanel;
|
|
public DisplayTags MyStepPropertiesPanel // gives us access to the Step Properties panel - used with shortcut keystrokes
|
|
{
|
|
get { return _MyStepPropertiesPanel; }
|
|
set { _MyStepPropertiesPanel = value; }
|
|
}
|
|
|
|
/// <summary>
|
|
/// This returns the section or procedure for the current item.
|
|
/// If the item is a step or section, it returns the section
|
|
/// If it is a procedure, it returns the procedure
|
|
/// </summary>
|
|
public EditItem MySectionRTBItem
|
|
{
|
|
get
|
|
{
|
|
if (_MySectionRTBItem == null)
|
|
{
|
|
if (MyItemInfo.IsSection || MyItemInfo.IsProcedure) _MySectionRTBItem = (RTBItem)this;
|
|
else _MySectionRTBItem = _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);
|
|
// do something like this to draw circle around step numbers - note got NULL reference error on NSP data
|
|
//if (value.FormatStepData != null && value.FormatStepData.TabData.IdentPrint.Contains("C0")) Circle = true;
|
|
}
|
|
}
|
|
private bool _ChangeBarForConfigItemChange = true;
|
|
|
|
public bool ChangeBarForConfigItemChange
|
|
{
|
|
get { return _ChangeBarForConfigItemChange; }
|
|
set { _ChangeBarForConfigItemChange = value; }
|
|
}
|
|
|
|
void value_Changed(object sender)
|
|
{
|
|
ChangeBar = _MyItemInfo.HasChangeBar;
|
|
}
|
|
protected void MyContent_Changed(object sender)
|
|
{
|
|
// Update the text to reflect the content change
|
|
MyItemInfo.RefreshItemAnnotations();
|
|
ChangeBar = MyItemInfo.HasChangeBar;
|
|
CheckOff co = _MyItemInfo.GetCheckOffStep();
|
|
if (co != null && co.UIMark != null)
|
|
{
|
|
UserCheckOff = true;
|
|
UserCheckOffChar = (char)co.UIMark;
|
|
}
|
|
else
|
|
UserCheckOff = false;
|
|
RefreshContent();
|
|
|
|
// see if change in subsections to be displayed, i.e. if the user made a change to editable data
|
|
// on the section properties form, we may have to display steps or remove steps. By design,
|
|
// steps are the first children from a section. Also, this will only occur if the format has
|
|
// metasections AND there are subsections.
|
|
if (MyItemInfo.IsSection && MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.UseMetaSections
|
|
&& MyItemInfo.Sections != null && MyItemInfo.Sections.Count > 0)
|
|
{
|
|
// find out what the editable flag is to determine if change.
|
|
bool showSteps = MyItemInfo.MyConfig is SectionConfig && (MyItemInfo.MyConfig as SectionConfig).SubSection_Edit == "Y";
|
|
if (showSteps && _MyAfterEditItems != null && _MyAfterEditItems.Count > 0 && _MyAfterEditItems[0].MyItemInfo.IsSection)
|
|
{
|
|
// need to add steps in, i.e. they do not exist in step editor yet.
|
|
_MyAfterEditItems[0].AddSiblingBeforeNoDataSave(MyItemInfo.Steps, false);
|
|
}
|
|
else if (!showSteps && _MyAfterEditItems != null && _MyAfterEditItems.Count > 0 && _MyAfterEditItems[0].MyItemInfo.IsStep)
|
|
{
|
|
// Remove steps - only want sections. Put in a list for removal.
|
|
List<EditItem> remEIs = new List<EditItem>();
|
|
foreach (EditItem ei in _MyAfterEditItems)
|
|
{
|
|
if (!ei.MyItemInfo.IsSection) remEIs.Add(ei);
|
|
}
|
|
foreach (EditItem ei1 in remEIs)
|
|
{
|
|
ei1.RemoveItemWithoutDelete();
|
|
}
|
|
remEIs.Clear();
|
|
}
|
|
}
|
|
}
|
|
void value_OrdinalChanged(object sender)
|
|
{
|
|
RefreshOrdinal();
|
|
}
|
|
public EditItem ActiveParent
|
|
{
|
|
get { return _MyParentEditItem != null ? _MyParentEditItem : _MyPreviousEditItem.ActiveParent; }
|
|
}
|
|
/// <summary>
|
|
/// Return the Parent EditItem
|
|
/// </summary>
|
|
private EditItem UpOneEditItem
|
|
{
|
|
get
|
|
{
|
|
EditItem tmp = this;
|
|
while (tmp != null && tmp.MyParentEditItem == null) tmp = tmp.MyPreviousEditItem;
|
|
if (tmp != null) return tmp.MyParentEditItem;
|
|
return null;
|
|
}
|
|
}
|
|
private Stack<string> _LastMethods = new Stack<string>();
|
|
//private string _LastMethod = "";
|
|
internal void LastMethodsPush(string str)
|
|
{
|
|
if(MyStepPanel != null)MyStepPanel._LastAdjust = str;
|
|
_LastMethods.Push(str);
|
|
}
|
|
internal string LastMethodsPop()
|
|
{
|
|
//MyStepPanel._LastAdjust = "";
|
|
return _LastMethods.Pop();
|
|
}
|
|
internal bool LastMethodsEmpty
|
|
{
|
|
get { return _LastMethods.Count == 0; }
|
|
}
|
|
/// <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;
|
|
if(siblingEditItems.Contains(nextEditItem))
|
|
siblingEditItems.Insert(siblingEditItems.IndexOf(nextEditItem), this);
|
|
else
|
|
siblingEditItems.Insert(0, 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();
|
|
}
|
|
}
|
|
private static int xOffset = 0;
|
|
public void RemoveItem()
|
|
{
|
|
// if this item has enhanced edititems, remove them:
|
|
StepConfig sc = MyItemInfo.MyConfig as StepConfig;
|
|
List<EnhancedDocument> thisEnhs = null;
|
|
if (sc != null)
|
|
thisEnhs = sc.MyEnhancedDocuments;
|
|
else
|
|
{
|
|
if (MyItemInfo.IsSection)
|
|
{
|
|
SectionConfig secc = MyItemInfo.MyConfig as SectionConfig;
|
|
if (secc.Section_LnkEnh=="Y")thisEnhs = secc.MyEnhancedDocuments;
|
|
}
|
|
}
|
|
|
|
List<int> enhIds = new List<int>();
|
|
foreach (EnhancedDocument ed in thisEnhs)
|
|
{
|
|
if (ed.Type != 0) enhIds.Add(ed.ItemID);
|
|
}
|
|
BeingRemoved = true;
|
|
MyStepPanel.SelectedEditItem = null; // Unselect the item to be deleted
|
|
//ShowTops("\r\n");
|
|
int TopMostYBefore = TopMostEditItem.Top;
|
|
//_MyTimer.ActiveProcess = "DeleteItem";
|
|
// Add a Panel temporarily so that AutoScroll will not happen during the delete.
|
|
Panel pnl = new Panel();
|
|
pnl.Size = new Size(10, 10);
|
|
MyStepPanel.Controls.Add(pnl);
|
|
pnl.BackColor = Color.Red;
|
|
pnl.Location = new Point(xOffset += 15, MyStepPanel.ClientSize.Height+10);
|
|
EditItem newFocus = DeleteItem();
|
|
if (newFocus == null)
|
|
{
|
|
MyStepPanel.Controls.Remove(pnl);
|
|
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");
|
|
ForceEditItemRefresh(newFocus);
|
|
MyStepPanel.Controls.Remove(pnl);
|
|
foreach (int enhId in enhIds)
|
|
{
|
|
ItemInfo ii = ItemInfo.Get(enhId);
|
|
bool success = this._MyStepPanel.MyStepTabPanel.MyDisplayTabControl.DeleteRTBItem(ii);
|
|
if (!success) // item was not displayed in editor, just delete from database (add tree if necessarY)
|
|
Item.DeleteItemAndChildren(ii);
|
|
}
|
|
}
|
|
|
|
private static void ForceEditItemRefresh(EditItem newFocus)
|
|
{
|
|
// bug fix
|
|
// need to force a refresh from the level above the step that was removed.
|
|
// this fixes a problem where the following step/substep wasn't shown on the screen (but was there)
|
|
// and fixes a problem where the sequence numbers were off by one
|
|
// and fixes a problem where an edit window would end up on top of the ones above it
|
|
EditItem ei = newFocus;
|
|
while (ei.MyPreviousEditItem != null) ei = ei.MyPreviousEditItem;
|
|
if (ei.MyParentEditItem != null && ei.MyParentEditItem.MyItemInfo.IsStep)
|
|
ei.MyParentEditItem.Expand(true);
|
|
}
|
|
public EditItem DeleteItem()
|
|
{
|
|
//Volian.Base.Library.VlnTimer _MyTimer = new VlnTimer();
|
|
//_MyTimer.ActiveProcess = "_LookupEditItems.Remove";
|
|
MyStepPanel._LookupEditItems.Remove(MyID);
|
|
EditItem newFocus = null;
|
|
int? TopMostParentY = (MyParentEditItem == null ? null : (int?)(MyParentEditItem.TopMostEditItem.Top));
|
|
int? ParentY = (MyParentEditItem == null ? null : (int?)(MyParentEditItem.Top));
|
|
try
|
|
{
|
|
//_MyTimer.ActiveProcess = "DeleteItemAndChildren";
|
|
Item.DeleteItemAndChildren(MyItemInfo);
|
|
}
|
|
catch (System.Data.SqlClient.SqlException ex)
|
|
{
|
|
HandleSqlExceptionOnDelete(ex);
|
|
return null;
|
|
}
|
|
// 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)
|
|
private void HandleSqlExceptionOnDelete(Exception 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 Procedure"))
|
|
{
|
|
using (TransitionInfoList exTrans = TransitionInfoList.GetExternalTransitionsToChildren(MyID))
|
|
{
|
|
DialogResult ans = MessageBox.Show("Transitions exist to this procedure." +
|
|
"\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 Procedure", 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);
|
|
AddGridIfNeeded(newItemInfo);
|
|
DoAddSiblingAfter(newItemInfo, updateStatus);
|
|
if (MyStepPanel.SelectedEditItem is RTBItem)
|
|
{
|
|
RTBItem rtbi = MyStepPanel.SelectedEditItem as RTBItem;
|
|
// see if this step has associated enhanced step(s). If it does, flag it so
|
|
// that the enhanced steps get inserted also.
|
|
StepConfig sc = new StepConfig(MyItemInfo.MyContent.Config);
|
|
if (sc.MyEnhancedDocuments.Count > 0)
|
|
{
|
|
rtbi.EnhAddFromItemInfo = MyItemInfo;
|
|
rtbi.EnhAddType = EnhancedAddTypes.After;
|
|
}
|
|
}
|
|
}
|
|
// This logic allows us to do an Insert Before and Insert After while on a Table
|
|
// if allowed by the format
|
|
private void AddGridIfNeeded(ItemInfo newItemInfo)
|
|
{
|
|
if (this is GridItem)
|
|
{
|
|
GridItem gi = this as GridItem;
|
|
VlnFlexGrid fg = new VlnFlexGrid(gi.MyFlexGrid.Rows.Count, gi.MyFlexGrid.Cols.Count);
|
|
// bug fix B2015136
|
|
// need to copy the font used in the table we are doing the Insert Previous/Next from.
|
|
VE_Font vefont = MyItemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList.Table.Font;
|
|
Font GridFont = new Font(vefont.Family, (float)vefont.Size);
|
|
fg.Font = GridFont;
|
|
using (Item itm = newItemInfo.Get())
|
|
{
|
|
itm.MyContent.MyGrid.Data = fg.GetXMLData();
|
|
itm.Save();
|
|
}
|
|
}
|
|
}
|
|
public void AddSiblingAfter(int? type, bool updateStatus)
|
|
{
|
|
SaveContents();
|
|
ItemInfo newItemInfo = MyItemInfo.InsertSiblingAfter("", "", type);
|
|
AddGridIfNeeded(newItemInfo);
|
|
DoAddSiblingAfter(newItemInfo, updateStatus);
|
|
if (MyStepPanel.SelectedEditItem is RTBItem)
|
|
{
|
|
RTBItem rtbi = MyStepPanel.SelectedEditItem as RTBItem;
|
|
// see if this step has associated enhanced step(s). If it does, flag it so
|
|
// that the enhanced steps get inserted also.
|
|
StepConfig sc = new StepConfig(MyItemInfo.MyContent.Config);
|
|
if (sc.MyEnhancedDocuments.Count > 0)
|
|
{
|
|
rtbi.EnhAddFromItemInfo = MyItemInfo;
|
|
rtbi.EnhAddType = EnhancedAddTypes.After;
|
|
}
|
|
}
|
|
}
|
|
private void DoAddSiblingAfter(ItemInfo newItemInfo, bool updateStatus)
|
|
{
|
|
EditItem newEditItem = null;
|
|
switch (_MyChildRelation)
|
|
{
|
|
case ChildRelation.After:
|
|
newEditItem = ActiveParent.AddChildAfter(newItemInfo, MyNextEditItem);
|
|
break;
|
|
case ChildRelation.Before:
|
|
newEditItem = ActiveParent.AddChildBefore(newItemInfo, MyNextEditItem);
|
|
break;
|
|
case ChildRelation.RNO:
|
|
newEditItem = ActiveParent.AddChildRNO(newItemInfo, MyNextEditItem);
|
|
break;
|
|
default: // Need debug
|
|
break;
|
|
}
|
|
//EditItem newEditItem = ActiveParent.AddChildAfter(newItemInfo, );
|
|
if (updateStatus)
|
|
MyStepPanel.SelectedEditItem = newEditItem;//Update Screen
|
|
}
|
|
protected static int _WatchThis = 1;
|
|
public void AddSiblingBefore()
|
|
{
|
|
AddSiblingBefore("", true);
|
|
}
|
|
public void AddSiblingBefore(int? type, bool updateStatus)
|
|
{
|
|
SaveContents();
|
|
ItemInfo newItemInfo = MyItemInfo.InsertSiblingBefore("", "",type);
|
|
AddGridIfNeeded(newItemInfo);
|
|
DoAddSiblingBefore(newItemInfo, updateStatus);
|
|
}
|
|
public void AddSiblingBefore(string text, bool updateSelection)
|
|
{
|
|
// Save RTB text before creating a new item because the process of creating
|
|
// a new item will save a change to iteminfo excluding text changes. This
|
|
// shouldn't be necessary for adding sibling after because the current step
|
|
// doesn't get saved during the insert after because of the MyPrevious field
|
|
// is only set on an insert before, which is what saves the item without
|
|
// any updates from the richtextbox text.
|
|
SaveContents();
|
|
ItemInfo newItemInfo = MyItemInfo.InsertSiblingBefore(text);
|
|
AddGridIfNeeded(newItemInfo);
|
|
DoAddSiblingBefore(newItemInfo, updateSelection);
|
|
if (MyStepPanel.SelectedEditItem is RTBItem)
|
|
{
|
|
RTBItem rtbi = MyStepPanel.SelectedEditItem as RTBItem;
|
|
// see if this step has associated enhanced step(s). If it does, flag it so
|
|
// that the enhanced steps get inserted also.
|
|
StepConfig sc = new StepConfig(MyItemInfo.MyContent.Config);
|
|
if (sc.MyEnhancedDocuments.Count > 0)
|
|
{
|
|
rtbi.EnhAddFromItemInfo = MyItemInfo;
|
|
rtbi.EnhAddType = EnhancedAddTypes.Before;
|
|
}
|
|
}
|
|
}
|
|
public void DoAddSiblingBefore(ItemInfo newItemInfo, bool updateSelection)
|
|
{
|
|
EditItem newEditItem = null;
|
|
switch (_MyChildRelation)
|
|
{
|
|
case ChildRelation.After:
|
|
newEditItem = ActiveParent.AddChildAfter(newItemInfo, this);
|
|
break;
|
|
case ChildRelation.Before:
|
|
newEditItem = ActiveParent.AddChildBefore(newItemInfo, this);
|
|
break;
|
|
case ChildRelation.RNO:
|
|
newEditItem = ActiveParent.AddChildRNO(newItemInfo, this);
|
|
break;
|
|
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.ActiveFormat.MyStepSectionLayoutData.Dev_Format) || _MyItemInfo.IsSection)
|
|
CanExpand = true;
|
|
this.Expanded = true;
|
|
_WatchThis = 1;
|
|
ItemInfo newItemInfo = MyItemInfo.InsertChild(fromType, type, text);
|
|
if (vfGrid != null)
|
|
{
|
|
string xml = vfGrid.GetXMLData();
|
|
using (Item itm = newItemInfo.Get())
|
|
{
|
|
itm.MyContent.MyGrid.Data = xml;
|
|
itm.Save();
|
|
// newItemInfo.MyContent.MyGrid.ResetContent(itm.MyContent.MyGrid); // Do I need this?
|
|
}
|
|
}
|
|
// TODO: We need to determine where this will go in the stack of children
|
|
EditItem nextItem = GetNextItem(fromType, newItemInfo);
|
|
// TODO: May need similar logic if a Table is being added to a step that has substeps
|
|
// else if (fromType == E_FromType.Table && ((ItemInfo)newItemInfo.ActiveParent).Steps != null
|
|
//&& ((ItemInfo)newItemInfo.ActiveParent).Steps.Count > 0)
|
|
// nextItem = MyStepPanel.FindItem(((ItemInfo)newItemInfo.ActiveParent).Steps[0]);
|
|
EditItem newEditItem;
|
|
switch (fromType)
|
|
{
|
|
case E_FromType.Caution:
|
|
newEditItem = this.AddChildBefore(newItemInfo, nextItem);
|
|
break;
|
|
case E_FromType.Note:
|
|
newEditItem = this.AddChildBefore(newItemInfo, nextItem);
|
|
break;
|
|
case E_FromType.Procedure:
|
|
newEditItem = this.AddChildAfter(newItemInfo, nextItem);
|
|
break;
|
|
case E_FromType.RNO:
|
|
newEditItem = this.AddChildRNO(newItemInfo, nextItem);
|
|
break;
|
|
case E_FromType.Section:
|
|
newEditItem = this.AddChildAfter(newItemInfo, nextItem);
|
|
break;
|
|
case E_FromType.Step:
|
|
newEditItem = this.AddChildAfter(newItemInfo, nextItem);
|
|
break;
|
|
case E_FromType.Table:
|
|
newEditItem = this.AddChildAfter(newItemInfo, nextItem);
|
|
break;
|
|
default:
|
|
newEditItem = this.AddChildAfter(newItemInfo, nextItem);
|
|
break;
|
|
}
|
|
MyStepPanel.SelectedEditItem = newEditItem;//Update Screen
|
|
if (MyStepPanel.SelectedEditItem is RTBItem)
|
|
{
|
|
RTBItem rtbi = MyStepPanel.SelectedEditItem as RTBItem;
|
|
// see if this step has associated enhanced step(s). If it does, flag it so
|
|
// that the enhanced steps get inserted also.
|
|
EnhancedDocuments cfgeds = null;
|
|
if (MyItemInfo.IsStepSection)
|
|
{
|
|
SectionConfig scfg = MyItemInfo.MyConfig as SectionConfig;
|
|
if (scfg.Section_LnkEnh != "Y") return;
|
|
cfgeds = scfg.MyEnhancedDocuments;
|
|
}
|
|
else
|
|
{
|
|
StepConfig sc = new StepConfig(MyItemInfo.MyContent.Config);
|
|
cfgeds = sc.MyEnhancedDocuments;
|
|
}
|
|
if (cfgeds != null && cfgeds.Count > 0)
|
|
{
|
|
rtbi.EnhAddFromItemInfo = MyItemInfo;
|
|
rtbi.EnhAddType = EnhancedAddTypes.Child;
|
|
}
|
|
}
|
|
}
|
|
public EditItem GetNextItem(E_FromType fromType, ItemInfo newItemInfo)
|
|
{
|
|
EditItem nextItem = null;
|
|
if (newItemInfo.NextItem != null)
|
|
nextItem = MyStepPanel.FindItem(newItemInfo.NextItem);
|
|
else if (fromType == E_FromType.Table && MyAfterEditItems != null)
|
|
nextItem = MyAfterEditItems[0];
|
|
// Cautions come before notes, so if this is a Caution and there are Notes, put this first
|
|
else if (fromType == E_FromType.Caution && ((ItemInfo)newItemInfo.ActiveParent).Notes != null
|
|
&& ((ItemInfo)newItemInfo.ActiveParent).Notes.Count > 0)
|
|
nextItem = MyStepPanel.FindItem(((ItemInfo)newItemInfo.ActiveParent).Notes[0]);
|
|
return nextItem;
|
|
}
|
|
/// <summary>
|
|
/// Add a list of children after
|
|
/// </summary>
|
|
/// <param name="myItemInfoList"></param>
|
|
/// <param name="expand"></param>
|
|
public EditItem AddChildAfter(ItemInfoList myItemInfoList, bool expand, bool addFirstChld)
|
|
{
|
|
EditItem child = null;
|
|
int indx = 0;
|
|
if (myItemInfoList != null)
|
|
foreach (ItemInfo item in myItemInfoList)
|
|
{
|
|
if (addFirstChld)
|
|
{
|
|
// the first time add it as first child, the rest should be done in between.
|
|
child = AddChildAfter(item, expand, addFirstChld);
|
|
addFirstChld = false;
|
|
}
|
|
else
|
|
child = AddChildAfter(item, this._MyAfterEditItems[indx]);
|
|
indx++;
|
|
}
|
|
return child;
|
|
}
|
|
public EditItem AddChildAfter(ItemInfoList myItemInfoList, bool expand)
|
|
{
|
|
EditItem child = null;
|
|
if (myItemInfoList != null)
|
|
foreach (ItemInfo item in myItemInfoList)
|
|
child = AddChildAfter(item, expand, false);
|
|
return child;
|
|
}
|
|
public EditItem AddChildAfter(ItemInfoList myItemInfoList, EditItem nextEditItem)
|
|
{
|
|
EditItem child = null;
|
|
if (myItemInfoList != null)
|
|
foreach (ItemInfo item in myItemInfoList)
|
|
child = AddChildAfter(item, nextEditItem);
|
|
return child;
|
|
}
|
|
#endregion
|
|
#region CopyPaste
|
|
public void PasteSiblingBefore(int copyStartID)
|
|
{
|
|
ItemInfo newItemInfo = MyItemInfo.PasteSiblingBefore(copyStartID, GetChangeId(MyItemInfo));
|
|
|
|
if (newItemInfo.ItemID == MyItemInfo.ItemID) return;
|
|
|
|
EditItem newEditItem = null;
|
|
switch (_MyChildRelation)
|
|
{
|
|
case ChildRelation.After:
|
|
newEditItem = ActiveParent.AddChildAfter(newItemInfo, this);
|
|
break;
|
|
case ChildRelation.Before:
|
|
newEditItem = ActiveParent.AddChildBefore(newItemInfo, this);
|
|
break;
|
|
case ChildRelation.RNO:
|
|
newEditItem = ActiveParent.AddChildRNO(newItemInfo, this);
|
|
break;
|
|
default: // Need debug
|
|
break;
|
|
}
|
|
if (newEditItem != null) MyStepPanel.SelectedEditItem = newEditItem;//Update Screen
|
|
MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OnItemPaste(this, new vlnTreeItemInfoPasteEventArgs(newItemInfo, copyStartID, ItemInfo.EAddpingPart.Before, newItemInfo.MyContent.Type));
|
|
|
|
// MyItemInfo is the 'paste from' item, if it has enhanced need to copy and paste the steps in enhanced.
|
|
newItemInfo.EnhancedPasteItem(copyStartID, MyItemInfo, ItemInfo.EAddpingPart.Before, GetChangeId(MyItemInfo));
|
|
}
|
|
|
|
private string GetChangeId(ItemInfo iiDest)
|
|
{
|
|
// get the change id for the destination's procedure's change id.
|
|
string chgid = null;
|
|
if (iiDest.ActiveFormat.PlantFormat.FormatData.ProcData.ChangeBarData.ChangeIds)
|
|
chgid = MyStepPanel.MyStepTabPanel.MyDisplayTabControl.ItemsChangeIds[iiDest.MyProcedure.ItemID];
|
|
return chgid;
|
|
}
|
|
public void PasteSiblingAfter(int copyStartID)
|
|
{
|
|
ItemInfo newItemInfo = MyItemInfo.PasteSiblingAfter(copyStartID, GetChangeId(MyItemInfo));
|
|
if (newItemInfo.ItemID == MyItemInfo.ItemID) return;
|
|
EditItem newEditItem = null;
|
|
switch (_MyChildRelation)
|
|
{
|
|
case ChildRelation.After:
|
|
newEditItem = ActiveParent.AddChildAfter(newItemInfo, MyNextEditItem);
|
|
break;
|
|
case ChildRelation.Before:
|
|
newEditItem = ActiveParent.AddChildBefore(newItemInfo, MyNextEditItem);
|
|
break;
|
|
case ChildRelation.RNO:
|
|
newEditItem = ActiveParent.AddChildRNO(newItemInfo, MyNextEditItem);
|
|
break;
|
|
default: // Need debug
|
|
break;
|
|
}
|
|
MyStepPanel.SelectedEditItem = newEditItem;//Update Screen
|
|
MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OnItemPaste(this, new vlnTreeItemInfoPasteEventArgs(newItemInfo, copyStartID, ItemInfo.EAddpingPart.After, newItemInfo.MyContent.Type));
|
|
|
|
// MyItemInfo is the 'paste from' item, if it has enhanced need to copy and paste the steps in enhanced.
|
|
newItemInfo.EnhancedPasteItem(copyStartID, MyItemInfo, ItemInfo.EAddpingPart.After, GetChangeId(MyItemInfo));
|
|
}
|
|
public void PasteChild(int copyStartID)
|
|
{
|
|
ItemInfo newItemInfo = MyItemInfo.PasteChild(copyStartID, GetChangeId(MyItemInfo));
|
|
|
|
E_FromType fromType = E_FromType.Step;
|
|
if (MyItemInfo.MyContent.Type < 10000)
|
|
fromType = E_FromType.Procedure;
|
|
else if (MyItemInfo.MyContent.Type < 20000)
|
|
fromType = E_FromType.Section;
|
|
else if (MyItemInfo.MyContent.Type > 19999)
|
|
{
|
|
int tmptype = (int)MyItemInfo.MyContent.Type - 20000;
|
|
if (MyItemInfo.IsCaution) fromType = E_FromType.Caution;
|
|
else if (MyItemInfo.IsNote) fromType = E_FromType.Note;
|
|
else if (MyItemInfo.IsTable) fromType = E_FromType.Table;
|
|
else if (MyItemInfo.IsRNOPart) fromType = E_FromType.RNO;
|
|
}
|
|
EditItem nextItem = GetNextItem(fromType, newItemInfo);
|
|
EditItem newEditItem;
|
|
|
|
switch (fromType)
|
|
{
|
|
case E_FromType.Caution:
|
|
newEditItem = this.AddChildBefore(newItemInfo, nextItem);
|
|
break;
|
|
case E_FromType.Note:
|
|
newEditItem = this.AddChildBefore(newItemInfo, nextItem);
|
|
break;
|
|
case E_FromType.Procedure:
|
|
newEditItem = this.AddChildAfter(newItemInfo, nextItem);
|
|
break;
|
|
case E_FromType.RNO:
|
|
newEditItem = this.AddChildRNO(newItemInfo, nextItem);
|
|
break;
|
|
case E_FromType.Section:
|
|
newEditItem = this.AddChildAfter(newItemInfo, nextItem);
|
|
break;
|
|
case E_FromType.Step:
|
|
newEditItem = this.AddChildAfter(newItemInfo, nextItem);
|
|
break;
|
|
case E_FromType.Table:
|
|
newEditItem = this.AddChildAfter(newItemInfo, nextItem);
|
|
break;
|
|
default:
|
|
newEditItem = this.AddChildAfter(newItemInfo, nextItem);
|
|
break;
|
|
}
|
|
MyStepPanel.SelectedEditItem = newEditItem;//Update Screen
|
|
|
|
// MyItemInfo is the 'paste from' item, if it has enhanced need to copy and paste the steps in enhanced.
|
|
newItemInfo.EnhancedPasteItem(copyStartID, MyItemInfo, ItemInfo.EAddpingPart.Child, GetChangeId(MyItemInfo));
|
|
}
|
|
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;
|
|
|
|
StepConfig savOrigPasteConfig = MyItemInfo.MyConfig as StepConfig;
|
|
int TopMostYBefore = TopMostEditItem.Top;
|
|
int? TopMostParentY = (MyParentEditItem == null ? null : (int?)(MyParentEditItem.TopMostEditItem.Top));
|
|
int? ParentY = (MyParentEditItem == null ? null : (int?)(MyParentEditItem.Top));
|
|
ItemInfo newItemInfo = null;
|
|
try
|
|
{
|
|
newItemInfo = Item.PasteReplace(MyItemInfo, copyStartID, GetChangeId(MyItemInfo));
|
|
}
|
|
//catch (System.Data.SqlClient.SqlException ex)
|
|
catch (Exception ex)
|
|
{
|
|
if (HandleSqlExceptionOnCopy(ex)) return this;
|
|
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));
|
|
// MyItemInfo is the 'paste from' item, if it has enhanced need to copy and paste the steps in enhanced.
|
|
newItemInfo.EnhancedPasteItem(copyStartID, MyItemInfo, ItemInfo.EAddpingPart.Replace, GetChangeId(MyItemInfo));
|
|
return newEditItem;
|
|
}
|
|
private bool HandleSqlExceptionOnCopy(Exception ex)
|
|
{
|
|
if (ex.Message.Contains("This step has been deleted"))
|
|
{
|
|
MessageBox.Show("The step being pasted has been deleted", "Cannot Paste Step", MessageBoxButtons.OK, MessageBoxIcon.Hand);
|
|
return true;
|
|
}
|
|
if(ex.Message.Contains("This current step has been deleted in another session"))
|
|
{
|
|
MessageBox.Show("The highlighted step has been deleted by another user.", "Cannot Paste Step", MessageBoxButtons.OK, MessageBoxIcon.Hand);
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
public void IdentifyChildren(bool highlight)
|
|
{
|
|
// Highlight children of EditItem:
|
|
if (MyAfterEditItems != null)
|
|
{
|
|
foreach (EditItem sia in MyAfterEditItems)
|
|
{
|
|
sia.IdentifyMe(highlight);
|
|
sia.IdentifyChildren(highlight);
|
|
}
|
|
}
|
|
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;
|
|
if(rnoTop.Top != Top)
|
|
rnoTop.Top = Top;
|
|
rnoTop.LastMethodsPop();
|
|
MyStepPanel.ItemMoving--;
|
|
}
|
|
else
|
|
{
|
|
MyStepPanel.ItemMoving++;
|
|
rnoTop.LastMethodsPush(string.Format("EditItem_Move RNO Below {0} {1} {2}", rnoTop.MyID, BottomMostEditItemNoRNOs.MyID, BottomMostEditItemNoRNOs.Bottom));
|
|
if(rnoTop.Top != BottomMostEditItemNoRNOs.Bottom)
|
|
rnoTop.Top = BottomMostEditItemNoRNOs.Bottom;
|
|
rnoTop.LastMethodsPop();
|
|
MyStepPanel.ItemMoving--;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
private bool _TryAgainLater = false;
|
|
public bool TryAgainLater
|
|
{
|
|
get { return _TryAgainLater; }
|
|
set { _TryAgainLater = value; }
|
|
}
|
|
int _LastTop = 0;
|
|
/// <summary>
|
|
/// Handles movement of the EditItems
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void EditItem_Move(object sender, EventArgs e)
|
|
{
|
|
int newTop = Top - MyStepPanel.TopMostEditItem.Top;
|
|
if (_LastTop == newTop) return;
|
|
_LastTop = newTop;
|
|
int watchThis = _WatchThis;
|
|
//if (MyID == 136)
|
|
//{
|
|
// vlnStackTrace.ShowStack("{0} Move TO {1}", MyID, Top);
|
|
// //vlnStackTrace.ShowStack("{0} Move TO {1} - {2}, BottomMost {3}", MyID, Top, MyPath, BottomMostRTBItem.MyPath);
|
|
// //Console.WriteLine("{0} Move TO {1} - {2}, BottomMost {3}", MyID, Top, MyPath, BottomMostRTBItem.MyPath);
|
|
//}
|
|
//if (MyID > _StartingID)
|
|
// Console.WriteLine("{0}--------------- {1} Top = {2} Bottom {3}", WatchThisIndent, MyID, Top, Bottom);
|
|
if (MyStepPanel.ItemMoving == 0 && !TryAgainLater)
|
|
{
|
|
//vlnStackTrace.ScrollInStack();
|
|
return; // If 0 - Indicates scrolling which requires no action.
|
|
}
|
|
TryAgainLater = false;
|
|
//ShowMe("Move");
|
|
if (MyItemInfo == null)
|
|
return;
|
|
//if (_WatchThis > 0 && MyID > _StartingID)
|
|
//{
|
|
|
|
// Console.WriteLine("{0}Start Move {1},{2}", WatchThisIndent, MyID, this);
|
|
// if (MyID == _LookForID)
|
|
// Console.WriteLine("{0}---------------", WatchThisIndent,MyID, this);
|
|
// _WatchThis++;
|
|
//}
|
|
if (MyExpandingStatus == ExpandingStatus.Expanding)
|
|
{
|
|
_WatchThis = watchThis;
|
|
return;
|
|
}
|
|
Moving = true;
|
|
EditItem tmp = (EditItem)sender;
|
|
if (tmp.MyPreviousEditItem == null && tmp.MyParentEditItem == null)
|
|
{
|
|
_WatchThis = watchThis;
|
|
return;
|
|
}
|
|
if (RNOBelow) // Adjust substeps first
|
|
{
|
|
//Console.WriteLine("RNOBelow");
|
|
AdjustLocation();
|
|
MoveRNO();
|
|
}
|
|
else // Adjust RNO First
|
|
{
|
|
if (RNORight)
|
|
{
|
|
//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());
|
|
MyStepPropertiesPanel.UpdatePageBreakCheckBox(); // update the checkbox on the Step Properties panel
|
|
if (!MyStepRTB.ContainsFocus)
|
|
MyStepRTB.Focus();
|
|
}
|
|
protected void ToggleChangeBar()
|
|
{
|
|
MyStepPropertiesPanel.ToggleChangeBar(); // update the checkbox on the Step Properties panel
|
|
if (!MyStepRTB.ContainsFocus)
|
|
MyStepRTB.Focus();
|
|
}
|
|
protected void ToggleContinuousActionSummary()
|
|
{
|
|
MyStepPropertiesPanel.ToggleContActSummary(); // update the checkbox on the Step Properties panel
|
|
if (!MyStepRTB.ContainsFocus)
|
|
MyStepRTB.Focus();
|
|
}
|
|
protected void TogglePlaceKeeper()
|
|
{
|
|
MyStepPropertiesPanel.TogglePlaceKeeper(); // update the checkbox on the Step Properties panel
|
|
if (!MyStepRTB.ContainsFocus)
|
|
MyStepRTB.Focus();
|
|
}
|
|
protected void TogglePlaceKeeperContAct()
|
|
{
|
|
MyStepPropertiesPanel.TogglePlaceKeeperContAct(); // update the checkbox on the Step Properties panel
|
|
if (!MyStepRTB.ContainsFocus)
|
|
MyStepRTB.Focus();
|
|
}
|
|
protected void ToggleSuperScript()
|
|
{
|
|
MyStepPanel.MyStepTabPanel.MyStepTabRibbon.btnSuperscript_Click(this, new EventArgs()); // click the Superscrpt button on the ribbon
|
|
if (!MyStepRTB.ContainsFocus)
|
|
MyStepRTB.Focus();
|
|
}
|
|
protected void ToggleSubScript()
|
|
{
|
|
MyStepPanel.MyStepTabPanel.MyStepTabRibbon.btnSubscript_Click(this, new EventArgs()); // click the Subscrpt button on the ribbon
|
|
if (!MyStepRTB.ContainsFocus)
|
|
MyStepRTB.Focus();
|
|
}
|
|
protected void OpenAnnotations()
|
|
{
|
|
MyStepPanel.MyStepTabPanel.MyStepTabRibbon.btnAnnots_Click(this, new EventArgs());
|
|
}
|
|
protected bool CheckClipboard()
|
|
{
|
|
return (MyStepPanel.MyStepTabPanel.MyDisplayTabControl.MyCopyStep != null);
|
|
}
|
|
protected void CopyStep()
|
|
{
|
|
MyStepPanel.MyStepTabPanel.MyStepTabRibbon.DoCopyStep();
|
|
}
|
|
/// <summary>
|
|
/// Finds the last child in a list
|
|
/// </summary>
|
|
/// <param name="childEditItems"></param>
|
|
/// <returns></returns>
|
|
private static EditItem LastChild(List<EditItem> childEditItems)
|
|
{
|
|
return childEditItems[childEditItems.Count - 1];
|
|
}
|
|
/// <summary>
|
|
/// If the selected EditItem is within the window leave it as it is.
|
|
/// If not, scroll so that the selected window is centered.
|
|
/// </summary>
|
|
protected void ScrollToCenter()
|
|
{
|
|
//vlnStackTrace.ShowStack("CenterScroll {0} Current {1} Top {2} Bottom {3} Limit {4}", _MyItem.ItemID, _Panel.VerticalScroll.Value, Top, Bottom, _Panel.Height);// Show StackTrace
|
|
//Console.WriteLine("CenterScroll {0} Current {1} Top {2} Bottom {3} Limit {4}", _MyItem.ItemID, _Panel.VerticalScroll.Value, Top, Bottom, _Panel.Height);
|
|
if (Top >= 0 && Bottom <= MyStepPanel.Height) return;// Don't move if within screen.
|
|
int scrollValue = MyStepPanel.VerticalScroll.Value + (Top - (MyStepPanel.Height / 2)); // calculate scroll center for the item
|
|
// Limit scroll location within allowable values
|
|
scrollValue = Math.Max(MyStepPanel.VerticalScroll.Minimum,Math.Min(MyStepPanel.VerticalScroll.Maximum,scrollValue));
|
|
//Console.WriteLine("CenterScroll {0} Current {1} New {2} Min {3} Max {4}", _MyItem.ItemID, _Panel.VerticalScroll.Value, scrollValue, _Panel.VerticalScroll.Minimum, _Panel.VerticalScroll.Maximum);
|
|
//if (scrollValue >= MyStepPanel.VerticalScroll.Minimum && scrollValue <= MyStepPanel.VerticalScroll.Maximum) // If it is within range
|
|
MyStepPanel.VerticalScroll.Value = scrollValue; // Center the item
|
|
}
|
|
|
|
/// <summary>
|
|
/// Hide a Items Children - Part of colapsing
|
|
/// </summary>
|
|
protected void HideChildren()
|
|
{
|
|
HideChildren(_MyBeforeEditItems);
|
|
HideChildren(_MyRNOEditItems);
|
|
HideChildren(_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()
|
|
{
|
|
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(_LookForID.Contains(MyID))
|
|
// Console.WriteLine("{0}AdjustLocation {1},{2},{3} -> {4},{5} ({6}) {7}", WatchThisIndent, MyID, MyItemInfo.Ordinal, MyPath,
|
|
// nextEditItem == null ? 0 : nextEditItem.MyID, nextEditItem == null ? 0 : nextEditItem.MyItemInfo.Ordinal, nextEditItem == null ? "Null" : nextEditItem.MyPath,
|
|
// _NextDownEditItemPath);
|
|
if (nextEditItem != null)
|
|
{
|
|
if (MyStepPanel.ExpandingHLS != null && nextEditItem.MyItemInfo.IsSection) return; // without this, if next item is section, it crashes on null reference
|
|
if (MyStepPanel.ExpandingHLS != null && nextEditItem.MyItemInfo.MyHLS.ItemID != MyStepPanel.ExpandingHLS.ItemID)
|
|
return;
|
|
int bottom = nextEditItem.FindTop(Bottom);
|
|
if (MyItemInfo.ActiveFormat.MyStepSectionLayoutData.Dev_Format)
|
|
if (MyItemInfo.IsCaution || MyItemInfo.IsNote)
|
|
bottom = Top;
|
|
|
|
// SameRowAsParent - Comanche Peak Step Designator
|
|
//FormatData fmtdata = MyItemInfo.ActiveFormat.PlantFormat.FormatData;
|
|
//int formatSteptype = MyItemInfo.FormatStepType;
|
|
//if (fmtdata.StepDataList[formatSteptype].SameRowAsParent)
|
|
//if (MyItemInfo.SameRowAsParent && MyItemInfo.IsCaution2)
|
|
// bottom = Top;
|
|
|
|
// If this is a "TitleWithTextRight", don't move down on the screen but only if it has a
|
|
// child, i.e. want the child to be positioned on line, but if no child, move down on screen:
|
|
int newTop = bottom;
|
|
if (MyItemInfo.FormatStepData != null && MyItemInfo.FormatStepData.Type == "TitleWithTextRight" && MyItemInfo.HasChildren) newTop = Top;
|
|
if (nextEditItem.Top != newTop)
|
|
{
|
|
MyStepPanel.ItemMoving++;
|
|
nextEditItem.LastMethodsPush(string.Format("AdjustLocation {0}", MyID));
|
|
nextEditItem._NextDownEditItemPath = _NextDownEditItemPath;
|
|
float oldTop = nextEditItem.Top;
|
|
nextEditItem.ExpandPrefix = 0;// If I move then I have to move my children when I expand
|
|
// it appears that setting the top doesn't always work. The logic below checks to see if it does
|
|
// not work and trys some other things so that the EditItem will be moved to the correct place.
|
|
// As a last attempt, the EditItem is added to a list to be refreshed from a timer on MyStepPanel.
|
|
nextEditItem.Top = newTop;
|
|
if (nextEditItem.Top != newTop)
|
|
{
|
|
_MyLog.InfoFormat("'TryAgainLater',{0},{1},{2},{3},{4},'{5}'",
|
|
oldTop, nextEditItem.Top, newTop, MyStepPanel.Height, nextEditItem.MyID, nextEditItem.MyItemInfo.ShortPath);
|
|
nextEditItem.TryAgainLater = true;
|
|
}
|
|
nextEditItem.LastMethodsPop();
|
|
MyStepPanel.ItemMoving--;
|
|
}
|
|
}
|
|
}
|
|
public void TryAgainNow(int bottom)
|
|
{
|
|
TryToSetTop(bottom-10);
|
|
//TryToSetTop(bottom+10);
|
|
TryToSetTop(bottom);
|
|
}
|
|
private void TryToSetTop(int offset)
|
|
{
|
|
Top = offset;
|
|
if (Top != offset)
|
|
_MyLog.InfoFormat("Didn't work - Top {0} != offset {1} {2}", Top, offset,MyStepPanel.VerticalScroll.Value);
|
|
}
|
|
/// <summary>
|
|
/// Automatically expands Steps if not currently expanded
|
|
/// </summary>
|
|
internal void AutoExpand()
|
|
{
|
|
if (CanExpand && Expanded == false)// TODO: May need to do some additional checking for subsections
|
|
{
|
|
//vlnStackTrace.ShowStack(">AutoExpand ID {0} - Can {1} Expanded {2}", _MyItem.ItemID, CanExpand, Expanded);
|
|
if(MyStepPanel.AutoExpand)
|
|
Expand((_ContentType >= 20000) || MyItemInfo.ActiveFormat.MyStepSectionLayoutData.Dev_Format);
|
|
else
|
|
Expand(false);
|
|
//Console.WriteLine("<AutoExpand ID {0} - Can {1} Expanded {2}",_MyItem.ItemID, CanExpand, Expanded);
|
|
}
|
|
}
|
|
#endregion // Private Methods
|
|
#region Public Methods
|
|
/// <summary>
|
|
/// Expand an item and it's children
|
|
/// <para/>If the children have been loaded then just expand them
|
|
/// <para/>If not, load the children and expand their children etc.
|
|
/// </summary>
|
|
/// <param name="expand">normally equal to _Type > = 20000 (Step)</param>
|
|
public void Expand(bool expand)
|
|
{
|
|
//// TIMING: DisplayItem.TimeIt("Expand Start");
|
|
if (_ChildrenLoaded)
|
|
{
|
|
// Unhide Children
|
|
MyExpandingStatus = ExpandingStatus.Showing;
|
|
UnhideChildren(expand);
|
|
if (ExpandPrefix != 0)
|
|
{
|
|
MyStepPanel.ItemMoving++;
|
|
if(TopMostEditItem.Top != Top)
|
|
TopMostEditItem.Top = Top;
|
|
MyStepPanel.ItemMoving--;
|
|
}
|
|
else
|
|
TopMostEditItem.AdjustLocation();
|
|
AdjustChildren();
|
|
//if(_Before != null )
|
|
// Top = _Before[_Before.Count - 1].BottomMost.Bottom;
|
|
}
|
|
else
|
|
{
|
|
if (MyItemInfo.IsHigh) MyStepPanel.ExpandingHLS = MyItemInfo;
|
|
MyExpandingStatus = ExpandingStatus.Expanding;
|
|
_ChildrenLoaded = true;
|
|
//_Panel.SuspendLayout();
|
|
AddChildBefore(MyItemInfo.Cautions, expand);
|
|
AddChildBefore(MyItemInfo.Notes, expand);
|
|
AddChildAfter(MyItemInfo.Procedures, expand);
|
|
if (MyItemInfo.RNOs != null && MyItemInfo.RNOLevel < MyItemInfo.ColumnMode)
|
|
AddChildRNO(MyItemInfo.RNOs, expand);
|
|
if (MyItemInfo.RNOs != null && ((MyItemInfo.ActiveFormat.PlantFormat.FormatData.PurchaseOptions.Value & E_PurchaseOptions.EnhancedBackgrounds) == E_PurchaseOptions.EnhancedBackgrounds))
|
|
AddChildAfter(MyItemInfo.RNOs, expand);
|
|
AddChildAfter(MyItemInfo.Tables, expand);
|
|
// get the config item for the steps section. there is an 'editable'
|
|
// flag used in metasections to define whether the steps should print.
|
|
// this flag can be toggle on the section's properties dialog.
|
|
// Only check the flag if the section has subsections because the
|
|
// default for the flag is not editable, and this would make non-metasections
|
|
// not editable.
|
|
bool hasMetaSubs = MyItemInfo.IsSection && MyItemInfo.Sections != null && MyItemInfo.Sections.Count>0;
|
|
bool EditSteps = !hasMetaSubs || (MyItemInfo.MyConfig is SectionConfig && (MyItemInfo.MyConfig as SectionConfig).SubSection_Edit == "Y");
|
|
if (EditSteps) AddChildAfter(MyItemInfo.Steps, expand);
|
|
|
|
if (MyItemInfo.RNOs != null && MyItemInfo.RNOLevel >= MyItemInfo.ColumnMode &&
|
|
!((MyItemInfo.ActiveFormat.PlantFormat.FormatData.PurchaseOptions.Value & E_PurchaseOptions.EnhancedBackgrounds) == E_PurchaseOptions.EnhancedBackgrounds))
|
|
AddChildRNO(MyItemInfo.RNOs, expand);
|
|
AddChildAfter(MyItemInfo.Sections, expand);
|
|
MatchExpanded();
|
|
if (MyItemInfo.IsHigh) MyStepPanel.ExpandingHLS = null;
|
|
}
|
|
MyExpandingStatus = ExpandingStatus.Done;
|
|
BottomMostEditItem.AdjustLocation();
|
|
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)));
|
|
if(btmNext.Top != bottom)
|
|
btmNext.Top = bottom;
|
|
btmNext.LastMethodsPop();
|
|
MyStepPanel.ItemMoving--;
|
|
}
|
|
}
|
|
_NextDownEditItemPath = string.Format("Path 9 {0}", btm);
|
|
return null; // Not the bottom - don't adjust anything else
|
|
}
|
|
//else
|
|
//{
|
|
//}
|
|
}
|
|
if (EditItem != null)
|
|
{
|
|
// Need to verify that the bottom of the parents RNO does not excede the bottom of this item.
|
|
EditItem next = EditItem.MyNextEditItem.TopMostEditItem;
|
|
_NextDownEditItemPath = "Path A";
|
|
//if (Bottom >= (BottomOfParentRNO(next) ?? Bottom))
|
|
return next;// if no _After - check to see if there is a Next
|
|
//_NextDownEditItemPath = "Path B";
|
|
//return null;
|
|
}
|
|
_NextDownEditItemPath = "Path C";
|
|
return null;
|
|
}
|
|
}
|
|
|
|
private bool Ancestor(EditItem EditItem)
|
|
{
|
|
if (MyID == EditItem.MyID) return true;
|
|
if (MyItemInfo.IsHigh) return false;
|
|
return UpOneEditItem.Ancestor(EditItem);
|
|
}
|
|
public override string ToString()
|
|
{
|
|
return _MyItemInfo == null ? base.ToString() : string.Format("{0},'{1}'", 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);
|
|
int widt = MyStepPanel.ToDisplay(MyStepSectionLayoutData.WidT);
|
|
int wids = MyStepPanel.ToDisplay(MyStepSectionLayoutData.WidSTableEdit, 0);
|
|
int width = Math.Max(widt, wids);
|
|
ItemWidth = MyStepPanel.ToDisplay(MyStepSectionLayoutData.ColT) + width;
|
|
break;
|
|
case 1: // Section
|
|
if (this == TopMostEditItem)
|
|
{
|
|
if(MyItemInfo.ActiveFormat.MyStepSectionLayoutData.Dev_Format)
|
|
ItemLocation = new Point(MyStepPanel.ToDisplay(MyItemInfo.ActiveFormat.MyStepSectionLayoutData.ColS)+50, _MyParentEditItem.Bottom);
|
|
else
|
|
ItemLocation = new Point(_MyParentEditItem.ItemLocation.X + 20, _MyParentEditItem.Bottom);
|
|
}
|
|
else
|
|
TopMostEditItem.ItemLocation = new Point(TopMostEditItem.ItemLocation.X, _MyParentEditItem.Bottom);
|
|
//TextWidth = _WidthAdjust + borderWidth + MyStepPanel.ToDisplay(_MyStepSectionLayoutData.WidSTableEdit, Convert.ToInt32(_MyStepSectionLayoutData.PMode) - 1);
|
|
ContentWidth = _WidthAdjust + BorderWidth + MyStepPanel.ToDisplay(MyStepSectionLayoutData.WidSTableEdit, MyItemInfo.ColumnMode);
|
|
//ContentWidth = _WidthAdjust + BorderWidth;
|
|
//if (MyItemInfo.FormatStepData.WidthOverrideEdit != null && MyItemInfo.FormatStepData.WidthOverrideEdit > 0)
|
|
// ContentWidth += MyStepPanel.ToDisplay(MyItemInfo.FormatStepData.WidthOverrideEdit);
|
|
//else
|
|
// ContentWidth += MyStepPanel.ToDisplay(MyStepSectionLayoutData.WidSTableEdit, MyItemInfo.ColumnMode);
|
|
break;
|
|
case 2: // Step
|
|
// if Table then determine width and location based upon it's parent's location
|
|
if (MyStepData.Type == "Table" || MyStepData.ParentType == "Table")
|
|
{
|
|
AdjustTableWidthAndLocation();
|
|
}
|
|
else
|
|
{
|
|
if (MyItemInfo.FormatStepData.StepLayoutData.AlignWithParentTab)
|
|
// Paul Linn made the request on 6/4/12 to align the Component Description &
|
|
// Required Position under the Component Number.
|
|
ItemLocation = new Point(_MyParentEditItem.ItemLocation.X, _MyParentEditItem.Bottom);
|
|
else if (MyItemInfo.FormatStepData.Type == "TitleWithTextRight" && (MyItemInfo.Steps == null || MyItemInfo.Steps.Count==0)) // this code is run for siblings within a HLS (but not last sibling).
|
|
ItemLocation = new Point(_MyParentEditItem.ItemLocation.X, _MyParentEditItem.Bottom);
|
|
else if (MyItemInfo.MyParent.FormatStepData.Type == "TitleWithTextRight")
|
|
ItemLocation = new Point(_MyParentEditItem.ItemLocation.X + _MyParentEditItem.ItemWidth, _MyParentEditItem.ItemLocation.Y);
|
|
else if (MyItemInfo.MyTab.Offset != 0)
|
|
ContentLocation = new Point(_MyParentEditItem.ContentLocation.X+10, _MyParentEditItem.Bottom);
|
|
//ItemLocation = new Point(_MyParentEditItem.ItemLocation.X+10, _MyParentEditItem.Bottom);
|
|
else
|
|
ItemLocation = new Point(_MyParentEditItem.ContentLeft, _MyParentEditItem.Bottom);
|
|
|
|
bool specialTplSupport =((MyItemInfo.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DSS_PageListSpBckgrnd) == E_DocStructStyle.DSS_PageListSpBckgrnd) ||
|
|
(MyItemInfo.MyDocStyle.LandscapePageList && MyItemInfo.MyDocStyle.ComponentList);
|
|
if (MyItemInfo.FormatStepData.ReadOnly)
|
|
{
|
|
Graphics g = CreateGraphics();
|
|
SizeF sz = g.MeasureString(MyItemInfo.MyContent.Text, MyItemInfo.FormatStepData.Font.WindowsFont);
|
|
ItemWidth = (int)sz.Width;
|
|
}
|
|
else if (MyItemInfo.FormatStepData.Type == "TitleWithTextRight" && specialTplSupport)
|
|
{
|
|
Graphics g = CreateGraphics();
|
|
SizeF sz = g.MeasureString(MyItemInfo.MyContent.Text, MyItemInfo.FormatStepData.Font.WindowsFont);
|
|
ItemWidth = (int)sz.Width + 5;
|
|
}
|
|
else if (MyItemInfo.FormatStepData.Type == "TitleWithTextBelow" && specialTplSupport)
|
|
{
|
|
ItemWidth = MyStepPanel.ToDisplay(MyStepSectionLayoutData.WidSTableEdit, 0);
|
|
}
|
|
else if (MyItemInfo.MyParent.FormatStepData.Type == "TitleWithTextBelow" && specialTplSupport)
|
|
{
|
|
ItemWidth = MyParentEditItem.ItemWidth - RTBItem.RTBMargin;
|
|
}
|
|
else if (MyItemInfo.MyParent.FormatStepData.Type == "TitleWithTextRight" &&
|
|
((MyItemInfo.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DSS_PageListSpBckgrnd) == E_DocStructStyle.DSS_PageListSpBckgrnd))
|
|
{
|
|
ItemWidth = MyParentEditItem.MyParentEditItem.ContentWidth - MyParentEditItem.ItemWidth;
|
|
}
|
|
else if (MyItemInfo.MyParent.FormatStepData.Type == "TitleWithTextRight")
|
|
{
|
|
ItemWidth = MyStepPanel.ToDisplay(MyStepSectionLayoutData.ColT) + MyStepPanel.ToDisplay(MyStepSectionLayoutData.WidSTableEdit, 0);
|
|
ItemWidth = ItemWidth - ItemLocation.X;
|
|
}
|
|
else if (MyParentEditItem != null && MyParentEditItem.MyItemInfo.FormatStepData.ReadOnly)
|
|
ItemWidth = MyStepPanel.ToDisplay(MyStepSectionLayoutData.ColT) + MyStepPanel.ToDisplay(MyStepSectionLayoutData.WidSTableEdit, 0);
|
|
else if (MyItemInfo.MyTab.Offset != 0)
|
|
ContentWidth = _MyParentEditItem.ContentWidth;
|
|
else
|
|
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;
|
|
// Use the RNOWidthAlt value if it exists instead of the default RNO width
|
|
// Note that I needed to add 1 to the ToDisplay() value to be closer to the needed
|
|
// width for the screen (this does not affect the printout)
|
|
// If in single column, don't make this adjustment:
|
|
string[] splitRNOWidthAlt = MyStepSectionLayoutData.RNOWidthAlt.Split(',');
|
|
int ovrRNOWidth = (RNOLevel < splitRNOWidthAlt.Length)?MyStepPanel.ToDisplay(float.Parse(splitRNOWidthAlt[RNOLevel])+1) : 0;
|
|
if (MyStepSectionLayoutData.RNOWidthAlt != null && ovrRNOWidth > 1 && MyItemInfo.ColumnMode != 0)
|
|
ContentWidth = ovrRNOWidth;
|
|
else
|
|
ContentWidth = _MyParentEditItem.ContentWidth;
|
|
_IgnoreResize = false;
|
|
if (RNOLevel <= MyItemInfo.ColumnMode)
|
|
{
|
|
//int colR = MyStepPanel.ToDisplay(_MyStepSectionLayoutData.ColRTable, Convert.ToInt32(_MyStepSectionLayoutData.PMode) - 1);
|
|
int colR = MyStepPanel.ToDisplay(MyStepSectionLayoutData.ColRTable, MyItemInfo.ColumnMode);
|
|
if (colR - _MyParentEditItem.Width < 0) colR = _MyParentEditItem.Width + 0;
|
|
MyStepPanel.ItemMoving++;
|
|
//Left = _MyParentRTBItem.ItemLeft + RNOLevel * colR;
|
|
//ItemLocation = new Point(_MyParentRTBItem.ItemLeft + RNOLevel * colR, _MyParentRTBItem.Top);
|
|
LastMethodsPush(string.Format("set_MyParentRTBItem RNO Right {0}", MyID));
|
|
ItemLocation = new Point(_MyParentEditItem.ItemLeft + RNOLevel * colR, _MyParentEditItem.Top);
|
|
int top = _MyParentEditItem.FindTop(_MyParentEditItem.Top);
|
|
if (top != _MyParentEditItem.Top)
|
|
{
|
|
_MyParentEditItem.LastMethodsPush(string.Format("set_MyParentRTBItem RNO Right {0}", MyID));
|
|
if(_MyParentEditItem.Top != top)
|
|
_MyParentEditItem.Top = top;
|
|
_MyParentEditItem.LastMethodsPop();
|
|
Top = top;
|
|
}
|
|
LastMethodsPop();
|
|
MyStepPanel.ItemMoving--;
|
|
}
|
|
else
|
|
{
|
|
MyStepPanel.ItemMoving++;
|
|
LastMethodsPush(string.Format("set_MyParentRTBItem RNO Below {0} {1} {2}", MyID, _MyParentEditItem.BottomMostEditItem.MyID, _MyParentEditItem.BottomMostEditItem.Bottom));
|
|
ContentLocation = new Point(_MyParentEditItem.ContentLeft, _MyParentEditItem.BottomMostEditItem.Bottom);
|
|
LastMethodsPop();
|
|
//TextLocation = new Point(_MyParentRTBItem.TextLeft, FindTop(_MyParentRTBItem.Top));
|
|
MyStepPanel.ItemMoving--;
|
|
}
|
|
// Same size as the Parent
|
|
break;
|
|
case ChildRelation.Before: // Cautions and Notes
|
|
//if(_WatchThis > 0 && MyID > 2111)
|
|
// Console.WriteLine("Setting MyParent: \r\n\tParent {0},{1} \r\n\tTopMostItem {2},{3} \r\n\tNext {4}, {5}", _MyParentRTBItem.MyID, _MyParentRTBItem
|
|
// ,_MyParentRTBItem.TopMostRTBItem.MyID,_MyParentRTBItem.TopMostRTBItem
|
|
// , _MyNextRTBItem == null ? 0 : _MyNextRTBItem.MyID, _MyNextRTBItem == null ? "None" : _MyNextRTBItem.ToString());
|
|
|
|
//Location = new Point(_MyParentRTBItem.Left + 20, max(_MyParentRTBItem.Top, (_MyNextRTBItem == null ? 0 : _MyNextRTBItem.Top )) ?? 0);
|
|
_IgnoreResize = true;
|
|
int spaceToRTB = 23;
|
|
_IgnoreResize = false;
|
|
MyStepPanel.ItemMoving++;
|
|
//Location = new Point(_MyParentRTBItem.Left + 20, FindTop(_MyParentRTBItem.Top));
|
|
int myTop = MyNextEditItem == null ? _MyParentEditItem.Top : MyNextEditItem.Top;
|
|
//if (MyItemInfo.SameRowAsParent && MyItemInfo.IsCaution2)
|
|
//{
|
|
// if (MyItemInfo.WidthOverride > 0)
|
|
// Width = MyStepPanel.ToDisplay(MyItemInfo.WidthOverride) + spaceToRTB;
|
|
//}
|
|
if (MyItemInfo.ActiveFormat.MyStepSectionLayoutData.Dev_Format && (MyItemInfo.IsCaution || MyItemInfo.IsNote))
|
|
{
|
|
int x = MyStepPanel.ToDisplay(MyItemInfo.ActiveFormat.MyStepSectionLayoutData.ColT);
|
|
int y = FindTop(myTop);
|
|
// Get the "bottom" number of the longest Caution/Note on the step/substep above so that
|
|
// we can position properly on the screen.
|
|
// EX. Catawba Deviations E-1 step deviation for step 10
|
|
EditItem eitm = (MyParentEditItem.MyPreviousEditItem != null) ? MyParentEditItem.MyPreviousEditItem : MyParentEditItem.MyParentEditItem;
|
|
if (eitm != null && eitm.MyBeforeEditItems != null)
|
|
{
|
|
foreach (EditItem eitmTmp in eitm.MyBeforeEditItems)
|
|
y = Math.Max(y, eitmTmp.Bottom);
|
|
}
|
|
if(MyItemInfo.IsNote)
|
|
x += Width + 6;
|
|
Location = new Point(x, y);
|
|
}
|
|
else
|
|
Location = new Point(_MyParentEditItem.Left + 20, FindTop(myTop));
|
|
// ip2bck's needed the width to be set slightly differently to get the correct width.
|
|
int widthtpl = MyStepPanel.ToDisplay(MyStepSectionLayoutData.WidT) + spaceToRTB;
|
|
if (MyItemInfo.FormatStepData != null && MyItemInfo.FormatStepData.UseOldTemplate &&
|
|
((MyItemInfo.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DSS_PageListSpBckgrnd) == E_DocStructStyle.DSS_PageListSpBckgrnd))
|
|
widthtpl = MyParentEditItem.Width + MyParentEditItem.Left - Left;
|
|
Width = widthtpl; // MyStepPanel.ToDisplay(MyStepSectionLayoutData.WidT) + spaceToRTB;
|
|
MyStepPanel.ItemMoving--;
|
|
//_MyParentRTBItem.Top = Bottom;
|
|
// Could be a Caution or Note - Need to get WidT
|
|
break;
|
|
}
|
|
}
|
|
LastMethodsPop();
|
|
}
|
|
}
|
|
/// <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.Bottom);
|
|
ItemWidth = value.MyParentEditItem.ContentWidth;
|
|
}
|
|
else
|
|
{
|
|
if (MyItemInfo.FormatStepData != null && MyItemInfo.FormatStepData.ReadOnly)
|
|
{
|
|
Graphics g = CreateGraphics();
|
|
SizeF sz = g.MeasureString(MyItemInfo.MyContent.Text, MyItemInfo.FormatStepData.Font.WindowsFont);
|
|
ItemWidth = (int)sz.Width;
|
|
}
|
|
else if (MyPreviousEditItem != null && MyPreviousEditItem.MyItemInfo.FormatStepData != null && MyPreviousEditItem.MyItemInfo.FormatStepData.ReadOnly)
|
|
ItemWidth = MyStepPanel.ToDisplay(MyStepSectionLayoutData.ColT) + MyStepPanel.ToDisplay(MyStepSectionLayoutData.WidSTableEdit, 0);
|
|
else if (MyItemInfo.MyTab.Offset != 0)
|
|
ContentWidth = MyPreviousEditItem.ContentWidth+10;
|
|
else
|
|
Width = MyPreviousEditItem.Width;
|
|
|
|
if (TopMostEditItem == this)
|
|
{
|
|
if (MyItemInfo.ActiveFormat.MyStepSectionLayoutData.Dev_Format && (MyItemInfo.IsNote || MyItemInfo.IsCaution))
|
|
//if ((MyItemInfo.SameRowAsParent && MyItemInfo.IsCaution2) || (MyItemInfo.ActiveFormat.MyStepSectionLayoutData.Dev_Format && (MyItemInfo.IsNote || MyItemInfo.IsCaution)))
|
|
{
|
|
int x = MyStepPanel.ToDisplay(MyItemInfo.ActiveFormat.MyStepSectionLayoutData.ColT);
|
|
if (MyItemInfo.IsNote)
|
|
x += Width + 6;
|
|
Location = new Point(x, _MyPreviousEditItem.Top);
|
|
}
|
|
else
|
|
{
|
|
int top = FindTop(_MyPreviousEditItem.BottomMostEditItem.Bottom);
|
|
if (MyItemInfo.ActiveFormat.MyStepSectionLayoutData.Dev_Format && _MyPreviousEditItem.MyItemInfo.IsHigh)
|
|
//if (MyItemInfo.SameRowAsParent || (MyItemInfo.ActiveFormat.MyStepSectionLayoutData.Dev_Format && _MyPreviousEditItem.MyItemInfo.IsHigh))
|
|
{
|
|
if (_MyPreviousEditItem.MyBeforeEditItems != null)
|
|
foreach(EditItem ei in _MyPreviousEditItem.MyBeforeEditItems)
|
|
top=Math.Max(top, ei.Bottom);
|
|
}
|
|
Location = new Point(_MyPreviousEditItem.Left, top);
|
|
}
|
|
}
|
|
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 (myStepPanel.TopMostEditItem == null) myStepPanel.TopMostEditItem = this;
|
|
//if (itemInfo.ItemID == 10366) Console.WriteLine("Here");
|
|
//if (itemInfo.ItemID == 225) _MyStepRTB.Resize += new EventHandler(_MyStepRTB_Resize);
|
|
//_MyStepRTB.MyRTBItem = this;
|
|
//// TIMING: DisplayItem.TimeIt("CSLARTB InitComp");
|
|
BackColor = myStepPanel.PanelColor;
|
|
//_MyStepRTB.BackColor = myStepPanel.InactiveColor;
|
|
// TODO: Adjust top based upon format
|
|
// TODO: Remove Label and just output ident on the paint event
|
|
TabLeft = 20;
|
|
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;
|
|
if (itemInfo.MyTab != null ) TabFont = itemInfo.MyTab.MyFont.WindowsFont;
|
|
MyStepData = itemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList[ContentType % 10000];
|
|
break;
|
|
}
|
|
//this.Move += new EventHandler(DisplayItem_Move);
|
|
}
|
|
else
|
|
{
|
|
if (myStepPanel.MyFont != null) ContentFont = TabFont = myStepPanel.MyFont;
|
|
}
|
|
if (expand) ShowExpanded();
|
|
MyStepPanel = myStepPanel;
|
|
if (itemInfo != null && !myStepPanel._LookupEditItems.ContainsKey(itemInfo.ItemID)) myStepPanel._LookupEditItems.Add(itemInfo.ItemID, this);
|
|
_MyChildRelation = myChildRelation;
|
|
if (myParentEditItem != null) RNOLevel = myParentEditItem.RNOLevel;
|
|
if (itemInfo != null)
|
|
{
|
|
//// TIMING: DisplayItem.TimeIt("CSLARTB before _Layout");
|
|
MyStepSectionLayoutData = itemInfo.ActiveFormat.MyStepSectionLayoutData;
|
|
//// TIMING: DisplayItem.TimeIt("CSLARTB _Layout");
|
|
if (myParentEditItem != null)
|
|
SeqLevel = myParentEditItem.SeqLevel + ((myChildRelation == ChildRelation.After || myChildRelation == ChildRelation.Before) && itemInfo.IsSequential ? 1 : 0);
|
|
//// TIMING: DisplayItem.TimeIt("CSLARTB seqLevel");
|
|
MyItemInfo = itemInfo;
|
|
MyItemInfo.MyConfig.PropertyChanged += new PropertyChangedEventHandler(MyConfig_PropertyChanged);
|
|
}
|
|
//// 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)
|
|
{
|
|
// ip2bck's needed the ContentWidth set to get the edit windows to size correctly.
|
|
if (itemInfo.IsStep && itemInfo.FormatStepData.Type == "TitleWithTextBelow" &&
|
|
((itemInfo.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DSS_PageListSpBckgrnd) == E_DocStructStyle.DSS_PageListSpBckgrnd))
|
|
ContentWidth = myParentEditItem.ContentWidth;
|
|
|
|
if (myChildRelation == ChildRelation.None)
|
|
{
|
|
if (ContentType == 0 && MyStepSectionLayoutData != null)
|
|
{
|
|
LastMethodsPush(string.Format("SetupRTBItem {0}", MyID));
|
|
int widt = MyStepPanel.ToDisplay(MyStepSectionLayoutData.WidT);
|
|
int wids = MyStepPanel.ToDisplay(MyStepSectionLayoutData.WidSTableEdit, 0);
|
|
ItemWidth = Math.Max(widt, wids);
|
|
}
|
|
}
|
|
}
|
|
//// TIMING: DisplayItem.TimeIt("CSLARTB Parent");
|
|
SetText();
|
|
//// 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 (MyItemInfo.ActiveFormat.MyStepSectionLayoutData.Dev_Format)
|
|
if (MyItemInfo.IsCaution || MyItemInfo.IsNote)
|
|
top = myParentEditItem.TopMostEditItem.Top;
|
|
//if ((MyItemInfo.SameRowAsParent && MyItemInfo.IsCaution2) || (MyItemInfo.ActiveFormat.MyStepSectionLayoutData.Dev_Format && (MyItemInfo.IsCaution || MyItemInfo.IsNote)))
|
|
// top = myParentEditItem.TopMostEditItem.Top;
|
|
if (Top < top)
|
|
{
|
|
LastMethodsPush("SetupRTBItem");
|
|
MyStepPanel.ItemMoving++;
|
|
Top = top;
|
|
MyStepPanel.ItemMoving--;
|
|
LastMethodsPop();
|
|
}
|
|
this.Enabled = this.MyItemInfo.IsApplicable(MyStepPanel.ApplDisplayMode);
|
|
_Loading = false;
|
|
//// TIMING: DisplayItem.TimeIt("CSLARTB Controls Add");
|
|
}
|
|
void MyConfig_PropertyChanged(object sender, PropertyChangedEventArgs e)
|
|
{
|
|
SaveConfig();
|
|
}
|
|
public void SaveConfig()
|
|
{
|
|
if (!MyItemInfo.MyConfig.IsDirty) return;
|
|
using (Item itm = MyItemInfo.Get())
|
|
{
|
|
itm.MyContent.Config = MyItemInfo.MyConfig.ToString();
|
|
if (ChangeBarForConfigItemChange)
|
|
itm.MyContent.DTS = DateTime.Now;
|
|
itm.MyContent.UserID = Volian.Base.Library.VlnSettings.UserID;
|
|
itm.Save();
|
|
}
|
|
MyItemInfo.MyConfig.IsDirty = false;
|
|
}
|
|
/// <summary>
|
|
/// If the background changes, change the background of the RichTextBox
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
void EditItem_BackColorChanged(object sender, EventArgs e)
|
|
{
|
|
//IdentifyMe(false);
|
|
}
|
|
// TODO: the format of the circles, Checkoffs and Changebars should come from the format file
|
|
/// <summary>
|
|
/// This adds drawing items to the RTBItem as needed including
|
|
/// Circle around the Tab Number
|
|
/// Check-Offs
|
|
/// Change Bars
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void EditItem_Paint(object sender, PaintEventArgs e)
|
|
{
|
|
Graphics g = e.Graphics;
|
|
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
|
|
//g.DrawString(lblTab.Text, MyItemInfo.MyTab.MyFont.WindowsFont, Brushes.Red, new RectangleF(new PointF(MyStepPanel.MyStepPanelSettings.NumberLocationX, MyStepPanel.MyStepPanelSettings.NumberLocationY), MyStepPanel.MyStepPanelSettings.NumberSize), StringFormat.GenericDefault);
|
|
// adjust x location of label by 7, to position correctly.
|
|
//g.DrawString(lblTab.Text, MyItemInfo.MyTab.MyFont.WindowsFont, Brushes.Blue, new RectangleF(new PointF(Convert.ToSingle(lblTab.Location.X-7), Convert.ToSingle(lblTab.Location.Y)), MyStepPanel.MyStepPanelSettings.NumberSize), StringFormat.GenericDefault);
|
|
//g.DrawLine(Pens.DarkGreen, lblTab.Location.X-7, 0, lblTab.Location.X-7, this.Height);
|
|
//g.DrawLine(Pens.DarkGreen, MyStepRTB.Location.X - 7, 0, MyStepRTB.Location.X - 7, this.Height);
|
|
//g.DrawString(TabText, MyItemInfo.MyTab.MyFont.WindowsFont, Brushes.Black, new RectangleF(new PointF(Convert.ToSingle(TabLocation.X), Convert.ToSingle(TabLocation.Y)), MyStepPanel.MyStepPanelSettings.NumberSize), StringFormat.GenericDefault);
|
|
Font myWFont = (MyItemInfo.MyTab != null) ? MyItemInfo.MyTab.MyFont.WindowsFont : MyItemInfo.FormatStepData.Font.WindowsFont;
|
|
g.DrawString(TabText, myWFont, Brushes.Black, new RectangleF(new PointF(Convert.ToSingle(TabLocation.X), Convert.ToSingle(TabLocation.Y)), this.Size), 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;
|
|
// SkipSpaces puts the checkoff macro (if specified in the format) next to the step tab
|
|
// this is used for Bryon and Braidwood
|
|
if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.ProcData.CheckOffData.SkipSpaces)
|
|
location = new PointF(ri.MyStepRTB.Left - 50, ri.MyStepRTB.Top);
|
|
else
|
|
location = new PointF(ri.MyStepRTB.Left + ri.MyStepRTB.Width + 2, ri.MyStepRTB.Top);
|
|
}
|
|
CheckOff co = MyItemInfo.GetCheckOffStep();
|
|
// There may have been a data change in the setting of which checkoff to use (property
|
|
// change in the config data), or whether a checkoff is used at all. Need to set the
|
|
// 'UserCheckOff' or 'UserCheckOffChar' properties to reflect that.
|
|
if (co != null && co.UIMark != null)
|
|
{
|
|
UserCheckOffChar = (char)co.UIMark;
|
|
Font myFont = new Font("VolianDraw", MyItemInfo.MyTab.MyFont.WindowsFont.Size);
|
|
g.DrawString(UserCheckOffChar.ToString(), myFont, Brushes.DarkGreen, new RectangleF(location, MyStepPanel.MyStepPanelSettings.NumberSize), StringFormat.GenericDefault);
|
|
}
|
|
else if (co == null) UserCheckOff = false;
|
|
}
|
|
}
|
|
}
|
|
}
|