Improved Table layout

This commit is contained in:
Rich 2009-12-18 18:35:30 +00:00
parent 6f2b22b67e
commit 3a4ab8c801

View File

@ -69,6 +69,11 @@ namespace Volian.Controls.Library
public Label MyLabel
{ get { return lblTab; } }
private StepSectionLayoutData _MyStepSectionLayoutData;
public StepSectionLayoutData MyStepSectionLayoutData
{
get { return _MyStepSectionLayoutData; }
set { _MyStepSectionLayoutData = value; }
}
private bool _Loading = true;
private StepData _MyStepData;
private ItemInfo _MyItemInfo;
@ -210,7 +215,7 @@ namespace Volian.Controls.Library
if (_MyStepData.Type == "Table" || _MyStepData.ParentType == "Table")
{
_MyStepRTB.Font = _MyStepData.Font.WindowsFont;
ItemWidth = (int)TableWidth(_MyStepRTB.Font, _MyItemInfo.MyContent.Text);
ItemWidth = (int)TableWidth(_MyStepRTB.Font, _MyItemInfo.MyContent.Text, true);
ItemLocation = new Point(50, _MyParentStepItem.Bottom);
ItemLocation = TableLocation(_MyParentStepItem, _MyStepSectionLayoutData, ItemWidth);
}
@ -1625,18 +1630,25 @@ namespace Volian.Controls.Library
/// <param name="myFont"></param>
/// <param name="txt"></param>
/// <returns></returns>
public float TableWidth(Font myFont, string txt)
public float TableWidth(Font myFont, string txt, bool addBorder)
{
string[] lines = txt.Split("\n".ToCharArray());
float max = 0;
string lineMax = "";
Graphics g = this.CreateGraphics();
PointF pnt = new PointF(0, 0);
foreach (string line in lines)
{
string line2 = Regex.Replace(line, @"\\.*? ", ""); // Remove RTF Commands
string line2 = (addBorder ? "--" : "") + Regex.Replace(line, @"\\.*? ", ""); // Remove RTF Commands
SizeF siz = g.MeasureString(line2, myFont, pnt, StringFormat.GenericTypographic);
if (siz.Width + _MyStepPanel.MyStepPanelSettings.TableWidthAdjust > max) max = siz.Width + _MyStepPanel.MyStepPanelSettings.TableWidthAdjust;
if (siz.Width + _MyStepPanel.MyStepPanelSettings.TableWidthAdjust > max)
{
max = siz.Width + _MyStepPanel.MyStepPanelSettings.TableWidthAdjust;
lineMax = line2;
}
}
//vlnStackTrace.ShowStackLocal("TableWidth", 1, 10);
Console.WriteLine("TableWidth = {0}, lineMax = '{1}', myFont = {2}", max, lineMax, myFont);
return max;
}
/// <summary>