Rich ee9acb929d Fix problem with Item Selected. Fixes problem so that Item selected stays selected even if it is not active.
Also, makes DSOFramer properly select the related tab when it becomes active.
2008-02-26 16:20:00 +00:00

966 lines
27 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using VEPROMS.CSLA.Library;
using System.Text.RegularExpressions;
namespace Volian.Controls.Library
{
#region Enums
public enum ChildRelation : int
{
None = 0,
After = 1,
Before = 2,
RNO = 3
}
public enum ExpandingStatus : int
{
No = 0,
Expanding = 1,
Colapsing = 2,
Hiding = 4,
Showing = 8,
Done = 16
}
#endregion
public partial class DisplayItem : UserControl
{
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#region Events
#endregion
#region Private Fields
private bool _ChildrenLoaded=false;
private StepSectionLayoutData _Layout;
private DisplayPanel _Panel;
private ChildRelation _Relation;
private bool _Loading = true;
private List<DisplayItem> _Before;
private List<DisplayItem> _After;
private List<DisplayItem> _RNO;
private StepData _StepData;
#endregion
// TODO: Look at modules to see if any should be made static
#region Properties
private ItemInfo _MyItem;
public ItemInfo MyItem
{
get { return _MyItem; }
set
{
_MyItem = value;
int typ = (int) value.MyContent.Type;
if (typ >= 20000)
{
int stepType = typ % 10000;
_StepData = value.ActiveFormat.PlantFormat.FormatData.StepDataList[stepType];
}
if (value.MyContent.Type == 20001)
Circle = true;
if (_TabFormat == "o ")
CheckOff = true;
if ((value.ItemID % 25) == 0)
ChangeBar = true;
}
}
public DisplayRTB MyDisplayRTB
{
get { return _DisplayRTB; }
}
private void SetText()
{
if (_MyItem != null)
this._DisplayRTB.MyItem = _MyItem;
}
private static int __WidthAdjust = 3;
private DisplayItem _MyParent = null;
public DisplayItem MyParent
{
get { return _MyParent; }
set
{
_MyParent = value;
if (_MyParent != null)
{
switch (_Relation)
{
case ChildRelation.None: // Same as after
case ChildRelation.After:
// The size depends upon the parent type
int iType = (int)_MyParent._Type;
switch (iType / 10000)
{
case 0:
ItemLocation = new Point(_MyParent.ItemLocation.X + 20, _MyParent.Bottom);
ItemWidth = _Panel.ToDisplay(_Layout.ColT) + _Panel.ToDisplay(_Layout.WidT);
break;
case 1:
ItemLocation = new Point(_MyParent.ItemLocation.X + 20, _MyParent.Bottom);
int borderWidth = _DisplayRTB.Width - _DisplayRTB.ClientRectangle.Width;
TextWidth = __WidthAdjust + borderWidth + _Panel.ToDisplay(_Layout.WidSTableEdit, Convert.ToInt32(_Layout.PMode) - 1);
break;
case 2:
// if Table then determine width and location based upon it's parent's location
if (_StepData.Type == "TABLE" || _StepData.ParentType == "TABLE")
{
_DisplayRTB.Font = _StepData.Font.WindowsFont;
ItemWidth = (int)TableWidth(_DisplayRTB.Font, _MyItem.MyContent.Text);
ItemLocation = new Point(50, _MyParent.Bottom);
ItemLocation = TableLocation(_MyParent, _Layout, ItemWidth);
}
else
{
ItemLocation = new Point(_MyParent.TextLeft, _MyParent.Bottom);
ItemWidth = _MyParent.TextWidth;
}
break;
}
break;
case ChildRelation.RNO:
if (RNOLevel <= _Panel.MaxRNO)
{
int colR = _Panel.ToDisplay(_Layout.ColRTable, Convert.ToInt32(_Layout.PMode) - 1);
if(colR - _MyParent.Width < 0) colR = _MyParent.Width + 0;
ItemLocation = new Point(_MyParent.ItemLeft + RNOLevel * colR , _MyParent.Top);
}
else
{
TextLocation = new Point(_MyParent.TextLeft, _MyParent.BottomMost.Bottom);
}
// Same size as the Parent
TabFormat = "";
TextWidth = _MyParent.TextWidth;
break;
case ChildRelation.Before:
Location = new Point(_MyParent.Left + 20, _MyParent.Top);
_Panel.Scrolling++;
_MyParent.Top = Bottom;
_Panel.Scrolling--;
// Could be a Caution or Note - Need to get WidT
Width = _Panel.ToDisplay(_Layout.WidT);
break;
}
}
}
}
private float TableWidth(Font fnt, string txt)
{
string[] lines = txt.Split("\n".ToCharArray());
float max = 0;
Graphics g = this.CreateGraphics();
PointF pnt = new PointF(0, 0);
foreach (string line in lines)
{
string line2 = Regex.Replace(line, @"\\.*? ", ""); // Remove RTF Commands
SizeF siz = g.MeasureString(line2, fnt,pnt,StringFormat.GenericTypographic) ;
if (siz.Width+ _Panel.Settings.TableWidthAdjust > max) max = siz.Width + _Panel.Settings.TableWidthAdjust;
}
return max;
}
private Point TableLocation(DisplayItem parent, StepSectionLayoutData layout, int width)
{
int x = parent.TextLeft;
int y = parent.Bottom;
if (x + width > parent.Right) x = parent.Right - width;
int colT = _Panel.ToDisplay(layout.ColT);
if (x < colT) x = colT;
return new Point(x,y);
}
public int ItemLeft
{
get { return Left+lblTab.Left; }
set { Left = value - lblTab.Left; }
}
public int ItemTop
{
get { return Top; }
set {
_Panel.Scrolling++;
Top = value;
_Panel.Scrolling--;
}
}
public Point ItemLocation
{
get { return new Point(Location.X + lblTab.Left, Location.Y); }
set { Location = new Point(value.X - lblTab.Left,value.Y); }
}
public int ItemWidth
{
get { return Width - lblTab.Left; }
set
{
Width = value + lblTab.Left;
}
}
public int TextWidth
{
get { return _DisplayRTB.Width; }
set
{
Width = value + lblTab.Left + lblTab.Width;
}
}
public Point TextLocation
{
get { return new Point(Location.X + _DisplayRTB.Left, Location.Y); }
set { Location = new Point(value.X - _DisplayRTB.Left, value.Y); }
}
public int TextLeft
{
get { return Left + _DisplayRTB.Left; }
}
private string _TabFormat ;
public string TabFormat
{
get { return _TabFormat; }
set
{
_TabFormat = value;
if (_MyItem != null)
{
string tabString = _TabFormat;
switch (_Type / 10000)
{
case 0: // Procedure
//// TIMING: vlnCSLARTB.TimeIt("TabFormat Start");
tabString = _MyItem.MyContent.Number.PadRight(20);
//// TIMING: vlnCSLARTB.TimeIt("TabFormat End");
break;
case 1: // Section
//// TIMING: vlnCSLARTB.TimeIt("TabFormat Start");
tabString = _MyItem.MyContent.Number.PadRight(20);
//// TIMING: vlnCSLARTB.TimeIt("TabFormat End");
break;
case 2: // Step
//// TIMING: vlnCSLARTB.TimeIt("TabFormat Start");
//int ordinal = _MyItem.Ordinal;
int ordinal = Ordinal;
//// TIMING: vlnCSLARTB.TimeIt("TabFormat End");
string alpha = AlphabeticalNumbering.Convert(ordinal);
tabString = tabString.Replace("<alpha>", alpha.ToLower());
tabString = tabString.Replace("<ALPHA>", alpha);
string roman = RomanNumeral.Convert(ordinal);
tabString = tabString.Replace("<roman>", roman.ToLower());
tabString = tabString.Replace("<ROMAN>", roman);
tabString = tabString.Replace("<number>", ordinal.ToString().PadLeft(2));
tabString = tabString.Replace("<ID>", MyID.ToString());
break;
}
lblTab.Text = tabString;
lblTab.Width = tabString.Length * 8;
_DisplayRTB.Left = lblTab.Left + lblTab.Width;// +2;
_DisplayRTB.Width = Width - _DisplayRTB.Left;
// TODO: Performance - SetToolTip();
}
}
}
public int Ordinal
{
get
{
int count = 1;
for (DisplayItem tmp = this; tmp.Previous != null; tmp = tmp.Previous) count++;
return count;
}
}
private DisplayItem _Previous = null;
public DisplayItem Previous
{
get { return _Previous; }
set
{
_Previous = value;
if (_Previous != null)
{
Location = new Point(_Previous.Left, _Previous.BottomMost.Bottom);
Width = Previous.Width;
switch (_Relation)
{
case ChildRelation.None:
break;
case ChildRelation.After:
break;
case ChildRelation.RNO:
break;
case ChildRelation.Before:
_Panel.Scrolling++;
UpOne.Top = BottomMost.Bottom;
_Panel.Scrolling--;
break;
}
if (_Previous.Next != this) _Previous.Next = this;
}
}
}
private DisplayItem _Next = null;
public DisplayItem Next
{
get { return _Next; }
set
{
_Next = value;
if (_Next != null)
{
if (_Next.Previous != this)
{
_Next.Previous = this;
Next.Location = new Point(Left, Bottom);
}
}
}
}
public DisplayItem TopMost
{
get
{
if (Expanded && _Before != null) return _Before[0].TopMost;
return this;
}
}
public new int Bottom
{
get
{
return Top + (Visible ? Height : 0);
}
}
public DisplayItem BottomMost
{
get
{
DisplayItem tmpr = null;
if ((Expanding != ExpandingStatus.No || Expanded) && _RNO != null) tmpr = _RNO[_RNO.Count - 1].BottomMost;
DisplayItem tmpa = this;
if ((Expanding != ExpandingStatus.No || Expanded) & _After != null) tmpa = _After[_After.Count - 1].BottomMost;
if (tmpr == null)
return tmpa;
if (tmpa.Bottom >= tmpr.Bottom)
return tmpa;
return tmpr;
}
}
private DisplayItem FirstSibling
{
get
{
DisplayItem tmp = this;
while (tmp.Previous != null)
tmp = tmp.Previous;
return tmp;
}
}
private int _ExpandPrefix = 0;
private int _ExpandSuffix = 0;
private DisplayItem LastSibling
{
get
{
DisplayItem tmp = this;
while (tmp.Next != null)
tmp = tmp.Next;
return tmp;
}
}
public bool Expanded
{
get { return !_Colapsing && (Expanding != ExpandingStatus.No || vlnExp.Expanded); }
set { vlnExp.Expanded = value; }
}
private ExpandingStatus _Expanding = ExpandingStatus.No; // Volian Property Snippet
public ExpandingStatus Expanding
{
get { return _Expanding; }
set { _Expanding = value; }
}
private bool _Colapsing = false; // Volian Property Snippet
public bool Colapsing
{
get { return _Colapsing; }
set { _Colapsing = value; }
}
public bool CanExpand
{
get { return vlnExp.Visible; }
set { vlnExp.Visible = value; }
}
public string MyText
{
get { return _MyItem == null ? null : _MyItem.MyContent.Text; }
}
public int MyID
{
get { return _MyItem == null ? 0 : _MyItem.ItemID; }
}
private bool _Moving = false; // Volian Property Snippet
public bool Moving
{
get { return _Moving; }
set { _Moving = value; }
}
private int _RNOLevel =0; // Volian Property Snippet
public int RNOLevel
{
get { return _RNOLevel; }
set { _RNOLevel = value; }
}
private int _SeqLevel = 0; // Volian Property Snippet
public int SeqLevel
{
get { return _SeqLevel; }
set { _SeqLevel = value; }
}
private int _Type;
#endregion
#region Constructors
public DisplayItem(ItemInfo item, DisplayPanel panel, DisplayItem parent, ChildRelation relationType, bool expand)
{
//// TIMING: vlnCSLARTB.TimeIt("CSLARTB Top");
InitializeComponent();// TODO: Performance 25%
//// TIMING: vlnCSLARTB.TimeIt("CSLARTB InitComp");
BackColor = panel.PanelColor;
_DisplayRTB.BackColor = panel.InactiveColor;
// TODO: Adjust top based upon format
// TODO: Remove Label and just output ident on the paint event
lblTab.Top = 3;
_DisplayRTB.Top = 3;
this.Paint += new PaintEventHandler(vlnCSLARTB_Paint);
this.BackColorChanged += new EventHandler(vlnCSLARTB_BackColorChanged);
//_DisplayRTB.Enter += new EventHandler(_DisplayRTB_Enter);
//_DisplayRTB.Leave += new EventHandler(_DisplayRTB_Leave);
//_DisplayRTB.GotFocus += new EventHandler(_DisplayRTB_GotFocus);
//_DisplayRTB.LostFocus += new EventHandler(_DisplayRTB_LostFocus);
_DisplayRTB.MouseClick += new MouseEventHandler(_DisplayRTB_MouseClick);
if (item != null)
{
_Type = (int)item.MyContent.Type;
switch (_Type / 10000)
{
case 0:
_DisplayRTB.Font = lblTab.Font = panel.ProcFont;
break;
case 1:
_DisplayRTB.Font = lblTab.Font = panel.SectFont;
break;
case 2:
_DisplayRTB.Font = lblTab.Font = panel.StepFont;
_StepData = item.ActiveFormat.PlantFormat.FormatData.StepDataList[_Type%10000];
break;
}
}
else
{
if (panel.MyFont != null) _DisplayRTB.Font = lblTab.Font = panel.MyFont;
}
if (expand) vlnExp.ShowExpanded();
_Panel = panel;
if(item != null)panel.ItemLookup.Add(item.ItemID, this);
_Relation = relationType;
if(parent != null)RNOLevel = parent.RNOLevel;
if (item != null)
{
//// TIMING: vlnCSLARTB.TimeIt("CSLARTB before _Layout");
_Layout = item.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData;
//// TIMING: vlnCSLARTB.TimeIt("CSLARTB _Layout");
if (parent != null)
SeqLevel = parent.SeqLevel + ((relationType == ChildRelation.After || relationType == ChildRelation.Before) && TemporaryFormat.IsSequential(item) ? 1 : 0);
//// TIMING: vlnCSLARTB.TimeIt("CSLARTB seqLevel");
MyItem = item;
}
//// TIMING: vlnCSLARTB.TimeIt("CSLARTB MyItem");
switch (relationType)
{
case ChildRelation.After:
AddItem(parent, ref parent._After);
break;
case ChildRelation.Before:
AddItem(parent, ref parent._Before);
break;
case ChildRelation.RNO:
RNOLevel = parent.RNOLevel + 1;
AddItem(parent, ref parent._RNO);
break;
case ChildRelation.None:
break;
}
if (item != null)
{
if (relationType == ChildRelation.None)
{
if (_Type == 0 && _Layout != null)
{
Width = _Panel.ToDisplay(_Layout.WidT);
}
}
}
//// TIMING: vlnCSLARTB.TimeIt("CSLARTB Parent");
SetText();
//// TIMING: vlnCSLARTB.TimeIt("CSLARTB SetText");
if (item != null)
{
Name = string.Format("Item-{0}", item.ItemID);
// Don't allow substeps to expand
switch (_Type / 10000)
{
case 1:
CanExpand = true;
vlnExp.Attachment = (item.MyContent.ContentPartCount == 0);
break;
case 2:
CanExpand = item.IsHigh && item.HasChildren; // TemporaryFormat.IsHigh(item); ;
break;
default:
CanExpand = false;
break;
}
if(expand && (item.MyContent.ContentPartCount != 0)) // If it should expand and it can expand
Expand(true);
else
if(parent == null)// If it is the top node
if(_Type >= 20000) // and it is a step - fully expand
Expand(true);
else // otherwise only expand one level
Expand(false);
}
//// TIMING: vlnCSLARTB.TimeIt("CSLARTB before Controls Add");
panel.Controls.Add(this);
_Loading = false;
//// TIMING: vlnCSLARTB.TimeIt("CSLARTB Controls Add");
}
void _DisplayRTB_MouseClick(object sender, MouseEventArgs e)
{
_DisplayRTB.Select();
}
//void _DisplayRTB_Enter(object sender, EventArgs e)
//{
// _Panel._ItemSelected = _MyItem;
// _Panel.OnItemSelectedChanged(sender, new DisplayPanelEventArgs(this, null));
//}
//void _DisplayRTB_LostFocus(object sender, EventArgs e)
//{
// //_Panel.ItemSelected = null;
// //_Panel.OnItemSelectedChanged(sender, null);
//}
//void _DisplayRTB_GotFocus(object sender, EventArgs e)
//{
// _Panel.ItemSelected = _MyItem;
// //_Panel.OnItemSelectedChanged(sender, new DisplayPanelEventArgs(this, null));
//}
//void _DisplayRTB_Leave(object sender, EventArgs e)
//{
// _Panel._ItemSelected = null;
// _Panel.OnItemSelectedChanged(sender, null);
//}
public void AutoExpand()
{
Expand(_Type >= 20000);
}
private bool _Circle=false;
public bool Circle
{
get { return _Circle; }
set { _Circle = value; }
}
private bool _CheckOff=false;
public bool CheckOff
{
get { return _CheckOff; }
set { _CheckOff = value; }
}
private bool _ChangeBar=false;
public bool ChangeBar
{
get { return _ChangeBar; }
set { _ChangeBar = value; }
}
public void ItemSelect()
{
_DisplayRTB.Focus();
_DisplayRTB.SelectAll();
if (CanExpand)
AutoExpand(); // Expand the item if you can
int scrollValue = _Panel.VerticalScroll.Value + (Top - (_Panel.Height / 2)); // calculate scroll center for the item
if(scrollValue > _Panel.VerticalScroll.Minimum && scrollValue <= _Panel.VerticalScroll.Maximum) // If it isn't within range
_Panel.VerticalScroll.Value = scrollValue; // Center the item
}
public void ItemShow()
{
_DisplayRTB.Focus();
int scrollValue = _Panel.VerticalScroll.Value + (Top - (_Panel.Height / 2)); // calculate scroll center for the item
if(scrollValue > _Panel.VerticalScroll.Minimum && scrollValue <= _Panel.VerticalScroll.Maximum) // If it isn't within range
_Panel.VerticalScroll.Value = scrollValue; // Center the item
}
private void vlnCSLARTB_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
g.DrawString(lblTab.Text, _DisplayRTB.Font, Brushes.Black ,new RectangleF(new PointF(_Panel.Settings.NumberLocationX,_Panel.Settings.NumberLocationY),_Panel.Settings.NumberSize), StringFormat.GenericDefault);
if (Circle)
{
Pen penC = new Pen(_Panel.Settings.CircleColor, _Panel.Settings.CircleWeight);
g.DrawArc(penC, lblTab.Left + 1, 0, _Panel.Settings.CircleDiameter, _Panel.Settings.CircleDiameter, 0F, 360F);
}
if (CheckOff)
{
Pen penCO = new Pen(_Panel.Settings.CheckOffColor, _Panel.Settings.CheckOffWeight);
g.DrawRectangle(penCO, _Panel.Settings.CheckOffX, _Panel.Settings.CheckOffY, _Panel.Settings.CheckOffSize, _Panel.Settings.CheckOffSize);
}
if (ChangeBar)
{
Pen penCB = new Pen(_Panel.Settings.ChangeBarColor, _Panel.Settings.ChangeBarWeight);
g.DrawLine(penCB, 0, 0, 0, Height);
}
}
void vlnCSLARTB_BackColorChanged(object sender, EventArgs e)
{
_DisplayRTB.BackColor = BackColor;
}
#endregion
#region AddItem
public void AddItem(DisplayItem parent, ref List<DisplayItem> siblings)
{
if (siblings == null)
{
siblings = new List<DisplayItem>();
siblings.Add(this);
MyParent = parent;
}
else
{
DisplayItem lastChild = LastChild(siblings);
siblings.Add(this);
Previous = lastChild;
}
TabFormat = TemporaryFormat.TabFormat(this);
}
public DisplayItem AddNext(ItemInfo item,bool expand)
{
DisplayItem tmp = new DisplayItem(item, _Panel,MyParent, ChildRelation.None,expand);
Next = tmp;
return tmp;
}
#region Add Children
public DisplayItem LastChild(List<DisplayItem> children)
{
return children[children.Count - 1];
}
public void AddChildBefore(ItemInfo item,bool expand)
{
DisplayItem child = new DisplayItem(item, _Panel,this, ChildRelation.Before,expand);
}
public void AddChildBefore(ItemInfoList itemList, bool expand)
{
if (itemList != null)
foreach (ItemInfo item in itemList)
AddChildBefore(item, expand);
}
public void AddChildRNO(ItemInfo item,bool expand)
{
DisplayItem child = new DisplayItem(item, _Panel,this, ChildRelation.RNO,expand);
}
public void AddChildRNO(ItemInfoList itemList,bool expand)
{
if (itemList != null)
foreach (ItemInfo item in itemList)
AddChildRNO(item,expand);
}
public void AddChildAfter(ItemInfo item,bool expand)
{
DisplayItem child = new DisplayItem(item, _Panel, this, ChildRelation.After,expand);
child.RNOLevel = this.RNOLevel;
}
public void AddChildAfter(ItemInfoList itemList,bool expand)
{
if (itemList != null)
foreach (ItemInfo item in itemList)
AddChildAfter(item,expand);
}
#endregion
#endregion
private void veRichTextBoxText_HeightChanged(object sender, EventArgs args)
{
this.Height = _DisplayRTB.Height+10;
}
private void vlnExp_BeforeColapse(object sender, vlnExpanderEventArgs args)
{
Cursor tmp = Cursor.Current;
Cursor.Current = Cursors.WaitCursor;
int top = TopMost.Top;// This does'nt work - this is since the last time it was expanded.
_Colapsing = true;
// Hide Children
HideChildren();
// Adjust Positions
_ExpandPrefix = Top - top;
_ExpandSuffix = BottomMost.Bottom - Bottom;
if (Top != top)
{
_Panel.Scrolling++;
Top = top;
_Panel.Scrolling--;
}
else
AdjustLocation();
BottomMost.AdjustLocation();
_Colapsing = false;
Cursor.Current = tmp;
}
protected void HideChildren()
{
HideChildren(_Before);
HideChildren(_RNO);
HideChildren(_After);
}
private void HideChildren(List<DisplayItem> children)
{
if (children != null)
{
foreach (DisplayItem child in children)
{
if (child.Expanded) child.HideChildren();
child.Visible = false;
}
}
}
protected void UnhideChildren(bool expand)
{
UnhideChildren(_Before,expand);
UnhideChildren(_RNO, expand);
UnhideChildren(_After, expand);
if(!vlnExp.Expanded)
vlnExp.ShowExpanded();
}
private void UnhideChildren(List<DisplayItem> children,bool expand)
{
if (children != null)
{
foreach (DisplayItem child in children)
{
if (child.Expanded)
child.UnhideChildren(expand);
else if (expand)
child.Expand(expand);
child.Visible = true;
}
}
}
protected void AdjustChildren()
{
AdjustChildren(_Before);
AdjustChildren(_RNO);
AdjustChildren(_After);
}
private void AdjustChildren(List<DisplayItem> children)
{
if (children != null)
{
foreach (DisplayItem child in children)
{
child.AdjustLocation();
if (child.Expanded) child.AdjustChildren();
}
}
}
private void vlnExp_AttachmentClick(object sender, vlnExpanderEventArgs args)
{
_Panel.OnAttachmentClicked(sender, new DisplayPanelAttachmentEventArgs(this));
}
public void Expand(bool expand)
{
//// TIMING: vlnCSLARTB.TimeIt("Expand Start");
if (_ChildrenLoaded)
{
// Unhide Children
Expanding = ExpandingStatus.Showing;
UnhideChildren(expand);
if (_ExpandPrefix != 0)
{
_Panel.Scrolling++;
TopMost.Top = Top;
_Panel.Scrolling--;
}
else
TopMost.AdjustLocation();
AdjustChildren();
//if(_Before != null )
// Top = _Before[_Before.Count - 1].BottomMost.Bottom;
}
else
{
Expanding = ExpandingStatus.Expanding;
_ChildrenLoaded = true;
//_Panel.SuspendLayout();
AddChildBefore(MyItem.Cautions, expand);
AddChildBefore(MyItem.Notes, expand);
AddChildAfter(MyItem.Procedures, expand);
AddChildAfter(MyItem.Sections, expand);
AddChildAfter(MyItem.Steps, expand);
AddChildAfter(MyItem.Tables, expand);
AddChildRNO(MyItem.RNOs, expand);
if (!vlnExp.Expanded)
vlnExp.ShowExpanded();
}
Expanding = ExpandingStatus.Done;
BottomMost.AdjustLocation();
Expanding = ExpandingStatus.No;
//// TIMING: vlnCSLARTB.TimeIt("Expand End");
}
private void vlnExp_BeforeExpand(object sender, vlnExpanderEventArgs args)
{
Cursor tmp = Cursor.Current;
Cursor.Current = Cursors.WaitCursor;
if (!_Loading && Expanding == ExpandingStatus.No)
Expand(_Type >= 20000);
Cursor.Current = tmp;
}
private void ExpandChildren(List<DisplayItem> children)
{
if (children != null)
{
foreach (DisplayItem child in children)
{
if (child.CanExpand)
{
child.Expand(true);
}
child.Visible = true;
}
}
}
private void ExpandChildren()
{
// Walk though Children performing Expand
ExpandChildren(_Before);
ExpandChildren(_RNO);
ExpandChildren(_After);
}
public DisplayItem NextItem
{
get
{
DisplayItem tmp = this;
if (tmp.Next == null && FirstSibling._Relation == ChildRelation.Before)
return UpOne;
if (Expanded && tmp._After != null)
return tmp._After[0].TopMost; // check to see if there is a _After if there is go that way
while (tmp != null && tmp.Next == null) // if no Next walk up the parent path
{
tmp = tmp.UpOne;
if (tmp == null) // No Parent
return null;
if (tmp.Expanding == ExpandingStatus.Expanding || tmp.Moving) // Parent Expanding or Moving - Wait
return null;
DisplayItem btm = tmp.BottomMost;
if (this != btm)
{
if (tmp.Next != null && tmp.Next.TopMost.Top != btm.Bottom)
{
_Panel.Scrolling++;
tmp.Next.TopMost.Top = btm.Bottom;
_Panel.Scrolling--;
}
return null; // Not the bottom - don't adjust anything else
}
}
if (tmp != null)
return tmp.Next.TopMost;// if no _After - check to see if there is a Next
return null;
}
}
private DisplayItem UpOne
{
get
{
DisplayItem tmp = this;
while (tmp != null && tmp.MyParent == null) tmp = tmp.Previous;
if (tmp != null) return tmp.MyParent;
return null;
}
}
private void AdjustLocation()
{
DisplayItem tmp = NextItem;
if (tmp == null) return;
if (tmp != null && !tmp.Moving && tmp.Top != Bottom )
{
_Panel.Scrolling++;
tmp.Top = Bottom;
_Panel.Scrolling--;
}
}
public IDisplayRTB TextBox
{
get { return (IDisplayRTB)_DisplayRTB; }
}
private void vlnCSLARTB_Resize(object sender, EventArgs e)
{
if (_MyItem == null) return;
AdjustLocation();
}
private void vlnCSLARTB_Move(object sender, EventArgs e)
{
if (_Panel.Scrolling == 0) return;
if (_MyItem == null) return;
if (Expanding == ExpandingStatus.Expanding) return;
_Moving = true;
DisplayItem tmp = (DisplayItem)sender;
if (tmp._Previous == null && tmp._MyParent == null)
{
return;
}
AdjustLocation();
if (_RNO != null)
{
if (_RNO[0].TopMost.Top != Top)
{
//if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("\r\n'Adjust RNO',{0},'Move',{1}", MyID, _RNO[0].MyID);
if (RNOLevel >= _Panel.MaxRNO)
{
DisplayItem tmpBottom = this;
if (_After != null) tmpBottom = _After[_After.Count - 1].BottomMost;
_Panel.Scrolling++;
_RNO[0].TopMost.Top = tmpBottom.Bottom;
_Panel.Scrolling--;
}
else
{
_Panel.Scrolling++;
_RNO[0].TopMost.Top = Top;
_Panel.Scrolling--;
}
}
}
_Moving = false;
BottomMost.AdjustLocation();
}
private void _DisplayRTB_LinkGoTo(object sender, System.Windows.Forms.LinkClickedEventArgs e)
{
_MyLog.DebugFormat("_DisplayRTB_LinkGoTo " + e.LinkText);
_Panel.OnLinkClicked(sender, new DisplayLinkEventArgs(this, e));
}
private void lblTab_MouseDown(object sender, MouseEventArgs e)
{
_Panel.OnItemClick(this, new DisplayPanelEventArgs(this, e));
}
private void _DisplayRTB_Enter(object sender, EventArgs e)
{
_Panel.DisplayRTB = _DisplayRTB;
_Panel.ItemSelected = _MyItem;
}
//private void veRichTextBoxText_Leave(object sender, EventArgs e)
//{
//}
private void _DisplayRTB_LinkModifyTran(object sender, LinkClickedEventArgs e)
{
_Panel.OnLinkModifyTran(sender, new DisplayLinkEventArgs(this, e));
}
}
}