Override the default font for Demo Mode

Check for null MyFlexGrid before using it.
Added Static LineWidth0 method used for drawing borders on the screen
Fixed logic to draw borders on the VlnFlexGrid
Fixed logic to draw grid borders on the pdf output.
This commit is contained in:
Rich 2011-04-07 23:35:07 +00:00
parent f1074ce770
commit 2d16db5bf2
6 changed files with 310 additions and 145 deletions

View File

@ -274,6 +274,13 @@ namespace VEPROMS
tc.Enter += new EventHandler(tc_Enter); tc.Enter += new EventHandler(tc_Enter);
tc.Leave += new EventHandler(tc_Leave); tc.Leave += new EventHandler(tc_Leave);
this.Deactivate += new EventHandler(frmVEPROMS_Deactivate); this.Deactivate += new EventHandler(frmVEPROMS_Deactivate);
if (VlnSettings.DemoMode) StepRTB.MyFontFamily = GetFamily("Bookman Old Style");
}
private FontFamily GetFamily(string name)
{
foreach (FontFamily ff in FontFamily.Families)
if (ff.Name == name) return ff;
return null;
} }
void frmVEPROMS_Deactivate(object sender, EventArgs e) void frmVEPROMS_Deactivate(object sender, EventArgs e)
{ {

View File

@ -339,10 +339,10 @@ namespace Volian.Controls.Library
_FormatFont = formatFont; _FormatFont = formatFont;
else else
{ {
if (VlnSettings.DebugMode || VlnSettings.ProductionMode) //if (VlnSettings.DebugMode || VlnSettings.ProductionMode)
_FormatFont = new Font(MyFontFamily == null ? formatFont.FontFamily : MyFontFamily, formatFont.Size, formatFont.Style); _FormatFont = new Font(MyFontFamily == null ? formatFont.FontFamily : MyFontFamily, formatFont.Size, formatFont.Style);
else //else
_FormatFont = new Font("Bookman Old Style", formatFont.Size, formatFont.Style); // _FormatFont = new Font("Bookman Old Style", formatFont.Size, formatFont.Style);
// TODO: Release Mode // TODO: Release Mode
//Font = _origDisplayText.TextFont.WindowsFont; // font defined in plant's format //Font = _origDisplayText.TextFont.WindowsFont; // font defined in plant's format
} }

View File

@ -165,6 +165,8 @@ namespace Volian.Controls.Library
} }
void MyFlexGrid_SelChange(object sender, EventArgs e) void MyFlexGrid_SelChange(object sender, EventArgs e)
{ {
if (MyFlexGrid == null)
return;
if (MyFlexGrid.Selection.c1 < 0 || MyFlexGrid.Selection.r1 < 0) if (MyFlexGrid.Selection.c1 < 0 || MyFlexGrid.Selection.r1 < 0)
return; return;
if (MyFlexGrid.Selection.c1 >= MyFlexGrid.Cols.Count || MyFlexGrid.Selection.r1 >= MyFlexGrid.Rows.Count) if (MyFlexGrid.Selection.c1 >= MyFlexGrid.Cols.Count || MyFlexGrid.Selection.r1 >= MyFlexGrid.Rows.Count)
@ -276,7 +278,6 @@ namespace Volian.Controls.Library
DevComponents.DotNetBar.ButtonItem btnCM4 = GetCMButton(sym); DevComponents.DotNetBar.ButtonItem btnCM4 = GetCMButton(sym);
btnCM4.Click += new System.EventHandler(btnSym_Click); btnCM4.Click += new System.EventHandler(btnSym_Click);
gc4.SubItems.Add(btnCM4); gc4.SubItems.Add(btnCM4);
} }
} }
@ -291,7 +292,6 @@ namespace Volian.Controls.Library
btnCM3.FontBold = true; btnCM3.FontBold = true;
return btnCM3; return btnCM3;
} }
//void _MyStepRTB_ModeChange(object sender, StepRTBModeChangeEventArgs args) //void _MyStepRTB_ModeChange(object sender, StepRTBModeChangeEventArgs args)
//{ //{
// SetButtonAndMenuEnabling(true); // SetButtonAndMenuEnabling(true);

View File

