using System.Drawing; using iTextSharp.text.pdf; using Volian.Base.Library; namespace VG { public interface IVGOutput { float Scale { get;} int DebugStatus { get; set; } void DrawLine(Pen pn, float startx, float starty, float endx, float endy); void DrawRectangle(Pen pn, RectangleF rectf); void DrawEllipse(Pen pn, float cx, float cy, float dx, float dy); void DrawImage(Bitmap bm, RectangleF rectf); void DrawString(string text, Font myFont, Brush brush, RectangleF rectf); void DrawArc(Pen pn, RectangleF rectf, float startAngle, float sweepAngle); SizeF MeasureString(string text, Font myFont); void Save(string fileName); float FontSizeAdjust { get;} } public partial class VGOut_Graphics: IVGOutput { 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) => _VGOutput.MeasureString(text, myFont, new PointF(0, 0), StringFormat.GenericTypographic); public void Save(string fileName) { ;/* Don't do anything*/ } public float FontSizeAdjust => .71f * 96f / _VGOutput.DpiX; // Changed to adjust for Screen DPI Setting } }