Fixed DSO Framer:

1. Open Properly if all tabs are closed
2. Open to a full window view
3. Set Current Item in the Tab Control
Fixed Display Panel so that when you click on an item in an inactive panel, the item clicked-on become the selected item.
This commit is contained in:
Rich
2008-01-11 22:00:54 +00:00
parent 04336831c3
commit c34c604c11
5 changed files with 80 additions and 316 deletions

View File

@@ -28,32 +28,14 @@ namespace Volian.Controls.Library
Done = 16
}
#endregion
//public delegate void vlnCSLARTBLinkEvent(object sender, vlnCSLARTBLinkEventArgs args);
public partial class DisplayItem : UserControl
{
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#region Events
//public event vlnCSLARTBLinkEvent LinkClicked;
//private void OnLinkClicked(object sender, vlnCSLARTBLinkEventArgs args)
//{
// if (LinkClicked != null) LinkClicked(sender, args);
// else MessageBox.Show(args.LinkInfo.LinkText, "Unhandled Link Click", MessageBoxButtons.OK, MessageBoxIcon.Information);
//}
//public event vlnCSLARTBEvent BeforeExpand;
//private void OnBeforeExpand(object sender, EventArgs args)
//{
// if (BeforeExpand != null) BeforeExpand(sender, args);
//}
//public event vlnCSLARTBEvent BeforeColapse;
//private void OnBeforeColapse(object sender, EventArgs args)
//{
// if (BeforeColapse != null) BeforeColapse(sender, args);
//}
#endregion
#region Private Fields
private bool _ChildrenLoaded=false;
private StepSectionLayoutData _Layout;
//private FormatInfo _ActiveFormat;
private DisplayPanel _Panel;
private ChildRelation _Relation;
private bool _Loading = true;
@@ -72,14 +54,10 @@ namespace Volian.Controls.Library
{
_MyItem = value;
int typ = (int) value.MyContent.Type;
//TimeIt("f");
//TabFormat = TemporaryFormat.TabFormat(this);
//TimeIt("g");
if (typ >= 20000)
{
int stepType = typ % 10000;
_StepData = value.ActiveFormat.PlantFormat.FormatData.StepDataList[stepType];
//_StepData = _ActiveFormat.PlantFormat.FormatData.StepDataList[stepType];
}
if (value.MyContent.Type == 20001)
Circle = true;
@@ -87,14 +65,6 @@ namespace Volian.Controls.Library
CheckOff = true;
if ((value.ItemID % 25) == 0)
ChangeBar = true;
//if (value != null)
//{
// this.veRichTextBoxText.MyItem = value;
// //this.veRichTextBoxText.Text = _MyItem.MyContent.Text;
// //this.lblTab.Text = _MyItem.MyContent.Type < 20000 ? _MyItem.MyContent.Number : _MyItem.Ordinal.ToString();
// //this.lblTab.Text = _MyItem.ItemID.ToString();
// SetTab();
//}
}
}
private void SetText()
@@ -102,7 +72,6 @@ namespace Volian.Controls.Library
if (_MyItem != null)
this._DisplayRTB.MyItem = _MyItem;
}
//private static int _ColS = 8 * 120;//TODO: _layout.ColS
private static int __WidthAdjust = 3;
private DisplayItem _MyParent = null;
public DisplayItem MyParent
@@ -113,14 +82,9 @@ namespace Volian.Controls.Library
_MyParent = value;
if (_MyParent != null)
{
//this.BackColor = Color.Red;
//TabFormat = TemporaryFormat.TabFormat(this);
switch (_Relation)
{
case ChildRelation.None: // Same as after
//Location = new Point(_MyParent.Left + 20, _MyParent.Bottom);
//Width = _MyParent.Width - 20;
//break;
case ChildRelation.After:
// The size depends upon the parent type
int iType = (int)_MyParent._Type;
@@ -132,7 +96,6 @@ namespace Volian.Controls.Library
ItemWidth = _Panel.ToDisplay(_Layout.ColT) + _Panel.ToDisplay(_Layout.WidT);
break;
case 1:
//ItemWidth = _Panel.ToDisplay(_ColS) + _Panel.ToDisplay(_layout.WidSTableEdit, Convert.ToInt32(_layout.PMode)-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);
@@ -143,7 +106,6 @@ namespace Volian.Controls.Library
{
_DisplayRTB.Font = _StepData.Font.WindowsFont;
ItemWidth = (int)TableWidth(_DisplayRTB.Font, _MyItem.MyContent.Text);
//ItemLocation = new Point(_MyParent.TextLeft, _MyParent.Bottom);
ItemLocation = new Point(50, _MyParent.Bottom);
ItemLocation = TableLocation(_MyParent, _Layout, ItemWidth);
}
@@ -165,7 +127,6 @@ namespace Volian.Controls.Library
else
{
TextLocation = new Point(_MyParent.TextLeft, _MyParent.BottomMost.Bottom);
//ItemLocation = new Point(_MyParent.ItemLeft, _MyParent.BottomMost.Bottom);
}
// Same size as the Parent
TabFormat = "";
@@ -178,10 +139,8 @@ namespace Volian.Controls.Library
_Panel.Scrolling--;
// Could be a Caution or Note - Need to get WidT
Width = _Panel.ToDisplay(_Layout.WidT);
//Width = _MyParent.Width - 20;
break;
}
//veRichTextBoxText.ResizeForText();
}
}
}
@@ -194,8 +153,6 @@ namespace Volian.Controls.Library
foreach (string line in lines)
{
string line2 = Regex.Replace(line, @"\\.*? ", ""); // Remove RTF Commands
//if (line != line2)
// if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("'{0}' <> '{1}'", line, line2);
SizeF siz = g.MeasureString(line2, fnt,pnt,StringFormat.GenericTypographic) ;
if (siz.Width+ _Panel.Settings.TableWidthAdjust > max) max = siz.Width + _Panel.Settings.TableWidthAdjust;
}
@@ -234,7 +191,6 @@ namespace Volian.Controls.Library
get { return Width - lblTab.Left; }
set
{
//if(_MyLog.IsDebugEnabled)_MyLog.Debug("ItemWidth");
Width = value + lblTab.Left;
}
}
@@ -243,7 +199,6 @@ namespace Volian.Controls.Library
get { return _DisplayRTB.Width; }
set
{
//if(_MyLog.IsDebugEnabled)_MyLog.Debug("TextWidth");
Width = value + lblTab.Left + lblTab.Width;
}
}
@@ -256,7 +211,7 @@ namespace Volian.Controls.Library
{
get { return Left + _DisplayRTB.Left; }
}
private string _TabFormat ; // Volian Property Snippet
private string _TabFormat ;
public string TabFormat
{
get { return _TabFormat; }
@@ -294,12 +249,10 @@ namespace Volian.Controls.Library
break;
}
lblTab.Text = tabString;
//lblTab.Visible = (tabString != "");
lblTab.Width = tabString.Length * 8;
_DisplayRTB.Left = lblTab.Left + lblTab.Width;// +2;
_DisplayRTB.Width = Width - _DisplayRTB.Left;
// TODO: Performance - SetToolTip();
//// TIMING: vlnCSLARTB.TimeIt("TabFormat Done");
}
}
}
@@ -358,7 +311,6 @@ namespace Volian.Controls.Library
}
}
}
//private delegate vlnCSLARTB FindNext();
public DisplayItem TopMost
{
get
@@ -384,7 +336,6 @@ namespace Volian.Controls.Library
if ((Expanding != ExpandingStatus.No || Expanded) & _After != null) tmpa = _After[_After.Count - 1].BottomMost;
if (tmpr == null)
return tmpa;
//if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("Left {0}, Right {1}", tmpa.Bottom, tmpr.Bottom);
if (tmpa.Bottom >= tmpr.Bottom)
return tmpa;
return tmpr;
@@ -442,7 +393,6 @@ namespace Volian.Controls.Library
{
get { return _MyItem == null ? 0 : _MyItem.ItemID; }
}
//private bool ShowMoves = false;
private bool _Moving = false; // Volian Property Snippet
public bool Moving
{
@@ -478,6 +428,7 @@ namespace Volian.Controls.Library
this.Paint += new PaintEventHandler(vlnCSLARTB_Paint);
this.BackColorChanged += new EventHandler(vlnCSLARTB_BackColorChanged);
_DisplayRTB.Enter += new EventHandler(_DisplayRTB_Enter);
_DisplayRTB.MouseClick += new MouseEventHandler(_DisplayRTB_MouseClick);
if (item != null)
{
_Type = (int)item.MyContent.Type;
@@ -504,21 +455,16 @@ namespace Volian.Controls.Library
if(item != null)panel.ItemLookup.Add(item.ItemID, this);
_Relation = relationType;
if(parent != null)RNOLevel = parent.RNOLevel;
//List<vlnCSLARTB> siblings;
//TimeIt("d");
if (item != null)
{
//FormatInfo fi = item.ActiveFormat;
//// TIMING: vlnCSLARTB.TimeIt("CSLARTB before _Layout");
_Layout = item.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData;
//// TIMING: vlnCSLARTB.TimeIt("CSLARTB _Layout");
//_layout = item.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData;
if (parent != null)
SeqLevel = parent.SeqLevel + ((relationType == ChildRelation.After || relationType == ChildRelation.Before) && TemporaryFormat.IsSequential(item) ? 1 : 0);
//// TIMING: vlnCSLARTB.TimeIt("CSLARTB seqLevel");
MyItem = item;
}
//TabFormat = TemporaryFormat.TabFormat(item,SeqLevel);
//// TIMING: vlnCSLARTB.TimeIt("CSLARTB MyItem");
switch (relationType)
{
@@ -537,7 +483,6 @@ namespace Volian.Controls.Library
}
if (item != null)
{
//MyItem = item;
if (relationType == ChildRelation.None)
{
if (_Type == 0 && _Layout != null)
@@ -545,16 +490,10 @@ namespace Volian.Controls.Library
Width = _Panel.ToDisplay(_Layout.WidT);
}
}
//if (item != null)
//{
// //int iType = ((int)item.MyContent.Type) / 10000;
//}
}
//// TIMING: vlnCSLARTB.TimeIt("CSLARTB Parent");
SetText();
//// TIMING: vlnCSLARTB.TimeIt("CSLARTB SetText");
//MyItem = item;
//TabFormat = TemporaryFormat.TabFormat(this);
if (item != null)
{
Name = string.Format("Item-{0}", item.ItemID);
@@ -562,7 +501,6 @@ namespace Volian.Controls.Library
switch (_Type / 10000)
{
case 1:
//CanExpand = (item.MyContent.ContentPartCount != 0);
CanExpand = true;
vlnExp.Attachment = (item.MyContent.ContentPartCount == 0);
break;
@@ -573,7 +511,6 @@ namespace Volian.Controls.Library
CanExpand = false;
break;
}
//CanExpand = (item.MyContent.ContentPartCount != 0);
if(expand && (item.MyContent.ContentPartCount != 0)) // If it should expand and it can expand
Expand(true);
else
@@ -582,15 +519,16 @@ namespace Volian.Controls.Library
Expand(true);
else // otherwise only expand one level
Expand(false);
//BringToFront();
}
//// TIMING: vlnCSLARTB.TimeIt("CSLARTB before Controls Add");
panel.Controls.Add(this);
_Loading = false;
//TabFormat = "<number> ";
//// 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;
@@ -635,14 +573,12 @@ namespace Volian.Controls.Library
private void vlnCSLARTB_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
//g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
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);
//g.DrawString("\u20DE", _Panel.Settings.CircleFont, bluPen.Brush, lblTab.Left + _Panel.Settings.CircleXOffset, _Panel.Settings.CircleYOffset);
}
if (CheckOff)
{
@@ -692,19 +628,6 @@ namespace Volian.Controls.Library
public void AddChildBefore(ItemInfo item,bool expand)
{
DisplayItem child = new DisplayItem(item, _Panel,this, ChildRelation.Before,expand);
//if (_Before == null)
//{
// _Before = new List<vlnCSLARTB>();
// _Before.Add(child);
// child.MyParent = this;
//}
//else
//{
// vlnCSLARTB lastChild = LastChild(_Before);
// _Before.Add(child);
// child.Previous = lastChild;
//}
//_Before.Add(child);
}
public void AddChildBefore(ItemInfoList itemList, bool expand)
{
@@ -715,17 +638,6 @@ namespace Volian.Controls.Library
public void AddChildRNO(ItemInfo item,bool expand)
{
DisplayItem child = new DisplayItem(item, _Panel,this, ChildRelation.RNO,expand);
//if (_RNO == null)
//{
// _RNO = new List<vlnCSLARTB>();
// _RNO.Add(child);
// child.MyParent = this;
//}
//else
//{
// child.Previous = LastChild(_RNO);
// _RNO.Add(child);
//}
}
public void AddChildRNO(ItemInfoList itemList,bool expand)
{
@@ -737,18 +649,6 @@ namespace Volian.Controls.Library
{
DisplayItem child = new DisplayItem(item, _Panel, this, ChildRelation.After,expand);
child.RNOLevel = this.RNOLevel;
//if (_After == null)
//{
// _After = new List<vlnCSLARTB>();
// _After.Add(child);
// child.MyParent = this;
//}
//else
//{
// vlnCSLARTB lastChild=LastChild(_After);
// _After.Add(child);
// child.Previous = lastChild;
//}
}
public void AddChildAfter(ItemInfoList itemList,bool expand)
{
@@ -877,9 +777,6 @@ namespace Volian.Controls.Library
AddChildAfter(MyItem.Steps, expand);
AddChildAfter(MyItem.Tables, expand);
AddChildRNO(MyItem.RNOs, expand);
//if (args.Mode == vlnExpanderMode.ExpandAll)
// ExpandChildren(args);
//_Panel.ResumeLayout();
if (!vlnExp.Expanded)
vlnExp.ShowExpanded();
}
@@ -895,7 +792,6 @@ namespace Volian.Controls.Library
if (!_Loading && Expanding == ExpandingStatus.No)
Expand(_Type >= 20000);
Cursor.Current = tmp;
//Expand(args.Mode == vlnExpanderMode.ExpandAll);
}
private void ExpandChildren(List<DisplayItem> children)
{
@@ -922,8 +818,6 @@ namespace Volian.Controls.Library
{
get
{
//if (this.MyID == _WatchFor)
// if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("{0}", _WatchFor);
DisplayItem tmp = this;
if (tmp.Next == null && FirstSibling._Relation == ChildRelation.Before)
return UpOne;
@@ -937,7 +831,6 @@ namespace Volian.Controls.Library
if (tmp.Expanding == ExpandingStatus.Expanding || tmp.Moving) // Parent Expanding or Moving - Wait
return null;
DisplayItem btm = tmp.BottomMost;
//if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("'BottomMost',{0},'{1}'", btm.MyID, btm.MyText);
if (this != btm)
{
if (tmp.Next != null && tmp.Next.TopMost.Top != btm.Bottom)
@@ -951,7 +844,6 @@ namespace Volian.Controls.Library
}
if (tmp != null)
return tmp.Next.TopMost;// if no _After - check to see if there is a Next
//if (tmp != null) return tmp.Next;// if no _After - check to see if there is a Next
return null;
}
}
@@ -965,122 +857,38 @@ namespace Volian.Controls.Library
return null;
}
}
//static int _WatchFor = 333;
private void AdjustLocation()
{
//if (this.MyID == _WatchFor)
// if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("{0}",_WatchFor);
DisplayItem tmp = NextItem;
if (tmp == null) return;
//if(tmp.Top > _Panel.Height && Bottom > _Panel.Height){
// if(Bottom - tmp.Top != 0)
// _Panel.AdjustOutOfRangeControls(Bottom - tmp.Top);
// return;
//}
if (tmp != null && !tmp.Moving && tmp.Top != Bottom )
{
//if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("'Adjust Location',{0},'Move',{1}", MyID, tmp.MyID);
//tmp.TopMost.Top = Bottom;
_Panel.Scrolling++;
tmp.Top = Bottom;
_Panel.Scrolling--;
}
}
//private void SetToolTip()
//{
// toolTip1.SetToolTip(veRichTextBoxText,
// string.Format("ID={0}, ItemLeft={1}, ItemWidth={2}, TextWidth={3}, Width={4}",MyID,ItemLeft,ItemWidth,TextWidth,Width));
//}
//private static double Seconds()
//{
// DateTime t = DateTime.Now;
// return ((t.Hour * 60.0) + t.Minute) * 60.0 + t.Second + (t.Millisecond / 1000.0);
//}
//private static DateTime tLast = DateTime.Now;
//private static Dictionary<string, long> dicTiming = new Dictionary<string, long>();
//public static void TimeIt(string p)
//{
// DateTime tNow = DateTime.Now;
// if (!dicTiming.ContainsKey(p)) dicTiming[p] = 0;
// dicTiming[p] += (tNow.Ticks - tLast.Ticks);
// //if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("\t{0}\t{1:0.000}", p, tNow - tLast);
// tLast = tNow;
//}
//public static void TimeItList()
//{
// //string sep = "\r\n";
// long total = 0;
// foreach (string s in dicTiming.Keys)
// {
// //if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("{0}\"{1}\"",sep, s);
// total += dicTiming[s];
// //sep = "\t";
// }
// //sep = "\r\n";
// foreach (string s in dicTiming.Keys)
// {
// //if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("{0}{1}", sep, (dicTiming[s]*100)/total );
// //sep = "\t";
// long i = (dicTiming[s]*10000)/total;
// if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("\"{0}\"\t{1}\t{2}\t\"{3}\"", s, dicTiming[s], ((float)i) / 100, "".PadRight((int)(i / 100), 'X'));
// }
// //if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("\r\n{0:0.000}", tNow - tLast);
//}
//public static void TimeItSetup()
//{
// dicTiming = new Dictionary<string, long>();
// DateTime tNow = DateTime.Now;
// // Reset all Counts
// //if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("{0:0.000}", tNow - tLast);
// tLast = tNow;
//}
public IDisplayRTB TextBox
{
get { return (IDisplayRTB)_DisplayRTB; }
}
private void vlnCSLARTB_Resize(object sender, EventArgs e)
{
//return;
//TimeIt("ResizeStart");
if (_MyItem == null) return;
//if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("'Resize',{0},{1},{2},{3},{4}", MyID, Top, Left, Height, Width);
//SetToolTip();
AdjustLocation();
//TimeIt("ResizeEnd");
}
private void vlnCSLARTB_Move(object sender, EventArgs e)
{
//return;
if (_Panel.Scrolling == 0) return;
//_MyLog.DebugFormat("'Move',{0},{1},{2},{3},{4}", MyID, Top, Left, Height, Width);
if (_MyItem == null) return;
//if (_Panel.Scrolling) return;
if (Expanding == ExpandingStatus.Expanding) return;
_Moving = true;
//if (_Panel.Automatic == false) return;
DisplayItem tmp = (DisplayItem)sender;
if (tmp._Previous == null && tmp._MyParent == null)
{
//_Panel.Scrolling = true;
return;
}
//if (ShowMoves)
//if (MyID == 367)
//{
// if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat(",{0},{1},{2},{3},'{4}'", MyID, tmp.MyID, Top, Left, e.GetType().Name);
// //ShowMoves = true;
//}
//SetToolTip();
AdjustLocation();
//if (_After != null)
//{
// if (_After[0].TopMost.Top != Bottom)
// {
// if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("'Adjust After',{0},'{1}'", MyID, MyText);
// _After[0].TopMost.Top = Bottom;
// }
//}
if (_RNO != null)
{
if (_RNO[0].TopMost.Top != Top)
@@ -1105,11 +913,6 @@ namespace Volian.Controls.Library
_Moving = false;
BottomMost.AdjustLocation();
}
//private void veRichTextBoxText_LinkClicked(object sender, LinkClickedEventArgs e)
//{
// //MessageBox.Show(e.LinkText);
// _Panel.OnLinkClicked(sender, new DisplayLinkEventArgs(this, e));
//}
void _DisplayRTB_LinkGoTo(object sender, System.Windows.Forms.LinkClickedEventArgs e)
{
_MyLog.DebugFormat("_DisplayRTB_LinkGoTo " + e.LinkText);
@@ -1127,9 +930,5 @@ namespace Volian.Controls.Library
{
_DisplayRTB.BackColor = _Panel.InactiveColor;
}
private void veRichTextBoxText_Resize(object sender, EventArgs e)
{
//if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("'Resize Text',{0},{1},{2},{3},{4}", MyID, Top, Left, Height, Width);
}
}
}