Improved Table layout
This commit is contained in:
parent
6f2b22b67e
commit
3a4ab8c801
@ -69,6 +69,11 @@ namespace Volian.Controls.Library
|
|||||||
public Label MyLabel
|
public Label MyLabel
|
||||||
{ get { return lblTab; } }
|
{ get { return lblTab; } }
|
||||||
private StepSectionLayoutData _MyStepSectionLayoutData;
|
private StepSectionLayoutData _MyStepSectionLayoutData;
|
||||||
|
public StepSectionLayoutData MyStepSectionLayoutData
|
||||||
|
{
|
||||||
|
get { return _MyStepSectionLayoutData; }
|
||||||
|
set { _MyStepSectionLayoutData = value; }
|
||||||
|
}
|
||||||
private bool _Loading = true;
|
private bool _Loading = true;
|
||||||
private StepData _MyStepData;
|
private StepData _MyStepData;
|
||||||
private ItemInfo _MyItemInfo;
|
private ItemInfo _MyItemInfo;
|
||||||
@ -210,7 +215,7 @@ namespace Volian.Controls.Library
|
|||||||
if (_MyStepData.Type == "Table" || _MyStepData.ParentType == "Table")
|
if (_MyStepData.Type == "Table" || _MyStepData.ParentType == "Table")
|
||||||
{
|
{
|
||||||
_MyStepRTB.Font = _MyStepData.Font.WindowsFont;
|
_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 = new Point(50, _MyParentStepItem.Bottom);
|
||||||
ItemLocation = TableLocation(_MyParentStepItem, _MyStepSectionLayoutData, ItemWidth);
|
ItemLocation = TableLocation(_MyParentStepItem, _MyStepSectionLayoutData, ItemWidth);
|
||||||
}
|
}
|
||||||
@ -1625,18 +1630,25 @@ namespace Volian.Controls.Library
|
|||||||
/// <param name="myFont"></param>
|
/// <param name="myFont"></param>
|
||||||
/// <param name="txt"></param>
|
/// <param name="txt"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public float TableWidth(Font myFont, string txt)
|
public float TableWidth(Font myFont, string txt, bool addBorder)
|
||||||
{
|
{
|
||||||
string[] lines = txt.Split("\n".ToCharArray());
|
string[] lines = txt.Split("\n".ToCharArray());
|
||||||
float max = 0;
|
float max = 0;
|
||||||
|
string lineMax = "";
|
||||||
Graphics g = this.CreateGraphics();
|
Graphics g = this.CreateGraphics();
|
||||||
PointF pnt = new PointF(0, 0);
|
PointF pnt = new PointF(0, 0);
|
||||||
foreach (string line in lines)
|
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);
|
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;
|
return max;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user