@ -189,6 +189,23 @@ namespace Volian.Controls.Library
return 1; return 1;
} }
} }
public static int LineWidth0(GridLinePattern linePattern)
{
switch (linePattern)
{
case GridLinePattern.None:
return 0;
case GridLinePattern.Double:
case GridLinePattern.Thick:
return 3;
case GridLinePattern.Single:
case GridLinePattern.Dotted:
case GridLinePattern.Dashed:
case GridLinePattern.Mixed:
default:
return 1;
}
}
public static Pen LinePen(GridLinePattern linePattern, Color foreColor) public static Pen LinePen(GridLinePattern linePattern, Color foreColor)
{ {
Pen pn = new Pen(foreColor, 1); Pen pn = new Pen(foreColor, 1);
@ -286,6 +303,7 @@ namespace Volian.Controls.Library
for (int r = 0; r < newRows; r++) for (int r = 0; r < newRows; r++)
{ {
int rSrc = r < row ? r : r > row + count ? r - count : row; int rSrc = r < row ? r : r > row + count ? r - count : row;
if (rSrc > Rows - 1) rSrc = Rows - 1;
for (int c = 0; c < Columns; c++) for (int c = 0; c < Columns; c++)
{ {
newLines[r * Columns + c] = Lines[rSrc * Columns + c]; newLines[r * Columns + c] = Lines[rSrc * Columns + c];

View File

@ -29,7 +29,6 @@ namespace Volian.Controls.Library
{ {
get { return _DefaultFixedBackgroundColor; } get { return _DefaultFixedBackgroundColor; }
} }
public void CopyToCopiedFlexGrid(GridCopyOption myCopyOption) public void CopyToCopiedFlexGrid(GridCopyOption myCopyOption)
{ {
MyCopyInfo.MyCopiedFlexGrid = new VlnFlexGrid(); //make a copy of the grid being copied MyCopyInfo.MyCopiedFlexGrid = new VlnFlexGrid(); //make a copy of the grid being copied
@ -537,7 +536,7 @@ namespace Volian.Controls.Library
private void SetupGrid(int numrows, int numcols) //C1FlexGrid NewGrid() private void SetupGrid(int numrows, int numcols) //C1FlexGrid NewGrid()
{ {
// setup the default size of each cell in the table/grid // setup the default size of each cell in the table/grid
this.Cols.DefaultSize = 40; this.Cols.DefaultSize = (int) DPI;
this.Rows.DefaultSize = 20; this.Rows.DefaultSize = 20;
// setup the number of rows and columns // setup the number of rows and columns
@ -771,125 +770,260 @@ namespace Volian.Controls.Library
e.Handled = true; e.Handled = true;
} }
} }
private static Color _BorderColor = Color.Black;
public static Color BorderColor
{
get { return VlnFlexGrid._BorderColor; }
set { VlnFlexGrid._BorderColor = value; }
}
private void DrawCellBorder(C1.Win.C1FlexGrid.OwnerDrawCellEventArgs e) private void DrawCellBorder(C1.Win.C1FlexGrid.OwnerDrawCellEventArgs e)
{ {
Graphics graphics =e.Graphics; Graphics grGrid =e.Graphics;
Rectangle bounds = e.Bounds; Rectangle bounds = e.Bounds;
int row = e.Row; int row = e.Row;
int col = e.Col; int col = e.Col;
CellRange cr = GetMergedRange(row, col); CellRange cr = GetMergedRange(row, col);
GridLinePattern lineTop = MyBorders.HorizontalLines[cr.r1,cr.c1]; GridLinePattern topSide = MyBorders.HorizontalLines[cr.r1,cr.c1];
GridLinePattern lineLeft = MyBorders.VerticalLines[cr.r1, cr.c1]; GridLinePattern rightOfTopSide = cr.c2 == Cols.Count - 1 ? GridLinePattern.None : MyBorders.HorizontalLines[cr.r1, cr.c2 + 1];
GridLinePattern lineBottom = MyBorders.HorizontalLines[cr.r2+1, cr.c2]; GridLinePattern leftOfTopSide = cr.c1 == 0? GridLinePattern.None : MyBorders.HorizontalLines[cr.r1, cr.c1 - 1];
GridLinePattern lineRight = MyBorders.VerticalLines[cr.r2, cr.c2+1]; GridLinePattern leftSide = MyBorders.VerticalLines[cr.r1, cr.c1];
GridLinePattern aboveLeftSide = cr.r1 == 0 ? GridLinePattern.None : MyBorders.VerticalLines[cr.r1 - 1, cr.c1];
GridLinePattern belowLeftSide = cr.r2 == Rows.Count - 1 ? GridLinePattern.None : MyBorders.VerticalLines[cr.r2 + 1, cr.c1];
GridLinePattern bottomSide = MyBorders.HorizontalLines[cr.r2+1, cr.c2];
GridLinePattern rightOfBottomSide = cr.c2 == Cols.Count - 1 ? GridLinePattern.None : MyBorders.HorizontalLines[cr.r2 + 1, cr.c2 + 1];
GridLinePattern rightSide = MyBorders.VerticalLines[cr.r2, cr.c2+1];
GridLinePattern belowRightSide = cr.r2 == Rows.Count - 1 ? GridLinePattern.None : MyBorders.VerticalLines[cr.r2 + 1, cr.c2 + 1];
GridLinePattern none = GridLinePattern.None;
int x1 = bounds.Left; int x1 = bounds.Left;
int y1 = bounds.Top; int y1 = bounds.Top;
int x2 = bounds.Right - 1; int x2 = bounds.Right - 1;
int y2 = bounds.Bottom - 1; int y2 = bounds.Bottom - 1;
// We should look at the results of the following for Focus Style
Color bColor = Color.Blue; // Temporary - Set the border color to blue.
if ((e.Style ?? Styles.Normal).Name == "Focus")
{
if (lineRight == GridLinePattern.Thick || lineRight == GridLinePattern.Double)
lineRight = GridLinePattern.Single;
if (lineBottom == GridLinePattern.Thick || lineBottom == GridLinePattern.Double)
lineBottom = GridLinePattern.Single;
}
GridItem myGridItem = Parent as GridItem; GridItem myGridItem = Parent as GridItem;
if (myGridItem == null) return; if (myGridItem == null) return;
if (row == 0 && lineTop != GridLinePattern.None) if (row == 0 || col == 0) // Top or Left Edge - Draw on parent
{ {
Pen pn = VlnBorders.LinePen(lineTop, bColor);
//GridLinePattern lineTopLeft = cr.c1 == 0 ? GridLinePattern.None : MyBorders.HorizontalLines[cr.r1, cr.c1 - 1];
GridLinePattern lineTopRight = cr.c2 == Cols.Count - 1 ? GridLinePattern.None : MyBorders.HorizontalLines[cr.r1, cr.c2 + 1];
int dxTop = col == 0 ? (lineLeft == GridLinePattern.Double || lineLeft == GridLinePattern.Thick ? -3 : -1) : 0;
int dx = col == 0 ? -1 : 0;
using (Graphics grParent = myGridItem.CreateGraphics()) using (Graphics grParent = myGridItem.CreateGraphics())
{ {
if (lineTop == GridLinePattern.Double)// cr.r2 == 0) if (row == 0)
{ {
int lengthAdjustBottom = lineRight == GridLinePattern.Double ? -2 : 0; if (col == 0)
grParent.DrawLine(pn, x1 + Left + dxTop, y1 + Top - 3, x2 + Left, y1 + Top - 3); {
grParent.DrawLine(pn, x1 + Left + dx, y1 + Top - 1, x2 + Left + lengthAdjustBottom, y1 + Top - 1); // Draw the top left intersection
//if (lineRight == GridLinePattern.Double && lineTopRight != GridLinePattern.Double) DrawIntersection(grParent, Left - 3, Top-1, none, topSide,leftSide, none);
if (lineRight != GridLinePattern.None && lineTopRight != GridLinePattern.Double) }
grParent.DrawLine(VlnBorders.LinePen(lineRight,bColor), x2 + Left, y1 + Top - 3, x2 + Left, y1 + Top - 1); // Draw the top right intersection
DrawIntersection(grParent, Left +x2 - 2, Top-1, none, rightOfTopSide,rightSide,topSide);
// Draw the top side on the parent
DrawLine(grParent, topSide, Left + x1, Top + y1 - 1, Left + x2-3, Top + y1 -1);
} }
else if(pn.Width < 2) if (col == 0)
grParent.DrawLine(pn, x1 + Left + dxTop, y1 + Top - 1, x2 + Left, y1 + Top - 1);
else // Move line up and draw an extra pixel long to account for a bug in graphics
grParent.DrawLine(pn, x1 + Left + dxTop, y1 + Top - 2, x2 + Left + 1, y1 + Top - 2);
}
}
if (col == 0 && lineLeft != GridLinePattern.None)
{
Pen pn = VlnBorders.LinePen(lineLeft, bColor);
//GridLinePattern lineLeftAbove = cr.r1 == 0 ? GridLinePattern.None : MyBorders.VerticalLines[cr.r1 - 1, cr.c1];
GridLinePattern lineLeftBelow = cr.r2 == Rows.Count - 1 ? GridLinePattern.None : MyBorders.VerticalLines[cr.r2 + 1, cr.c1];
int dyLeft = row == 0 ? (lineLeft == GridLinePattern.Double || lineLeft == GridLinePattern.Thick ? -3 : -1) : 0;
int dy = row == 0 ? -1 : 0;
//GridItem myGridItem = Parent as GridItem;
using (Graphics grParent = myGridItem.CreateGraphics())
{
if (lineLeft == GridLinePattern.Double)// cr.r2 == 0)
{ {
int lengthAdjustRight = lineBottom == GridLinePattern.Double ? -2 : 0; // Draw the bottom left intersection
grParent.DrawLine(pn, x1 + Left - 3, y1 + Top + dyLeft, x1 + Left - 3, y2 + Top); DrawIntersection(grParent, Left -3, Top + y2, leftSide,bottomSide,belowLeftSide,none);
grParent.DrawLine(pn, x1 + Left - 1, y1 + Top + dy, x1 + Left - 1, y2 + Top + lengthAdjustRight); // Draw the left side
if (lineBottom != GridLinePattern.None && lineLeftBelow != GridLinePattern.Double) DrawLine(grParent, leftSide, Left + x1 - 1, Top + y1, Left + x1 - 1, Top + y2-3);
grParent.DrawLine(VlnBorders.LinePen(lineBottom, bColor), x1 + Left - 3, y2 + Top, x1 + Left - 1, y2 + Top);
} }
else if (pn.Width < 2)
grParent.DrawLine(pn, x1 + Left - 1, y1 + Top + dyLeft, x1 + Left - 1, y2 + Top);
else // Move line left and draw an extra pixel long to account for a bug in graphics
grParent.DrawLine(pn, x1 + Left - 2, y1 + Top + dyLeft, x1 + Left - 2, y2 + Top + 1);
} }
} }
//GridLinePattern lineBottomLeft = cr.c1 == 0 ? GridLinePattern.None : MyBorders.HorizontalLines[cr.r2 + 1, cr.c1 - 1]; // Draw the bottom right intersection
GridLinePattern lineBottomRight = cr.c2 == Cols.Count - 1 ? GridLinePattern.None : MyBorders.HorizontalLines[cr.r2 + 1, cr.c2 + 1]; DrawIntersection(grGrid, x2 - 2, y2, rightSide, rightOfBottomSide, belowRightSide, bottomSide);
//GridLinePattern lineRightAbove = cr.r1 == 0 ? GridLinePattern.None : MyBorders.VerticalLines[cr.r1 - 1, cr.c2 + 1]; // Draw the bottom side
GridLinePattern lineRightBelow = cr.r2 == Rows.Count - 1 ? GridLinePattern.None : MyBorders.VerticalLines[cr.r2 + 1, cr.c2 + 1]; DrawLine(grGrid, bottomSide, x1, y2, x2-3, y2);
if (lineBottom != GridLinePattern.None) // Draw the right side
DrawLine(grGrid, rightSide, x2, y1, x2, y2-3);
}
private static void DrawLine(Graphics gr, GridLinePattern pattern, int x1, int y1, int x2, int y2)
{
if (pattern == GridLinePattern.None) return;
Pen pn = VlnBorders.LinePen(pattern, BorderColor);
DrawLine(gr, pn, pattern, x1, y1, x2, y2);
}
private static void DrawLine(Graphics gr, Pen pn, int x1, int y1, int x2, int y2)
{
DrawLine(gr, pn, GridLinePattern.Single, x1, y1, x2, y2);
}
private static void DrawLine(Graphics gr, Pen pn, GridLinePattern pattern, int x1, int y1, int x2, int y2)
{
int dx = 0;
int dy = 0;
int dblx = 0;
int dbly = 0;
int xThick = 0;
int yThick = 0;
if (x1 == x2) // Vertical Line
{ {
Pen pn = VlnBorders.LinePen(lineBottom, bColor); dx = (int) (-pn.Width / 2);
int rightWidth = lineRight == GridLinePattern.Double ? 3 : 0; //VlnBorders.LineWidth(lineRight); dblx = -2;
int thickAdjust = 0; if (pn.Width > 2)
if (lineBottom == GridLinePattern.Thick && lineRight == GridLinePattern.Double && lineBottomRight != GridLinePattern.Thick) yThick = 1;
thickAdjust = -3;
if (lineBottom == GridLinePattern.Double)
{
int lengthAdjustTop = lineRight == GridLinePattern.Double ? -2 : 0;
int lengthAdjustBottom = lineRightBelow == GridLinePattern.Double ? -2 : 0;
graphics.DrawLine(pn, x1, y2 - 2, x2+lengthAdjustTop, y2 - 2);
graphics.DrawLine(pn, x1, y2, x2+lengthAdjustBottom, y2);
if (lineRight == GridLinePattern.Double && lineBottomRight == GridLinePattern.Double && lineRightBelow == GridLinePattern.Double)
graphics.DrawLine(pn, x2, y2, x2+1, y2);
}
else if(pn.Width < 2) // Bottom line is thin. Determine if intersecting with double:
graphics.DrawLine(pn, x1, y2, x2-rightWidth, y2);
else // Move line up and draw an extra pixel long to account for a bug in graphics
graphics.DrawLine(pn, x1, y2 - 1, x2 + 1 + thickAdjust, y2 - 1);
} }
if (lineRight != GridLinePattern.None) else // Horizontal Line
{ {
Pen pn = VlnBorders.LinePen(lineRight, bColor); dy = (int) (-pn.Width / 2);
int bottomWidth = lineBottom == GridLinePattern.Double ? 3 : 0;//VlnBorders.LineWidth(lineBottom); dbly = -2;
if (pn.Width > 2)
int thickAdjust = 0; xThick = 1;
if (lineRight == GridLinePattern.Thick && lineBottom == GridLinePattern.Double && lineRightBelow != GridLinePattern.Thick) }
thickAdjust = -3; gr.DrawLine(pn, x1 + dx, y1 + dy, x2 + dx + xThick, y2 + dy + yThick);
if (lineRight == GridLinePattern.Double)// cr.r2 == 0) if(pattern == GridLinePattern.Double)
{ gr.DrawLine(pn, x1 + dx +dblx, y1 + dy + dbly, x2 + dx+dblx, y2 + dy+dbly);
int lengthAdjustLeft = lineBottom == GridLinePattern.Double ? -2 : 0; }
int lengthAdjustRight = lineBottomRight == GridLinePattern.Double ? -2 : 0; private static void DrawIntersection(Graphics gr, int x, int y, GridLinePattern up, GridLinePattern right, GridLinePattern down, GridLinePattern left)
graphics.DrawLine(pn, x2 - 2, y1, x2 - 2, y2+lengthAdjustLeft); {
graphics.DrawLine(pn, x2, y1, x2, y2+lengthAdjustRight); if (up == GridLinePattern.Double)
} if (right == GridLinePattern.Double)
else if (pn.Width < 2) if (down == GridLinePattern.Double)
graphics.DrawLine(pn, x2, y1, x2, y2-bottomWidth); if (left == GridLinePattern.Double) DrawIntersectionAllDoubles(gr, x, y);
else DrawDrawIntersection3Doubles_URD(gr, x, y);
else // Down is not double
if (left == GridLinePattern.Double) DrawDrawIntersection3Doubles_URL(gr, x, y);
else DrawDrawIntersection2Doubles_UR(gr, x, y, down, left);
else // right is not double
if (down == GridLinePattern.Double)
if (left == GridLinePattern.Double) DrawDrawIntersection3Doubles_UDL(gr, x, y);
else DrawDrawIntersection2Doubles_UD(gr, x, y, right, left);
else // Down is not double
if (left == GridLinePattern.Double) DrawIntersection2Doubles_UL(gr, x, y, right, down);
else DrawIntersectionOneDoubleOrLess(gr, x, y, up, right, down, left);
else
if (right == GridLinePattern.Double)
if (down == GridLinePattern.Double)
if (left == GridLinePattern.Double) DrawDrawIntersection3Doubles_RDL(gr, x, y);
else DrawDrawIntersection2Doubles_RD(gr, x, y, up, left);
else // Down is not double
if (left == GridLinePattern.Double) DrawDrawIntersection2Doubles_RL(gr, x, y, up, down);
else DrawIntersectionOneDoubleOrLess(gr, x, y, up, right, down, left);
else else
graphics.DrawLine(pn, x2 - 1, y1, x2 - 1, y2 + 1 + thickAdjust); if (down == GridLinePattern.Double)
if (left == GridLinePattern.Double) DrawDrawIntersection2Doubles_DL(gr, x, y, up, right);
else DrawIntersectionOneDoubleOrLess(gr, x, y, up, right, down, left);
else // These both use the same function with the same parameters
if (left == GridLinePattern.Double) DrawIntersectionOneDoubleOrLess(gr, x, y, up, right, down, left);
else DrawIntersectionOneDoubleOrLess(gr, x, y, up, right, down, left);
}
private static Pen pnDouble = VlnBorders.LinePen(GridLinePattern.Double, BorderColor);
private static Pen pnThick = VlnBorders.LinePen(GridLinePattern.Thick, BorderColor);
private static void DrawIntersectionAllDoubles(Graphics gr, int x, int y)
{
DrawLine(gr, pnDouble, x-1, y, x, y);
DrawLine(gr, pnDouble, x, y - 2, x, y - 3);
DrawLine(gr, pnDouble, x + 2, y - 2, x + 3, y - 2);
DrawLine(gr, pnDouble, x + 2, y, x + 2, y + 1);
}
private static void DrawDrawIntersection3Doubles_URD(Graphics gr, int x, int y)
{
DrawLine(gr, pnDouble, x , y, x, y - 3);
DrawLine(gr, pnDouble, x + 2, y - 2, x + 3, y - 2);
DrawLine(gr, pnDouble, x + 2, y, x + 2, y + 1);
}
private static void DrawDrawIntersection3Doubles_URL(Graphics gr, int x, int y)
{
DrawLine(gr, pnDouble, x, y, x + 2, y);
DrawLine(gr, pnDouble, x -1, y - 2, x , y - 2);
DrawLine(gr, pnDouble, x + 2, y - 2, x + 3, y - 2);
}
private static void DrawDrawIntersection3Doubles_UDL(Graphics gr, int x, int y)
{
DrawLine(gr, pnDouble, x-1, y, x, y);
DrawLine(gr, pnDouble, x , y - 2, x , y - 3);
DrawLine(gr, pnDouble, x + 2, y-3, x + 2, y);
}
private static void DrawDrawIntersection3Doubles_RDL(Graphics gr, int x, int y)
{
DrawLine(gr, pnDouble, x-1, y, x, y);
DrawLine(gr, pnDouble, x, y - 2, x + 2, y - 2);
DrawLine(gr, pnDouble, x + 2, y, x + 2, y + 1);
}
private static void DrawDrawIntersection2Doubles_UR(Graphics gr, int x, int y, GridLinePattern lp1, GridLinePattern lp2)
{
if (lp1 == GridLinePattern.Thick && lp2 == GridLinePattern.Thick)
DrawLine(gr, pnThick, x, y, x + 3, y);
else
{
DrawLine(gr, pnDouble, x, y, x + 2, y);
DrawLine(gr, pnDouble, x , y, x , y - 2);
DrawLine(gr, pnDouble, x + 2, y - 2, x + 3, y - 2);
}
}
private static void DrawDrawIntersection2Doubles_UD(Graphics gr, int x, int y, GridLinePattern lp1, GridLinePattern lp2)
{
if (lp1 == GridLinePattern.Thick && lp2 == GridLinePattern.Thick)
DrawLine(gr, pnThick, x, y, x + 3, y);
else
{
DrawLine(gr, pnDouble, x, y, x, y - 2);
DrawLine(gr, pnDouble, x + 2, y, x + 2, y - 2);
}
}
private static void DrawIntersection2Doubles_UL(Graphics gr, int x, int y, GridLinePattern lp1, GridLinePattern lp2)
{
if (lp1 == GridLinePattern.Thick && lp2 == GridLinePattern.Thick)
DrawLine(gr, pnThick, x, y, x + 3, y);
else
{
DrawLine(gr, pnDouble, x, y, x + 2, y);
DrawLine(gr, pnDouble, x , y - 2, x, y - 3);
DrawLine(gr, pnDouble, x + 2, y, x + 2, y - 2);
}
}
private static void DrawDrawIntersection2Doubles_RD(Graphics gr, int x, int y, GridLinePattern lp1, GridLinePattern lp2)
{
if (lp1 == GridLinePattern.Thick && lp2 == GridLinePattern.Thick)
DrawLine(gr, pnThick, x, y, x + 3, y);
else
{
DrawLine(gr, pnDouble, x, y, x, y - 2);
DrawLine(gr, pnDouble, x, y - 2, x + 2, y - 2);
DrawLine(gr, pnDouble, x + 2, y, x + 2, y + 1);
}
}
private static void DrawDrawIntersection2Doubles_RL(Graphics gr, int x, int y, GridLinePattern lp1, GridLinePattern lp2)
{
if (lp1 == GridLinePattern.Thick && lp2 == GridLinePattern.Thick)
DrawLine(gr, pnThick, x, y, x + 2, y);
else
{
DrawLine(gr, pnDouble, x, y, x + 2, y);
DrawLine(gr, pnDouble, x, y - 2, x + 2, y - 2);
}
}
private static void DrawDrawIntersection2Doubles_DL(Graphics gr, int x, int y, GridLinePattern lp1, GridLinePattern lp2)
{
if (lp1 == GridLinePattern.Thick && lp2 == GridLinePattern.Thick)
DrawLine(gr, pnThick, x, y, x + 2, y);
else
{
DrawLine(gr, pnDouble, x-1, y, x, y);
DrawLine(gr, pnDouble, x, y - 2, x + 2, y - 2);
DrawLine(gr, pnDouble, x + 2, y, x + 2, y - 2);
}
}
private static void DrawIntersectionOneDoubleOrLess(Graphics gr, int x, int y,
GridLinePattern up, GridLinePattern right, GridLinePattern down, GridLinePattern left)
{
Pen pnUp = VlnBorders.LinePen(up, BorderColor);
Pen pnLeft = VlnBorders.LinePen(left, BorderColor);
int widthUpDown = Math.Max(VlnBorders.LineWidth0(up), VlnBorders.LineWidth0(down));
int heightLeftRight = Math.Max(VlnBorders.LineWidth0(left), VlnBorders.LineWidth0(right));
if (heightLeftRight > 0 && widthUpDown > 0)
{
Pen pn = new Pen(BorderColor, widthUpDown);
if(heightLeftRight > 1)
DrawLine(gr, pn, x + 2, y + 1 - heightLeftRight, x + 2, y);
else if(up == GridLinePattern.None) // Work around to set a pixel (actually set two)
DrawLine(gr, pn, x + 2, y, x + 2, y + 1);
}
if (left != GridLinePattern.None)
{
DrawLine(gr, pnLeft, x, y, x + 2 - widthUpDown, y);
if (left == GridLinePattern.Double)
DrawLine(gr, pnLeft, x, y - 2, x + 2 - widthUpDown, y - 2);
}
if (up != GridLinePattern.None)
{
DrawLine(gr, pnUp, x + 2, y - 3 , x + 2, y +1 - heightLeftRight);
if (up == GridLinePattern.Double)
DrawLine(gr, pnUp, x, y - 3, x, y +1 - heightLeftRight);
} }
} }
#endregion //Grid Initialize #endregion //Grid Initialize

View File

@ -124,12 +124,12 @@ namespace Volian.Print.Library
} }
public void ToPdf(iTextSharp.text.pdf.ColumnText myColumnText, float left, float top) public void ToPdf(iTextSharp.text.pdf.ColumnText myColumnText, float left, float top)
{ {
ZoomGrid(myColumnText, left, top); //ZoomGrid(myColumnText, left, top);
MyCells.ToPdf(myColumnText, left, top); MyCells.ToPdf(myColumnText, left, top);
} }
private void ZoomGrid(iTextSharp.text.pdf.ColumnText myColumnText, float left, float top) private void ZoomGrid(iTextSharp.text.pdf.ColumnText myColumnText, float left, float top)
{ {
PdfDestination dest = new PdfDestination(PdfDestination.FITR, left - 4, top + 4 - Height, left + Width, top + 4); PdfDestination dest = new PdfDestination(PdfDestination.FITR, left - 4, top - Height - 4, left + Width, top + 4);
myColumnText.Canvas.SetAction(PdfAction.GotoLocalPage(myColumnText.Canvas.PdfWriter.CurrentPageNumber, dest, myColumnText.Canvas.PdfWriter), left, top - Height, left + Width, top); myColumnText.Canvas.SetAction(PdfAction.GotoLocalPage(myColumnText.Canvas.PdfWriter.CurrentPageNumber, dest, myColumnText.Canvas.PdfWriter), left, top - Height, left + Width, top);
} }
#endregion #endregion
@ -192,14 +192,14 @@ namespace Volian.Print.Library
else else
myRTB.Text = str; myRTB.Text = str;
myRTB.SelectAll(); myRTB.SelectAll();
myRTB.SelectionColor = System.Drawing.Color.Black; myRTB.SelectionColor = PrintOverride.OverrideTextColor(System.Drawing.Color.Black);
str = myRTB.Rtf; str = myRTB.Rtf;
} }
iTextSharp.text.Paragraph myPara = RtfToParagraph(str); iTextSharp.text.Paragraph myPara = RtfToParagraph(str);
myColumnText1.SetSimpleColumn(0, 0, w - 2, MyContentByte.PdfDocument.PageSize.Top); // Padding = 4 myColumnText1.SetSimpleColumn(0, 0, w - 2, MyContentByte.PdfDocument.PageSize.Top); // Padding = 4
myPara.MultipliedLeading = 1.2F; myPara.MultipliedLeading = 1.2F;
myColumnText1.AddElement(myPara); myColumnText1.AddElement(myPara);
//myColumnText1.Canvas.SetColorFill(iTextSharp.text.BaseColor.RED); //myColumnText1.Canvas.SetColorFill(PrintOverride.OverrideTextColor(System.Drawing.Color.Black));
float posBefore = myColumnText1.YLine; float posBefore = myColumnText1.YLine;
int status = myColumnText1.Go(true); int status = myColumnText1.Go(true);
float posAfter = myColumnText1.YLine; float posAfter = myColumnText1.YLine;
@ -606,7 +606,7 @@ namespace Volian.Print.Library
{ {
PdfContentByte cb = myColumnText.Canvas; PdfContentByte cb = myColumnText.Canvas;
cb.SaveState();// Save state before drawing borders cb.SaveState();// Save state before drawing borders
SetOpacity(cb, .7F); // This line makes the borders transparent for testing //SetOpacity(cb, .7F); // This line makes the borders transparent for testing
float xLeft = left + x + XOffset; float xLeft = left + x + XOffset;
float yTop = top - y + YOffset; float yTop = top - y + YOffset;
float xRight = left + x + w + XOffset; float xRight = left + x + w + XOffset;
@ -630,30 +630,31 @@ namespace Volian.Print.Library
{ {
if (LinePattern != GridLinePattern.None) if (LinePattern != GridLinePattern.None)
{ {
float direction = (xStart < xEnd) ? 1 : -1;
InitializeLineStyle(cb); InitializeLineStyle(cb);
SetLineColor(cb, r1, c1, side); SetLineColor(cb, r1, c1, side);
if (LinePattern == GridLinePattern.Double) if (LinePattern == GridLinePattern.Double)
{ {
// Top Line // Top Line
float dStart = -DoubleIntersectionRight(startToLeft, startToRight, startAhead); float dStart = -direction * DoubleIntersectionRight(startToLeft, startToRight, startAhead);
float dEnd = DoubleIntersectionLeft(endToLeft, endToRight, endAhead); float dEnd = direction * DoubleIntersectionLeft(endToLeft, endToRight, endAhead);
DrawLine(cb, LineThicknessForDouble, xStart + dStart, y + DoubleLineOffset, xEnd + dEnd, y + DoubleLineOffset); DrawLine(cb, LineThicknessForDouble, xStart + dStart, y + DoubleLineOffset, xEnd + dEnd, y + DoubleLineOffset);
// Bottom Line // Bottom Line
dStart = -DoubleIntersectionLeft(startToLeft, startToRight, startAhead); dStart = -direction * DoubleIntersectionLeft(startToLeft, startToRight, startAhead);
dEnd = DoubleIntersectionRight(endToLeft, endToRight, endAhead); dEnd = direction * DoubleIntersectionRight(endToLeft, endToRight, endAhead);
DrawLine(cb, LineThicknessForDouble, xStart + dStart, y - DoubleLineOffset, xEnd + dEnd, y - DoubleLineOffset); DrawLine(cb, LineThicknessForDouble, xStart + dStart, y - DoubleLineOffset, xEnd + dEnd, y - DoubleLineOffset);
} }
else if (LinePattern != GridLinePattern.Thick) else if (LinePattern != GridLinePattern.Thick)
{ {
SetLinePattern(cb, LinePattern); SetLinePattern(cb, LinePattern);
float dStart = -ThinIntersection(startToLeft, startToRight, startAhead); float dStart = -direction * ThinIntersection(startToLeft, startToRight, startAhead);
float dEnd = ThinIntersection(endToLeft, endToRight, endAhead); float dEnd = direction * ThinIntersection(endToLeft, endToRight, endAhead);
DrawLine(cb, LineThicknessForThin, xStart + dStart, y, xEnd + dEnd, y); DrawLine(cb, LineThicknessForThin, xStart + dStart, y, xEnd + dEnd, y);
} }
else else
{ {
float dStart = -ThickIntersection(startToLeft, startToRight, startAhead); float dStart = -direction * ThickIntersection(startToLeft, startToRight, startAhead);
float dEnd = ThickIntersection(endToLeft, endToRight, endAhead); float dEnd = direction * ThickIntersection(endToLeft, endToRight, endAhead);
DrawLine(cb, LineThicknessForThick, xStart + dStart, y, xEnd + dEnd, y); DrawLine(cb, LineThicknessForThick, xStart + dStart, y, xEnd + dEnd, y);
} }
cb.Stroke(); cb.Stroke();
@ -665,30 +666,31 @@ namespace Volian.Print.Library
{ {
if (LinePattern != GridLinePattern.None) if (LinePattern != GridLinePattern.None)
{ {
float direction = (yStart < yEnd) ? 1 : -1;
InitializeLineStyle(cb); InitializeLineStyle(cb);
SetLineColor(cb, r1, c1, side); SetLineColor(cb, r1, c1, side);
if (LinePattern == GridLinePattern.Double) if (LinePattern == GridLinePattern.Double)
{ {
//Left Line //Left Line
float dStart = -DoubleIntersectionRight(startToLeft, startToRight, startAhead); float dStart = -direction * DoubleIntersectionRight(startToLeft, startToRight, startAhead);
float dEnd = DoubleIntersectionLeft(endToLeft, endToRight, endAhead); float dEnd = direction * DoubleIntersectionLeft(endToLeft, endToRight, endAhead);
DrawLine(cb, LineThicknessForDouble, x - DoubleLineOffset, yStart + dStart, x - DoubleLineOffset, yEnd + dEnd); DrawLine(cb, LineThicknessForDouble, x - DoubleLineOffset, yStart + dStart, x - DoubleLineOffset, yEnd + dEnd);
//Right Line //Right Line
dStart = -DoubleIntersectionLeft(startToLeft, startToRight, startAhead); dStart = -direction * DoubleIntersectionLeft(startToLeft, startToRight, startAhead);
dEnd = DoubleIntersectionRight(endToLeft, endToRight, endAhead); dEnd = direction * DoubleIntersectionRight(endToLeft, endToRight, endAhead);
DrawLine(cb, LineThicknessForDouble, x + DoubleLineOffset, yStart + dStart, x + DoubleLineOffset, yEnd + dEnd); DrawLine(cb, LineThicknessForDouble, x + DoubleLineOffset, yStart + dStart, x + DoubleLineOffset, yEnd + dEnd);
} }
else if (LinePattern != GridLinePattern.Thick) else if (LinePattern != GridLinePattern.Thick)
{ {
SetLinePattern(cb, LinePattern); SetLinePattern(cb, LinePattern);
float dStart = -ThinIntersection(startToLeft, startToRight, startAhead); float dStart = -direction * ThinIntersection(startToLeft, startToRight, startAhead);
float dEnd = ThinIntersection(endToLeft, endToRight, endAhead); float dEnd = direction * ThinIntersection(endToLeft, endToRight, endAhead);
DrawLine(cb, LineThicknessForThin, x, yStart + dStart, x, yEnd + dEnd); DrawLine(cb, LineThicknessForThin, x, yStart + dStart, x, yEnd + dEnd);
} }
else else
{ {
float dStart = -ThickIntersection(startToLeft, startToRight, startAhead); float dStart = -direction * ThickIntersection(startToLeft, startToRight, startAhead);
float dEnd = ThickIntersection(endToLeft, endToRight, endAhead); float dEnd = direction * ThickIntersection(endToLeft, endToRight, endAhead);
DrawLine(cb, LineThicknessForThick, x, yStart + dStart, x, yEnd + dEnd); DrawLine(cb, LineThicknessForThick, x, yStart + dStart, x, yEnd + dEnd);
} }
cb.Stroke(); cb.Stroke();
@ -731,7 +733,6 @@ namespace Volian.Print.Library
| |
Line Being Drawn Line Being Drawn
Case 4: Line being drawn down: Case 4: Line being drawn down:
Line Begin Drawn Line Begin Drawn
@ -791,9 +792,14 @@ namespace Volian.Print.Library
if (lineAhead == GridLinePattern.Thick) return ThickOverDouble; if (lineAhead == GridLinePattern.Thick) return ThickOverDouble;
return -ThickUnderDouble; return -ThickUnderDouble;
} }
if (lineToLeft == GridLinePattern.Double || lineToRight == GridLinePattern.Double) if ( lineToLeft == GridLinePattern.Double || lineToRight == GridLinePattern.Double)
{ {
if (lineAhead == GridLinePattern.Double) return -ThickUnderDouble; if (lineAhead == GridLinePattern.Double)
{
if (lineToLeft == GridLinePattern.Thick || lineToRight == GridLinePattern.Thick)
return ThickOverDouble;
return -ThickUnderDouble;
}
return ThickOverDouble; return ThickOverDouble;
} }
if (VlnBorders.LineWidth(lineToLeft) == 1 && VlnBorders.LineWidth(lineToRight) == 1) if (VlnBorders.LineWidth(lineToLeft) == 1 && VlnBorders.LineWidth(lineToRight) == 1)
@ -821,25 +827,25 @@ namespace Volian.Print.Library
private static void SetLineColor(PdfContentByte cb, int row, int col, string side) private static void SetLineColor(PdfContentByte cb, int row, int col, string side)
{ {
iTextSharp.text.Color lineColor = new iTextSharp.text.Color(PrintOverride.OverrideTextColor(System.Drawing.Color.Black)); iTextSharp.text.Color lineColor = new iTextSharp.text.Color(PrintOverride.OverrideTextColor(System.Drawing.Color.Black));
switch (side) //switch (side)
{ //{
case "Top": // case "Top":
if (col == 0) lineColor = new iTextSharp.text.Color(PrintOverride.OverrideTextColor(System.Drawing.Color.Blue)); // if (col == 0) lineColor = new iTextSharp.text.Color(PrintOverride.OverrideTextColor(System.Drawing.Color.Blue));
else lineColor = new iTextSharp.text.Color(PrintOverride.OverrideTextColor(System.Drawing.Color.Cyan)); // else lineColor = new iTextSharp.text.Color(PrintOverride.OverrideTextColor(System.Drawing.Color.Cyan));
break; // break;
case "Left": // case "Left":
if (row == 0) lineColor = new iTextSharp.text.Color(PrintOverride.OverrideTextColor(System.Drawing.Color.Red)); // if (row == 0) lineColor = new iTextSharp.text.Color(PrintOverride.OverrideTextColor(System.Drawing.Color.Red));
else lineColor = new iTextSharp.text.Color(PrintOverride.OverrideTextColor(System.Drawing.Color.Magenta)); // else lineColor = new iTextSharp.text.Color(PrintOverride.OverrideTextColor(System.Drawing.Color.Magenta));
break; // break;
case "Bottom": // case "Bottom":
if (col == 0) lineColor = new iTextSharp.text.Color(PrintOverride.OverrideTextColor(System.Drawing.Color.Green)); // if (col == 0) lineColor = new iTextSharp.text.Color(PrintOverride.OverrideTextColor(System.Drawing.Color.Green));
else lineColor = new iTextSharp.text.Color(PrintOverride.OverrideTextColor(System.Drawing.Color.Cyan)); // else lineColor = new iTextSharp.text.Color(PrintOverride.OverrideTextColor(System.Drawing.Color.Cyan));
break; // break;
case "Right": // case "Right":
if (row == 0) lineColor = new iTextSharp.text.Color(PrintOverride.OverrideTextColor(System.Drawing.Color.Orange)); // if (row == 0) lineColor = new iTextSharp.text.Color(PrintOverride.OverrideTextColor(System.Drawing.Color.Orange));
else lineColor = new iTextSharp.text.Color(PrintOverride.OverrideTextColor(System.Drawing.Color.Magenta)); // else lineColor = new iTextSharp.text.Color(PrintOverride.OverrideTextColor(System.Drawing.Color.Magenta));
break; // break;
} //}
cb.SetColorStroke(lineColor); cb.SetColorStroke(lineColor);
} }
private static void InitializeLineStyle(PdfContentByte cb) private static void InitializeLineStyle(PdfContentByte cb)
@ -857,7 +863,7 @@ namespace Volian.Print.Library
} }
private static void ZoomToCell(iTextSharp.text.pdf.ColumnText myColumnText, float xLeft, float yTop, float xRight, float yBottom) private static void ZoomToCell(iTextSharp.text.pdf.ColumnText myColumnText, float xLeft, float yTop, float xRight, float yBottom)
{ {
PdfDestination dest = new PdfDestination(PdfDestination.FITR, xLeft - 4, yBottom + 4, xRight, yTop + 4); PdfDestination dest = new PdfDestination(PdfDestination.FITR, xLeft - 4, yBottom , xRight, yTop + 4);
myColumnText.Canvas.SetAction(PdfAction.GotoLocalPage(myColumnText.Canvas.PdfWriter.CurrentPageNumber, dest, myColumnText.Canvas.PdfWriter), xLeft, yBottom, xRight, yTop); myColumnText.Canvas.SetAction(PdfAction.GotoLocalPage(myColumnText.Canvas.PdfWriter.CurrentPageNumber, dest, myColumnText.Canvas.PdfWriter), xLeft, yBottom, xRight, yTop);
} }
#endregion #endregion