AdjustBuildRevision, FlexMsgBx, Formats, LBWordLib, VlnStatus, RoAccessToSql, TablePicker, VG

This commit is contained in:
2026-07-30 08:15:47 -04:00
parent f67d37801a
commit e492f12602
25 changed files with 1159 additions and 2484 deletions
+14 -135
View File
@@ -1,10 +1,5 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using iTextSharp.text.pdf;
using iTextSharp.text.factories;
using Microsoft.Win32;
using Volian.Base.Library;
namespace VG
@@ -25,141 +20,25 @@ namespace VG
}
public partial class VGOut_Graphics: IVGOutput
{
private int _DebugStatus = 0;
public int DebugStatus
{
get { return _DebugStatus; }
set { _DebugStatus = value; }
}
private Graphics _VGOutput;
//public Graphics VGOutput
//{ get { return _VGOutput; } }
public VGOut_Graphics(Graphics vgOutput)
{ _VGOutput = vgOutput; }
public float Scale
{ get { return 1; } }
//{ get { return _VGOutput.Transform.Elements[0]; } }
public void DrawLine(Pen pn, float startx, float starty, float endx, float endy)
{ _VGOutput.DrawLine(pn, startx, starty, endx, endy); }
public void DrawRectangle(Pen pn, RectangleF rectf)
public int DebugStatus { get; set; } = 0;
private readonly Graphics _VGOutput;
public VGOut_Graphics(Graphics vgOutput) => _VGOutput = vgOutput;
public float Scale => 1;
public void DrawLine(Pen pn, float startx, float starty, float endx, float endy) => _VGOutput.DrawLine(pn, startx, starty, endx, endy);
public void DrawRectangle(Pen pn, RectangleF rectf)
{
_VGOutput.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceCopy;
_VGOutput.FillRectangle(DebugStatus == 1 ? Brushes.Transparent : Brushes.White, rectf.X, rectf.Y, rectf.Width, rectf.Height);
_VGOutput.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceOver;
_VGOutput.DrawRectangle(pn, rectf.X, rectf.Y, rectf.Width, rectf.Height);
}
public void DrawEllipse(Pen pn, float cx, float cy, float dx, float dy)
{ _VGOutput.DrawEllipse(pn, cx, cy, dx, dy); }
public void DrawImage(Bitmap bm, RectangleF rectf)
{ _VGOutput.DrawImage(bm, rectf); }
public void DrawString(string text, Font myFont, Brush brush, RectangleF rectf)
{ _VGOutput.DrawString(text, myFont, brush, rectf, StringFormat.GenericTypographic); }
public void DrawArc(Pen pn, RectangleF rectf, float startAngle, float sweepAngle)
{ _VGOutput.DrawArc(pn, rectf, startAngle, sweepAngle); }
public SizeF MeasureString(string text, Font myFont)
{ return _VGOutput.MeasureString(text, myFont, new PointF(0, 0), StringFormat.GenericTypographic); }
public void Save(string fileName)
public void DrawEllipse(Pen pn, float cx, float cy, float dx, float dy) => _VGOutput.DrawEllipse(pn, cx, cy, dx, dy);
public void DrawImage(Bitmap bm, RectangleF rectf) => _VGOutput.DrawImage(bm, rectf);
public void DrawString(string text, Font myFont, Brush brush, RectangleF rectf) => _VGOutput.DrawString(text, myFont, brush, rectf, StringFormat.GenericTypographic);
public void DrawArc(Pen pn, RectangleF rectf, float startAngle, float sweepAngle) => _VGOutput.DrawArc(pn, rectf, startAngle, sweepAngle);
public SizeF MeasureString(string text, Font myFont) => _VGOutput.MeasureString(text, myFont, new PointF(0, 0), StringFormat.GenericTypographic);
public void Save(string fileName)
{ ;/* Don't do anything*/ }
public float FontSizeAdjust
{ get { return .71f * 96f / _VGOutput.DpiX; } } // Changed to adjust for Screen DPI Setting
}
public partial class VGOut_ITextSharp : IVGOutput
{
private int _DebugStatus = 0;
public int DebugStatus
{
get { return _DebugStatus; }
set { _DebugStatus = value; }
}
private PdfContentByte _VGOutput;
//public Graphics VGOutput
//{ get { return _VGOutput; } }
public VGOut_ITextSharp(PdfContentByte vgOutput)
{ _VGOutput = vgOutput; }
public float Scale
{ get { return 1; } }
public void DrawLine(Pen pn, float startx, float starty, float endx, float endy)
{
_VGOutput.SaveState();
SetStrokeData(pn);
_VGOutput.MoveTo(startx, ScaleY(starty));
_VGOutput.LineTo(endx, ScaleY(endy));
_VGOutput.Stroke();
_VGOutput.RestoreState();
}
private void SetStrokeData(Pen pn)
{
_VGOutput.SetLineWidth(pn.Width);
_VGOutput.SetColorStroke(new iTextSharp.text.Color(pn.Color.R, pn.Color.G, pn.Color.B, pn.Color.A));
}
public void DrawRectangle(Pen pn, RectangleF rectf)
{
_VGOutput.SaveState();
SetStrokeData(pn);
_VGOutput.Rectangle(rectf.X, ScaleY(rectf.Y), rectf.Width, -rectf.Height);
_VGOutput.Stroke();
_VGOutput.RestoreState();
}
public void DrawEllipse(Pen pn, float cx, float cy, float dx, float dy)
{
_VGOutput.SaveState();
SetStrokeData(pn);
_VGOutput.Ellipse(cx, ScaleY(cy), dx, -dy);
_VGOutput.Stroke();
_VGOutput.RestoreState();
}
public void DrawImage(Bitmap bm, RectangleF rectf)
{
_VGOutput.SaveState();
// TODO: Determine how I can create an iTextSharp.text.Image
//_VGOutput.AddImage(new iTextSharp.text.Image(
_VGOutput.RestoreState();
}
public void DrawString(string text, Font myFont, Brush brush, RectangleF rectf)
{
_VGOutput.SaveState();
_VGOutput.BeginText();
iTextSharp.text.Font itFont = GetFont(myFont.Name);
iTextSharp.text.pdf.BaseFont baseFont = itFont.BaseFont;
// _VGOutput.DrawString(text, myFont, brush, rectf, StringFormat.GenericTypographic);
_VGOutput.MoveText(rectf.X, ScaleY(rectf.Y) - myFont.SizeInPoints);
_VGOutput.SetFontAndSize(baseFont, myFont.SizeInPoints);
_VGOutput.SetTextRenderingMode(PdfContentByte.TEXT_RENDER_MODE_FILL);
_VGOutput.ShowTextKerned(text);
_VGOutput.EndText();
_VGOutput.RestoreState();
}
public void DrawArc(Pen pn, RectangleF rectf, float startAngle, float sweepAngle)
{
_VGOutput.SaveState();
SetStrokeData(pn);
_VGOutput.Arc(rectf.X, ScaleY(rectf.Y), rectf.X + rectf.Width, ScaleY(rectf.Y + rectf.Height), -startAngle, -sweepAngle);
_VGOutput.Stroke();
_VGOutput.RestoreState();
}
public SizeF MeasureString(string text, Font myFont)
{
iTextSharp.text.Font itFont = GetFont(myFont.Name);
iTextSharp.text.pdf.BaseFont baseFont = itFont.BaseFont;
return new SizeF(baseFont.GetWidthPoint(text,myFont.SizeInPoints)
, baseFont.GetAscentPoint(text, myFont.SizeInPoints) + baseFont.GetDescentPoint(text, myFont.SizeInPoints));
}
public void Save(string fileName)
{ ;/* Don't do anything*/ }
public float FontSizeAdjust
{ get { return 1; } } // Changed to adjust for Screen DPI Setting
public static iTextSharp.text.Font GetFont(string fontName)
{
/// <summary>
/// B2019-116 Volian.Base.Library This is a generic class for dealing with iTextSharp Fonts
/// Code moved and consolidated from Volian.Print.Library Volian PDF.Library and VG
/// </summary>
VlnItextFont.RegisterFont(fontName);
return iTextSharp.text.FontFactory.GetFont(fontName, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
}
private float ScaleY(float y)
{
return _VGOutput.PdfWriter.PageSize.Height - y;
}
}
public float FontSizeAdjust => .71f * 96f / _VGOutput.DpiX; // Changed to adjust for Screen DPI Setting
}
}
+39 -168
View File
@@ -20,64 +20,34 @@ namespace VG
// Temporary page class to store portrait/landscape, Left Margin, Vertical offset, etc
public class Page
{
private bool _Portrait = true;
public bool Portrait
public bool Portrait { get; set; } = true;
public float LeftMargin { get; set; } = 0;
public float TopMargin { get; set; } = 0;
public float RightMargin { get; set; } = 0;
public float BottomMargin { get; set; } = 0;
public Page(bool portrait, float leftMargin, float topMargin, float rightMargin, float bottomMargin)
{
get { return _Portrait; }
set { _Portrait = value; }
}
private float _LeftMargin = 0;
public float LeftMargin
{
get { return _LeftMargin; }
set { _LeftMargin = value; }
}
private float _TopMargin = 0;
public float TopMargin
{
get { return _TopMargin; }
set { _TopMargin = value; }
}
private float _RightMargin = 0;
public float RightMargin
{
get { return _RightMargin; }
set { _RightMargin = value; }
}
private float _BottomMargin = 0;
public float BottomMargin
{
get { return _BottomMargin; }
set { _BottomMargin = value; }
}
public Page(bool portrait, float leftMargin, float topMargin, float rightMargin, float bottomMargin)
{
_Portrait = portrait;
_LeftMargin = leftMargin;
_TopMargin = topMargin;
_RightMargin = rightMargin;
_BottomMargin = bottomMargin;
Portrait = portrait;
LeftMargin = leftMargin;
TopMargin = topMargin;
RightMargin = rightMargin;
BottomMargin = bottomMargin;
}
public Page(bool portrait, float leftMargin, float topMargin)
{
_Portrait = portrait;
_LeftMargin = leftMargin;
_TopMargin = topMargin;
Portrait = portrait;
LeftMargin = leftMargin;
TopMargin = topMargin;
}
}
public class VG
{
private static Brush _BlackBrush = Brushes.Black;
public static Brush BlackBrush
{
get { return _BlackBrush; }
set { _BlackBrush = value; }
}
private static Color _BlackColor = Color.Black;
public static Brush BlackBrush { get; set; } = Brushes.Black;
private static Color _BlackColor = Color.Black;
public static Color BlackColor
{
get { return _BlackColor; }
set { _BlackColor = value; _BlackBrush = new SolidBrush(value); }
set { _BlackColor = value; BlackBrush = new SolidBrush(value); }
}
// Values of vector graphics items are stored as twips (1440 twips in an inch)
public int cx;
@@ -105,16 +75,12 @@ namespace VG
MoveAbsolute = ima;
pg = ipg;
}
public float ToPoints(float twip)
{
float r = ((float)twip) * 0.05f;
return r;
}
public void UpdatePageInfo(Page pa)
public float ToPoints(float twip) => (float)(((float)twip) * 0.05f);
public void UpdatePageInfo(Page pa)
{
pg.LeftMargin = pa.LeftMargin;
pg.Portrait = pa.Portrait; // RHM 20081003 - This had been pg.portrait=pg.portrait
pg.TopMargin = pa.TopMargin; // RHM 20081003 - This had been pg.VertOffset=pg.VertOffset
pg.Portrait = pa.Portrait;
pg.TopMargin = pa.TopMargin;
}
public string AddRTFBUI(string origStr, string bold, string underline, string italics)
{
@@ -145,7 +111,6 @@ namespace VG
int B1 = (int)(colorFraction * color.B);
int B2 = (int)((1 - colorFraction) * Color.White.B);
pn = new Pen(Color.FromArgb(R1 + R2, G1 + G2, B1 + B2), scaleWid);
//pn = new Pen(color, wid*wid);
}
else
pn = new Pen(color, scaleWid);
@@ -217,74 +182,14 @@ namespace VG
vgOutput.DrawRectangle(pn, rc);
}
}
public class VG_Image : VG
{
private int Scale;
private string FileName;
// Image is defined as starting point, scale factor (defaults to 1) & image file name
public VG_Image(int sx, int sy, int iscale, string fname)
{
cx = sx;
cy = sy;
Scale = 1;
FileName = fname;
}
public VG_Image(XmlElement svg, Page ipg)
{
cx = System.Convert.ToInt32(svg.GetAttribute("x"));
cy = System.Convert.ToInt32(svg.GetAttribute("y"));
Scale = 1;
if (svg.HasAttribute("scale")) Scale = System.Convert.ToInt32(svg.GetAttribute("scale"));
FileName = svg.GetAttribute("bname");
pg = ipg;
}
public void Draw(IVGOutput vgOutput)
{
Pen pn = new Pen(VG.BlackBrush, lnwid);
Bitmap bm = new Bitmap(FileName);
RectangleF rc = new RectangleF();
rc.Height = ToPoints((bm.Height * Scale) * 4.8f);
rc.Width = ToPoints((bm.Width * Scale) * 4.8f);
rc.X = ToPoints(pg.LeftMargin + cx);
rc.Y = ToPoints(pg.TopMargin + cy);
// TODO: grfx.DrawImage(bm, rc, ContentAlignment.MiddleCenter, ImageSizeModeEnum.Scale);
}
}
public class VG_Ellipse : VG
{
// Ellipse (circle) is defined by a bounding rectangle specified by a coordinate pair, a width, and a height
public VG_Ellipse(int sx, int sy, int ex, int ey, int w, Page ipg)
{
cx = sx;
cy = sy;
dx = ex;
dy = ey;
lnwid = w;
pg = ipg;
}
public VG_Ellipse(XmlElement svg, Page ipg)
{
cx = System.Convert.ToInt32(svg.GetAttribute("cx"));
cy = System.Convert.ToInt32(svg.GetAttribute("cy"));
dx = System.Convert.ToInt32(svg.GetAttribute("rx"));
dy = System.Convert.ToInt32(svg.GetAttribute("ry"));
lnwid = System.Convert.ToInt32(svg.GetAttribute("stroke-width"));
pg = ipg;
}
public void Draw(IVGOutput vgOutput)
{
Pen pn = new Pen(VG.BlackBrush, ToPoints(lnwid));
vgOutput.DrawEllipse(pn, ToPoints(pg.LeftMargin + cx), ToPoints(pg.TopMargin + cy), ToPoints(dx), ToPoints(dy));
}
}
public class VG_Text : VG
{
private string FontName;
private int FontSize;
private string Bold;
private string Underline;
private string Italics;
private string Text;
private readonly string FontName;
private readonly int FontSize;
private readonly string Bold;
private readonly string Underline;
private readonly string Italics;
private readonly string Text;
// Text is defined by a starting location, attributes & the string
public VG_Text(int sx, int sy, int fs, string txt, string fn, string ibold, string iunder, string iitalics, Page ipg)
{
@@ -297,48 +202,28 @@ namespace VG
Underline = iunder;
Italics = iitalics;
pg = ipg;
// TODO: The following were in the 16-bit code - we may need to use these, wait and see
// strokeWidth = stroke;
// strokeWidthBold = strokebold;
// ULOffset = UnderlineOffset;
// ULWidth = UnderlineWidth;
}
public VG_Text(XmlElement svg, Page ipg)
{
cx = System.Convert.ToInt32(svg.GetAttribute("x"));
cy = System.Convert.ToInt32(svg.GetAttribute("y"));
FontSize = System.Convert.ToInt32(svg.GetAttribute("font-size"));
Bold = svg.GetAttribute("font-weight");
Underline = svg.GetAttribute("text-decoration");
Italics = svg.GetAttribute("font-style");
FontName = svg.GetAttribute("font-family");
Text = svg.InnerText;
pg = ipg;
}
public void Draw(IVGOutput vgOutput)
{
// TODO: Font myfont = new Font(FontName, (FontSize*9)/10);
Font myfont = new Font(FontName, FontSize * vgOutput.FontSizeAdjust); // TODO: Trying 80%
RectangleF rc = new RectangleF();
// the returned value from c1 grfx code is already in points,
// so need to convert the size.
rc.Size = vgOutput.MeasureString(Text, myfont); // TODO: 500 or pagewidth, or what
//rc.Size = grfx.MeasureString(Text, myfont, 500); // TODO: 500 or pagewidth, or what
rc.X = ToPoints(pg.LeftMargin + cx);
rc.Y = ToPoints(pg.TopMargin + cy) - FontSize;
rc.Height *= 1.0000001F; // Small factor to make text visible.
// add bold, underline & italics for entire object.
// TODO: string rtfout = AddRTFBUI(Text, Bold, Underline, Italics);
//using(Pen pn = new Pen(Color.DarkBlue, .1F))
// grfx.DrawRectangle(pn, rc.X,rc.Y,rc.Width,rc.Height);
RectangleF rc = new RectangleF
{
// the returned value from c1 grfx code is already in points,
// so need to convert the size.
Size = vgOutput.MeasureString(Text, myfont), // TODO: 500 or pagewidth, or what
//rc.Size = grfx.MeasureString(Text, myfont, 500); // TODO: 500 or pagewidth, or what
X = ToPoints(pg.LeftMargin + cx),
Y = ToPoints(pg.TopMargin + cy) - FontSize
};
rc.Height *= 1.0000001F; // Small factor to make text visible.
vgOutput.DrawString(Text, myfont, VG.BlackBrush, rc);
//grfx.DrawString(Text, myfont, VG.BlackBrush, rc);
}
}
public class VG_Arc : VG
{
public Single sweepAngle;
public Single startAngle;
public float sweepAngle;
public float startAngle;
public float stX, stY;
public float rWid, rHgt;
// Arc is defined by a bounding rectangle specified by a coordinate pair, a width, and a height
@@ -365,9 +250,7 @@ namespace VG
rHgt = -hight;
}
startAngle = stAngle;
// startAngle = 90;
sweepAngle = swpAngle;
// sweepAngle = -45;
lnwid = w;
pg = ipg;
}
@@ -391,18 +274,6 @@ namespace VG
float starty = pg.Portrait ? (stY + pg.TopMargin) : (pg.LeftMargin - stX);
RectangleF rc = new RectangleF(ToPoints(startx), ToPoints(starty), ToPoints(rWid), ToPoints(rHgt));
//Console.WriteLine("{0},'{1}',{2},{3},{4},{5},{6},{7}", iColor, pn.Color, rc.X, rc.Y, rc.Width, rc.Height, startAngle, sweepAngle);
//if (iColor == 7 || iColor == 8) return;
//if (iColor == 6) return;
//if (iColor == 4 || iColor == 6)
//{
// using (Pen lightPen = new Pen(myColors[iColor % myColors.Length], .01F))
//{
// vgOutput.DrawEllipse(lightPen, rc.X, rc.Y, rc.Width, rc.Height);
// float xc = rc.X + (rc.Width / 2);
// float yc = rc.Y + (rc.Height / 2);
// vgOutput.DrawEllipse(lightPen, xc - .5F, yc - .5F, 1F, 1F);
//}
//}
if (sweepAngle > 0)
vgOutput.DrawArc(pn, rc, startAngle, sweepAngle);
else