Changed how Height and Width of grid is calculated

Preprocessed cell data to reduce number of calls to flexgrids
Preprocessed RTF data to reduce calls to rich text boxes
Added IsRangeStyleNull property and TextAlign property to reduce call to flexgrids
Eliminated creation of multiple flexgrids but using a static flexgrid over and over
This commit is contained in:
Rich 2014-02-14 20:17:38 +00:00
parent 60ae2a7ca1
commit bc69a84d33
2 changed files with 65 additions and 22 deletions

View File

@ -52,9 +52,15 @@ namespace Volian.Print.Library
set { _MyCells = value; }
}
public float Height
{ get { return RowTop[MyFlexGrid.Rows.Count]; } }
{ get
{
return RowTop[RowTop.Length - 1];
} }
public float Width
{ get { return ColLeft[MyFlexGrid.Cols.Count]; } }
{ get
{
return ColLeft[ColLeft.Length - 1];
} }
private static float _XOffset = -1; // This moves the borders with respect to the text
public static float XOffset
@ -165,6 +171,16 @@ namespace Volian.Print.Library
MyFlexGrid = myFlexGrid;
MyContentByte = myContentByte;
SetupCells();
foreach(vlnCell cell in this)
{
GridLinePattern glp = cell.AboveLeftSide;
glp = cell.AboveRightSide;
glp = cell.BelowLeftSide;
glp = cell.BelowRightSide;
glp = cell.RightOfBottomSide;
glp = cell.RightOfTopSide;
object ta = cell.TextAlign;
}
}
#endregion
#region Private Methods
@ -190,18 +206,7 @@ namespace Volian.Print.Library
}
DisplayText dt = new DisplayText(MyFlexGrid.GetMyItemInfo(), str, false);
str = dt.StartText;
using (StepRTB myRTB = new StepRTB())
{
myRTB.Width = (int)w;
myRTB.Font = MyFlexGrid.Font;
if (str.StartsWith(@"{\rtf"))
myRTB.Rtf = str.Replace(@"\~", @"\u160?");
else
myRTB.Text = str;
myRTB.SelectAll();
myRTB.SelectionColor = PrintOverride.OverrideTextColor(System.Drawing.Color.Black);
str = myRTB.Rtf;
}
str = PreProcessRTF(w, str);
iTextSharp.text.Paragraph myPara = RtfToParagraph(str);
myColumnText1.SetSimpleColumn(0, 0, w - 2, MyContentByte.PdfDocument.PageSize.Top); // Padding = 4
@ -226,6 +231,21 @@ namespace Volian.Print.Library
}
}
}
private static StepRTB _StatRTB = new StepRTB();
private string PreProcessRTF(float w, string str)
{
_StatRTB.Text = string.Empty;
_StatRTB.Width = (int)w;
_StatRTB.Font = MyFlexGrid.Font;
if (str.StartsWith(@"{\rtf"))
_StatRTB.Rtf = str.Replace(@"\~", @"\u160?");
else
_StatRTB.Text = str;
_StatRTB.SelectAll();
_StatRTB.SelectionColor = PrintOverride.OverrideTextColor(System.Drawing.Color.Black);
str = _StatRTB.Rtf;
return str;
}
public static iTextSharp.text.Paragraph RtfToParagraph(string rtf)
{
IRtfDocument rtfDoc = RtfInterpreterTool.BuildDoc(rtf);
@ -590,15 +610,38 @@ namespace Volian.Print.Library
myColumnText.Canvas.RestoreState();
}
private static float _SixLinesPerInch = 12; // twips
public bool IsRangeStyleNull = false;
private TextAlignEnum? _TextAlign = null;
public TextAlignEnum? TextAlign
{
get
{
if (_TextAlign == null)
{
CellRange cr = MyTable.MyFlexGrid.GetCellRange(r1, c1, r2, c2);
if (cr.Style == null)
{
IsRangeStyleNull = true;
return _TextAlign;
}
else
{
IsRangeStyleNull = false;
_TextAlign = cr.Style.TextAlign;
}
}
return (TextAlignEnum)_TextAlign;
}
}
#endregion
#region Private Text Methods
private float VeritcalTextAlignment(float h)
{
float hAdjust = 0;
CellRange cr = MyTable.MyFlexGrid.GetCellRange(r1, c1, r2, c2);
if (cr.Style != null)
//CellRange cr = MyTable.MyFlexGrid.GetCellRange(r1, c1, r2, c2);
if (!IsRangeStyleNull)
{
switch (cr.Style.TextAlign)
switch (TextAlign)
{
case TextAlignEnum.CenterBottom:
case TextAlignEnum.GeneralBottom:

View File

@ -1679,9 +1679,9 @@ namespace Volian.Print.Library
bool dropCheckoff = itemInfo.ActiveFormat.PlantFormat.FormatData.ProcData.CheckOffData.DropCheckOff;
if (itemInfo.MyContent.MyGrid != null)
{
VlnFlexGrid myFlexGrid = new VlnFlexGrid(1, 1);
myFlexGrid.LoadGrid(itemInfo);
MyGrid = new vlnTable(myFlexGrid, cb);
//VlnFlexGrid myFlexGrid = new VlnFlexGrid(1, 1);
MyFlexGrid.LoadGrid(itemInfo);
MyGrid = new vlnTable(MyFlexGrid, cb);
Height = MyGrid.Height;
Width = MyGrid.Width;
@ -1700,7 +1700,7 @@ namespace Volian.Print.Library
// if the table does not have a border, only move down one line:
float yoffForBorder = 2 * SixLinesPerInch;
if (myFlexGrid.BorderStyle == C1.Win.C1FlexGrid.Util.BaseControls.BorderStyleEnum.None && !myFlexGrid.TopRowHasBorder())
if (MyFlexGrid.BorderStyle == C1.Win.C1FlexGrid.Util.BaseControls.BorderStyleEnum.None && !MyFlexGrid.TopRowHasBorder())
yoffForBorder -= SixLinesPerInch;
//yForCheckoff = yoff + Height - SixLinesPerInch;