This commit is contained in:
Kathy Ruffing 2009-11-03 16:36:41 +00:00
parent be380cc312
commit 7801cdadf9

View File

@ -73,7 +73,7 @@ namespace Volian.Controls.Library
private StepData _MyStepData; private StepData _MyStepData;
private ItemInfo _MyItemInfo; private ItemInfo _MyItemInfo;
private static int _WidthAdjust = 3; private static int _WidthAdjust = 3;
private string _TabFormat;
private int _ExpandPrefix = 0; private int _ExpandPrefix = 0;
private int _ExpandSuffix = 0; private int _ExpandSuffix = 0;
private ExpandingStatus _MyExpandingStatus = ExpandingStatus.No; private ExpandingStatus _MyExpandingStatus = ExpandingStatus.No;
@ -120,13 +120,6 @@ namespace Volian.Controls.Library
int stepType = typ % 10000; int stepType = typ % 10000;
_MyStepData = value.ActiveFormat.PlantFormat.FormatData.StepDataList[stepType]; _MyStepData = value.ActiveFormat.PlantFormat.FormatData.StepDataList[stepType];
} }
#if(DEBUG)
// TODO: This formatting should come from the format file
if (value.MyContent.Type == 20002)
Circle = true;
if (_TabFormat == "o ")
CheckOff = true;
#endif
ChangeBar = _MyItemInfo.HasChangeBar(); ChangeBar = _MyItemInfo.HasChangeBar();
value.MyContent.Changed += new ContentInfoEvent(MyContent_Changed); value.MyContent.Changed += new ContentInfoEvent(MyContent_Changed);
} }
@ -210,7 +203,9 @@ namespace Volian.Controls.Library
} }
break; break;
case ChildRelation.RNO: case ChildRelation.RNO:
TabFormat = ""; // 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; _IgnoreResize = true;
TextWidth = _MyParentStepItem.TextWidth; TextWidth = _MyParentStepItem.TextWidth;
_IgnoreResize = false; _IgnoreResize = false;
@ -257,7 +252,9 @@ namespace Volian.Controls.Library
Width = _MyStepPanel.ToDisplay(_MyStepSectionLayoutData.WidT); Width = _MyStepPanel.ToDisplay(_MyStepSectionLayoutData.WidT);
_IgnoreResize = false; _IgnoreResize = false;
_MyStepPanel.ItemMoving++; _MyStepPanel.ItemMoving++;
Location = new Point(_MyParentStepItem.Left + 20, FindTop(_MyParentStepItem.Top)); //Location = new Point(_MyParentStepItem.Left + 20, FindTop(_MyParentStepItem.Top));
int myTop = MyNextStepItem == null ? _MyParentStepItem.Top : MyNextStepItem.Top;
Location = new Point(_MyParentStepItem.Left + 20, FindTop(myTop));
_MyStepPanel.ItemMoving--; _MyStepPanel.ItemMoving--;
//_MyParentStepItem.Top = Bottom; //_MyParentStepItem.Top = Bottom;
// Could be a Caution or Note - Need to get WidT // Could be a Caution or Note - Need to get WidT
@ -409,48 +406,26 @@ namespace Volian.Controls.Library
/// <summary> /// <summary>
/// Tab Format used for outputing the Tab /// Tab Format used for outputing the Tab
/// </summary> /// </summary>
private string _TabFormat;
public string TabFormat public string TabFormat
{ {
get { return _TabFormat; } get
{
if (_TabFormat == null) TabFormat = null; // execute 'set' code.
return _TabFormat;
}
set set
{ {
_TabFormat = value;
if (_MyItemInfo != null) if (_MyItemInfo != null)
{ {
string tabString = _TabFormat; ItemInfo.ResetTabString(MyID);
switch (_Type / 10000) string tabString = _MyItemInfo.MyTab.CleanText;
{
case 0: // Procedure
//// TIMING: DisplayItem.TimeIt("TabFormat Start");
tabString = _MyItemInfo.MyContent.Number.PadRight(20);
//// TIMING: DisplayItem.TimeIt("TabFormat End");
break;
case 1: // Section
//// TIMING: DisplayItem.TimeIt("TabFormat Start");
tabString = _MyItemInfo.MyContent.Number.PadRight(20);
//// TIMING: DisplayItem.TimeIt("TabFormat End");
break;
case 2: // Step
//// TIMING: DisplayItem.TimeIt("TabFormat Start");
//int ordinal = _MyItem.Ordinal;
int ordinal = Ordinal;
//// TIMING: DisplayItem.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.Text = tabString;
lblTab.Width = tabString.Length * 8; lblTab.Width = tabString.Length * 8;
Invalidate(); Invalidate();
_MyStepRTB.Left = lblTab.Left + lblTab.Width;// +2; _MyStepRTB.Left = lblTab.Left + lblTab.Width;// +2;
_MyStepRTB.Width = Width - _MyStepRTB.Left; _MyStepRTB.Width = Width - _MyStepRTB.Left;
// TODO: Performance - SetToolTip(); _TabFormat = value; // tabString;
} }
} }
} }
@ -741,14 +716,16 @@ namespace Volian.Controls.Library
} }
private void SetupStepItem(ItemInfo itemInfo, StepPanel myStepPanel, StepItem myParentStepItem, ChildRelation myChildRelation, bool expand, StepItem nextStepItem) private void SetupStepItem(ItemInfo itemInfo, StepPanel myStepPanel, StepItem myParentStepItem, ChildRelation myChildRelation, bool expand, StepItem nextStepItem)
{ {
if (itemInfo.ItemID==225)_MyStepRTB.Resize += new EventHandler(_MyStepRTB_Resize);
_MyStepRTB.MyStepItem = this; _MyStepRTB.MyStepItem = this;
//// TIMING: DisplayItem.TimeIt("CSLARTB InitComp"); //// TIMING: DisplayItem.TimeIt("CSLARTB InitComp");
BackColor = myStepPanel.PanelColor; BackColor = myStepPanel.PanelColor;
_MyStepRTB.BackColor = myStepPanel.InactiveColor; _MyStepRTB.BackColor = myStepPanel.InactiveColor;
// TODO: Adjust top based upon format // TODO: Adjust top based upon format
// TODO: Remove Label and just output ident on the paint event // TODO: Remove Label and just output ident on the paint event
lblTab.Top = 3; lblTab.Left = 20;
_MyStepRTB.Top = 3; SetupHeader(itemInfo);
this.Paint += new PaintEventHandler(StepItem_Paint); this.Paint += new PaintEventHandler(StepItem_Paint);
this.BackColorChanged += new EventHandler(StepItem_BackColorChanged); this.BackColorChanged += new EventHandler(StepItem_BackColorChanged);
if (itemInfo != null) if (itemInfo != null)
@ -757,13 +734,16 @@ namespace Volian.Controls.Library
switch (_Type / 10000) switch (_Type / 10000)
{ {
case 0: // Procedure case 0: // Procedure
_MyStepRTB.Font = lblTab.Font = myStepPanel.ProcFont; _MyStepRTB.Font = myStepPanel.ProcFont;// lblTab.Font = myStepPanel.ProcFont;
lblTab.Font = itemInfo.MyTab.MyFont.WindowsFont;
break; break;
case 1: // Section case 1: // Section
_MyStepRTB.Font = lblTab.Font = myStepPanel.SectFont; _MyStepRTB.Font = myStepPanel.SectFont;// lblTab.Font = myStepPanel.SectFont;
lblTab.Font = itemInfo.MyTab.MyFont.WindowsFont;
break; break;
case 2: // Steps case 2: // Steps
_MyStepRTB.Font = lblTab.Font = myStepPanel.StepFont; _MyStepRTB.Font = myStepPanel.StepFont;//lblTab.Font = myStepPanel.StepFont;
lblTab.Font = itemInfo.MyTab.MyFont.WindowsFont;
_MyStepData = itemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList[_Type % 10000]; _MyStepData = itemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList[_Type % 10000];
break; break;
} }
@ -790,6 +770,7 @@ namespace Volian.Controls.Library
} }
//// TIMING: DisplayItem.TimeIt("CSLARTB MyItem"); //// TIMING: DisplayItem.TimeIt("CSLARTB MyItem");
myStepPanel.Controls.Add(this); myStepPanel.Controls.Add(this);
switch (myChildRelation) switch (myChildRelation)
{ {
case ChildRelation.After: case ChildRelation.After:
@ -860,6 +841,48 @@ namespace Volian.Controls.Library
_Loading = false; _Loading = false;
//// TIMING: DisplayItem.TimeIt("CSLARTB Controls Add"); //// TIMING: DisplayItem.TimeIt("CSLARTB Controls Add");
} }
private void SetupHeader(ItemInfo itemInfo)
{
lblTab.Top = 3 + ((itemInfo.HasHeader) ? 23 : 0);
_MyStepRTB.Top = lblTab.Top; // 3 + ((itemInfo.HasHeader) ? 23 : 0);
//lblTab.Move += new EventHandler(lblTab_Move);
if (itemInfo.HasHeader)
SetupHeaderFooter(ref lblHeader, "Header", itemInfo.MyHeader);
else
{
// remove header from screen if it exists:
this.Controls.Remove(lblHeader);
lblHeader = null;
}
}
private void SetupHeader()
{
SetupHeader(MyItemInfo);
LastMethodsPush("SetupHeader");
Height = _MyStepRTB.Height + _MyStepRTB.Top + 7;
LastMethodsPop();
}
void _MyStepRTB_Resize(object sender, EventArgs e)
{
Console.WriteLine("Left {0} Width {1}", Left, Width);
}
private Label lblHeader = null;
private Label lblFooter = null;
private void SetupHeaderFooter(ref Label lbl, string name, MetaTag mTag)
{
if (lbl==null)lbl = new Label();
lbl.BackColor = System.Drawing.Color.Transparent;
lbl.Location = new System.Drawing.Point(0, 0);
lbl.Name = name;
lbl.Size = new System.Drawing.Size(this.Width, 23);
lbl.Visible = true;
lbl.Font = mTag.MyFont.WindowsFont;
lbl.Text = mTag.CleanText;
lbl.TextAlign = mTag.Justify;
this.Controls.Add(lbl);
}
#endregion #endregion
#region AddItem #region AddItem
/// <summary> /// <summary>
@ -898,14 +921,23 @@ namespace Volian.Controls.Library
MyStepPanel.ItemMoving--; MyStepPanel.ItemMoving--;
} }
} }
if (MyItemInfo.IsCaution || MyItemInfo.IsNote)
{
StepItem prev = this;
while (prev.MyPreviousStepItem != null) prev = prev.MyPreviousStepItem;
prev.SetAllTabs();
}
else
SetAllTabs(); SetAllTabs();
} }
// clear tabs, clears then all so that next 'get' will calculate new.
private void SetAllTabs() private void SetAllTabs()
{ {
TabFormat = TemporaryFormat.TabFormat(this); TabFormat = null; // reset TabFormat
//Console.WriteLine("TabFormat {0},{1},{2},{3}", MyID, MyPath, lblTab.Text,MyItemInfo.Ordinal); SetupHeader();
if (_MyAfterStepItems != null) foreach (StepItem chld in _MyAfterStepItems) chld.SetAllTabs();
if (_MyNextStepItem != null) _MyNextStepItem.SetAllTabs(); if (_MyNextStepItem != null) _MyNextStepItem.SetAllTabs();
} }
/// <summary> /// <summary>
/// Add the next item to a list /// Add the next item to a list
@ -988,6 +1020,7 @@ namespace Volian.Controls.Library
newFocus.TopMostStepItem.Top = TopMostYBefore; newFocus.TopMostStepItem.Top = TopMostYBefore;
newFocus.AdjustLocation(); newFocus.AdjustLocation();
newFocus.ShowTops(""); newFocus.ShowTops("");
return;
} }
private void HandleSqlExceptionOnDelete(System.Data.SqlClient.SqlException ex) private void HandleSqlExceptionOnDelete(System.Data.SqlClient.SqlException ex)
@ -1261,12 +1294,12 @@ namespace Volian.Controls.Library
/// <param name="args"></param> /// <param name="args"></param>
private void _StepRTB_HeightChanged(object sender, EventArgs args) private void _StepRTB_HeightChanged(object sender, EventArgs args)
{ {
if (this.Height != _MyStepRTB.Height + 10) if (this.Height != _MyStepRTB.Height+_MyStepRTB.Top+7) // add in 7 to make it look good // + 10)
{ {
//if (MyID == 2131 || MyID == 2132) //if (MyID == 2131 || MyID == 2132)
// Console.WriteLine("oops!"); // Console.WriteLine("oops!");
LastMethodsPush(string.Format("_StepRTB_HeightChanged {0}", _MyStepRTB.Height)); LastMethodsPush(string.Format("_StepRTB_HeightChanged {0}", _MyStepRTB.Height));
this.Height = _MyStepRTB.Height + 10; this.Height = _MyStepRTB.Height + _MyStepRTB.Top + 7;
LastMethodsPop(); LastMethodsPop();
} }
} }
@ -1340,6 +1373,7 @@ namespace Volian.Controls.Library
// _lookForID = MyID; // _lookForID = MyID;
if (_IgnoreResize) return; if (_IgnoreResize) return;
AdjustLocation(); AdjustLocation();
if (lblHeader != null) lblHeader.Width = this.Width;
} }
private string WatchThisIndent private string WatchThisIndent
{ {
@ -1620,7 +1654,14 @@ namespace Volian.Controls.Library
{ {
Graphics g = e.Graphics; Graphics g = e.Graphics;
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
g.DrawString(lblTab.Text, _MyStepRTB.Font, Brushes.Black, new RectangleF(new PointF(_MyStepPanel.MyStepPanelSettings.NumberLocationX, _MyStepPanel.MyStepPanelSettings.NumberLocationY), _MyStepPanel.MyStepPanelSettings.NumberSize), StringFormat.GenericDefault); //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(lblTab.Text, MyItemInfo.MyTab.MyFont.WindowsFont, Brushes.Black, new RectangleF(new PointF(Convert.ToSingle(lblTab.Location.X), Convert.ToSingle(lblTab.Location.Y)), _MyStepPanel.MyStepPanelSettings.NumberSize), StringFormat.GenericDefault);
//g.DrawLine(Pens.DarkGreen, lblTab.Location.X, 0, lblTab.Location.X, this.Height);
//g.DrawLine(Pens.DarkGreen, MyStepRTB.Location.X, 0, MyStepRTB.Location.X, this.Height);
if (Circle) if (Circle)
{ {
Pen penC = new Pen(_MyStepPanel.MyStepPanelSettings.CircleColor, _MyStepPanel.MyStepPanelSettings.CircleWeight); Pen penC = new Pen(_MyStepPanel.MyStepPanelSettings.CircleColor, _MyStepPanel.MyStepPanelSettings.CircleWeight);
@ -1634,7 +1675,7 @@ namespace Volian.Controls.Library
if (ChangeBar) if (ChangeBar)
{ {
Pen penCB = new Pen(_MyStepPanel.MyStepPanelSettings.ChangeBarColor, _MyStepPanel.MyStepPanelSettings.ChangeBarWeight); Pen penCB = new Pen(_MyStepPanel.MyStepPanelSettings.ChangeBarColor, _MyStepPanel.MyStepPanelSettings.ChangeBarWeight);
g.DrawLine(penCB, 0, 0, 0, Height); g.DrawLine(penCB, 0, _MyStepRTB.Top, 0, Height);
} }
} }
/// <summary> /// <summary>