This commit is contained in:
2010-03-25 14:51:27 +00:00
parent 8fe5e8c60c
commit 0b0c769ab0
2 changed files with 112 additions and 20 deletions

View File

@@ -480,7 +480,12 @@ namespace Volian.Controls.Library
if (_MyPreviousStepItem != null)
{
_IgnoreResize=true;
Width = MyPreviousStepItem.Width;
if (_MyStepData != null && (_MyStepData.Type == "Table" || _MyStepData.ParentType == "Table"))
{
ItemWidth = (int)TableWidth(_MyStepRTB.Font, _MyItemInfo.MyContent.Text, true);
}
else
Width = MyPreviousStepItem.Width;
_IgnoreResize=false;
//ShowMe("");
//if (MyID > _StartingID)
@@ -746,7 +751,7 @@ namespace Volian.Controls.Library
}
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);
if (itemInfo.ItemID == 225) _MyStepRTB.Resize += new EventHandler(_MyStepRTB_Resize);
_MyStepRTB.MyStepItem = this;
//// TIMING: DisplayItem.TimeIt("CSLARTB InitComp");
BackColor = myStepPanel.PanelColor;
@@ -1592,6 +1597,11 @@ namespace Volian.Controls.Library
/// <param name="e"></param>
private void StepItem_Resize(object sender, EventArgs e)
{
//if (_MyItemInfo != null && _MyItemInfo.MyContent.Type == 20008)
//{
// vlnStackTrace.ShowStackLocal(string.Format("{0},{1}", _MyItemInfo.ItemID, _MyStepRTB.Width), 3);
// Console.WriteLine("asd");
//}
//ShowMe("Resize");
if (MyStepRTB.Text.EndsWith("\n"))
if (!_LookForID.Contains(MyID))
@@ -1824,28 +1834,62 @@ namespace Volian.Controls.Library
/// </summary>
/// <param name="myFont"></param>
/// <param name="txt"></param>
/// <param name="addBorder"></param>
/// <returns></returns>
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);
//string lineMax = "";
SizeF siz10 = new SizeF();
using (Graphics g = this.CreateGraphics())
{
PointF pnt = new PointF(0, 0);
siz10 = g.MeasureString("MMMMMMMMMM", myFont, pnt, StringFormat.GenericTypographic);
}
foreach (string line in lines)
{
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)
string line2 = (addBorder ? "--" : "") + Regex.Replace(line, @"\\.*? ", ""); // Remove RTF Commands - Really should not be any
//line2 = line2.Replace(@"\u8209?", "-");
//line2 = line2.Replace("<START]", "");
//line2 = Regex.Replace(line2, @"#Link:.*?\[END>","");
line2 = StepRTB.RemoveLinkComments(line2);
// MeasureString doesn't work properly if the line include graphics characters.
//SizeF siz = g.MeasureString(line2, myFont, pnt, StringFormat.GenericTypographic);
float wid = line2.Length * siz10.Width / 10;
//Console.WriteLine("'LineWidth'\t'{0}'\t{1}\t{2:0.}\t{3:0.}\t{4:0.}",
// line2.Length, wid, max, _MyStepPanel.MyStepPanelSettings.TableWidthAdjust, line2);
if (wid + _MyStepPanel.MyStepPanelSettings.TableWidthAdjust > max)
{
max = siz.Width + _MyStepPanel.MyStepPanelSettings.TableWidthAdjust;
lineMax = line2;
max = wid + _MyStepPanel.MyStepPanelSettings.TableWidthAdjust;
//lineMax = line2;
}
}
//vlnStackTrace.ShowStackLocal("TableWidth", 1, 10);
Console.WriteLine("TableWidth = {0}, lineMax = '{1}', myFont = {2}", max, lineMax, myFont);
//Console.WriteLine("TableWidth = {0}, lineMax = '{1}', myFont = {2}", max, lineMax, myFont);
return max;
}
// OLD - RHM 3-24-2010 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 = (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;
// lineMax = line2;
// }
// }
// //vlnStackTrace.ShowStackLocal("TableWidth", 1, 10);
// Console.WriteLine("TableWidth = {0}, lineMax = '{1}', myFont = {2}", max, lineMax, myFont);
// return max;
//}
/// <summary>
/// Calculates the table location
/// </summary>