Print Library, Svg Library, Utils Library, XYPlots

This commit is contained in:
2026-07-24 13:36:46 -04:00
parent 06c3136566
commit f67d37801a
68 changed files with 12173 additions and 16618 deletions
-30
View File
@@ -1,30 +0,0 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using Microsoft.Win32;
namespace Volian.Svg.Library
{
//public static class FontFind
//{
// public static string FileName(string fontName)
// {
// string baseFont = string.Empty;
// Regex find = new Regex(fontName + @".* ?\(.*\)", RegexOptions.IgnoreCase);
// RegistryKey regKey = Registry.LocalMachine.CreateSubKey(@"Software\Microsoft\Windows NT\CurrentVersion\Fonts");
// string[] values = regKey.GetValueNames();
// baseFont = regKey.GetValue(values[0]).ToString();
// foreach (string valueName in regKey.GetValueNames())
// {
// if (find.IsMatch(valueName))
// return regKey.GetValue(valueName).ToString();
// }
// return baseFont;
// }
// public static string FullFileName(string fontName)
// {
// return @"c:\windows\fonts\" + FileName(fontName);
// }
//}
}
+3 -32
View File
@@ -17,13 +17,6 @@ namespace Volian.Svg.Library
}
public partial class Svg : SvgGroup
{
public void Draw(Graphics graphics)
{
//SetupInheritance();
//Console.WriteLine("{0}, DPI {1}", graphics.VisibleClipBounds, graphics.DpiX);
SvgParts.Draw(graphics, new SvgScale(DeviceDPI(graphics), graphics.VisibleClipBounds, _Width, _Height, _ViewBox), this, this);
//SvgParts.Draw(graphics, new SvgScale(100, graphics.VisibleClipBounds, _Width, _Height, _ViewBox));
}
public static float DeviceDPI(Graphics g)
{
PointF[] tmp = { new PointF(g.DpiX, g.DpiY) };
@@ -36,7 +29,6 @@ namespace Volian.Svg.Library
public override void Draw(System.Drawing.Graphics graphics, SvgScale scale, Svg mySvg, SvgPartInheritance myParent)
{
SetupInheritance(myParent.MyInheritedSettings);
//_MyLineSettings.Scale = scale.M(1F);
if (FillColor != Color.Transparent)
using (Brush brush = new SolidBrush(FillColor))
graphics.FillEllipse(brush, scale.X(CX - Radius), scale.Y(CY - Radius), scale.M(Radius * 2), scale.M(Radius * 2));
@@ -50,7 +42,6 @@ namespace Volian.Svg.Library
public override void Draw(System.Drawing.Graphics graphics, SvgScale scale, Svg mySvg, SvgPartInheritance myParent)
{
SetupInheritance(myParent.MyInheritedSettings);
//_MyLineSettings.Scale = scale.M(1F);
if (FillColor != Color.Transparent)
using (Brush brush = new SolidBrush(FillColor))
graphics.FillEllipse(brush, scale.X(CX - Radius), scale.Y(CY - Radius), scale.M(Radius * 2), scale.M(Radius * 2));
@@ -64,7 +55,6 @@ namespace Volian.Svg.Library
public override void Draw(Graphics graphics, SvgScale myScale, Svg mySvg, SvgPartInheritance myParent)
{
// Don't draw
//_SvgParts.Draw(graphics, myScale);
}
}
public partial class SvgEllipse : SvgShapePart
@@ -85,7 +75,7 @@ namespace Volian.Svg.Library
public override void Draw(Graphics graphics, SvgScale myScale, Svg mySvg, SvgPartInheritance myParent)
{
SetupInheritance(myParent.MyInheritedSettings);
_SvgParts.Draw(graphics, myScale, mySvg, this);
SvgParts.Draw(graphics, myScale, mySvg, this);
}
}
public partial class SvgImage : SvgPart
@@ -130,26 +120,9 @@ namespace Volian.Svg.Library
graphics.DrawRectangle(pen, scale.X(X),scale.Y(Y), scale.M(Width), scale.M(Height));
}
}
//public partial class SvgRtf : SvgShapePart
//{
// //private static float _Factor = 1.085F; // 20 point Arial Font
// public override void Draw(System.Drawing.Graphics graphics, SvgScale scale, Svg mySvg, SvgPartInheritance myParent)
// {
// SetupInheritance(myParent.MyInheritedSettings);
// _MyFontSettings.Scale = scale.M(1F);
// }
// private float YAdjustment(Graphics gr, Font fnt)
// {
// int yAsc = fnt.FontFamily.GetCellAscent(fnt.Style);
// int yLS = fnt.FontFamily.GetLineSpacing(fnt.Style);
// float gth = fnt.GetHeight(gr);
// float fAsc = (yAsc * gth) / yLS;
// return -fAsc;
// }
//}
public partial class SvgText : SvgShapePart
{
//private static float _Factor = 1.085F; // 20 point Arial Font
public override void Draw(System.Drawing.Graphics graphics, SvgScale scale, Svg mySvg, SvgPartInheritance myParent)
{
SetupInheritance(myParent.MyInheritedSettings);
@@ -175,8 +148,6 @@ namespace Volian.Svg.Library
private float YAdjustment(Graphics gr, Font fnt)
{
int yAsc = fnt.FontFamily.GetCellAscent(fnt.Style);
//int yDesc = fnt.FontFamily.GetCellDescent(fnt.Style);
//int yEm = fnt.FontFamily.GetEmHeight(fnt.Style);
int yLS = fnt.FontFamily.GetLineSpacing(fnt.Style);
float gth = fnt.GetHeight(gr);
float fh = fnt.Size;
@@ -189,7 +160,7 @@ namespace Volian.Svg.Library
public override void Draw(System.Drawing.Graphics graphics, SvgScale scale, Svg mySvg, SvgPartInheritance myParent)
{
SetupInheritance(myParent.MyInheritedSettings);
mySvg[_UseID.Substring(1)].Draw(graphics, scale.AdjustOrigin(X, Y), mySvg, this);
mySvg[UseID.Substring(1)].Draw(graphics, scale.AdjustOrigin(X, Y), mySvg, this);
}
}
}
+21 -61
View File
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Serialization;
using System.ComponentModel;
@@ -37,84 +35,46 @@ namespace Volian.Svg.Library
}
set { _Namespaces = value; }
}
#endregion
#region Width
private SvgMeasurement _Width = new SvgMeasurement();
[XmlIgnore]
public SvgMeasurement Width
{
get { return _Width; }
set { _Width = value; }
}
[System.ComponentModel.DefaultValueAttribute("0")]
#endregion
#region Width
[XmlIgnore]
public SvgMeasurement Width { get; set; } = new SvgMeasurement();
[System.ComponentModel.DefaultValueAttribute("0")]
[XmlAttribute("width")]
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
public string Width_XmlSurrogate
{
get { return SvgXmlConverter<SvgMeasurement>.GetString(_Width); }
set { _Width = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
get { return SvgXmlConverter<SvgMeasurement>.GetString(Width); }
set { Width = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
}
//private string _Watermark="";
//[XmlAttribute("watermark")]
//public string Watermark
//{
// get { return _Watermark; }
// set { _Watermark = value; }
//}
//public void SetValidWaterMark(string token, string watermark)
//{
// if (token == "{" + watermark.ToUpper() + "PAGE}" )
// _Watermark = watermark;
//}
#endregion
#region Height
private SvgMeasurement _Height = new SvgMeasurement();
[XmlIgnore]
public SvgMeasurement Height
{
get { return _Height; }
set { _Height = value; }
}
[System.ComponentModel.DefaultValueAttribute("0")]
#endregion
#region Height
[XmlIgnore]
public SvgMeasurement Height { get; set; } = new SvgMeasurement();
[System.ComponentModel.DefaultValueAttribute("0")]
[XmlAttribute("height")]
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
public string Height_XmlSurrogate
{
get { return SvgXmlConverter<SvgMeasurement>.GetString(_Height); }
set { _Height = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
get { return SvgXmlConverter<SvgMeasurement>.GetString(Height); }
set { Height = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
}
#endregion
#region ViewBox
private SvgViewBox _ViewBox = new SvgViewBox("0 0 0 0");
[XmlIgnore]
public SvgViewBox ViewBox
{
get { return _ViewBox; }
set { _ViewBox = value; }
}
[System.ComponentModel.DefaultValueAttribute("0 0 0 0")]
#endregion
#region ViewBox
[XmlIgnore]
public SvgViewBox ViewBox { get; set; } = new SvgViewBox("0 0 0 0");
[System.ComponentModel.DefaultValueAttribute("0 0 0 0")]
[XmlAttribute("viewBox")]
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
public string SVGViewBox_XmlSurrogate
{
get { return SvgXmlConverter<SvgViewBox>.GetString(_ViewBox); }
set { _ViewBox = SvgXmlConverter<SvgViewBox>.GetObject(value); }
get { return SvgXmlConverter<SvgViewBox>.GetString(ViewBox); }
set { ViewBox = SvgXmlConverter<SvgViewBox>.GetObject(value); }
}
#endregion
//#region Setup Inheritance
//private void SetupInheritance()
//{
// SvgParts.SetupInheritance(_MyInheritedSettings);
//}
////override internal void SetupInheritance(SvgInheritedSettings myParentsSettings)
////{
//// _MyInheritedSettings.MyParentsSettings = myParentsSettings;
//// SvgParts.SetupInheritance(_MyInheritedSettings);
////}
//#endregion
#region Part Lookup
private Dictionary<string, SvgPart> _LookUp;
[XmlIgnore]
+23 -43
View File
@@ -1,6 +1,3 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Serialization;
using System.ComponentModel;
using System.Drawing;
@@ -13,65 +10,48 @@ namespace Volian.Svg.Library
public SvgArc() { ;}
public SvgArc(PointF location, float radius, float startAngle, float endAngle, Color fillColor, Color lineColor, float lineWidth)
{
_CX.Value = location.X;
_CY.Value = location.Y;
_Radius.Value = radius;
CX.Value = location.X;
CY.Value = location.Y;
Radius.Value = radius;
FillColor = fillColor;
LineColor = lineColor;
LineWidth = new SvgMeasurement(lineWidth);
}
//XMLElementAttribute(ElementName = "PREFIX", IsNullable = false)
#endregion
#region Location
private SvgMeasurement _CX = new SvgMeasurement();
[XmlIgnore]
public SvgMeasurement CX
{
get { return _CX; }
set { _CX = value; }
}
[XmlAttribute("cx")]
#endregion
#region Location
[XmlIgnore]
public SvgMeasurement CX { get; set; } = new SvgMeasurement();
[XmlAttribute("cx")]
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
public string CX_XmlSurrogate
{
get { return SvgXmlConverter<SvgMeasurement>.GetString(_CX); }
set { _CX = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
get { return SvgXmlConverter<SvgMeasurement>.GetString(CX); }
set { CX = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
}
private SvgMeasurement _CY = new SvgMeasurement();
[XmlIgnore]
public SvgMeasurement CY
{
get { return _CY; }
set { _CY = value; }
}
[XmlAttribute("cy")]
[XmlIgnore]
public SvgMeasurement CY { get; set; } = new SvgMeasurement();
[XmlAttribute("cy")]
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
public string CY_XmlSurrogate
{
get { return SvgXmlConverter<SvgMeasurement>.GetString(_CY); }
set { _CY = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
get { return SvgXmlConverter<SvgMeasurement>.GetString(CY); }
set { CY = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
}
#endregion
#region Radius
private SvgMeasurement _Radius = new SvgMeasurement();
[XmlIgnore]
public SvgMeasurement Radius
{
get { return _Radius; }
set { _Radius = value; }
}
[XmlAttribute("r")]
#endregion
#region Radius
[XmlIgnore]
public SvgMeasurement Radius { get; set; } = new SvgMeasurement();
[XmlAttribute("r")]
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
public string X_XmlSurrogate
{
get { return SvgXmlConverter<SvgMeasurement>.GetString(_Radius); }
set { _Radius = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
get { return SvgXmlConverter<SvgMeasurement>.GetString(Radius); }
set { Radius = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
}
#endregion
#region Angles
#endregion
}
}
+23 -41
View File
@@ -1,6 +1,3 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Serialization;
using System.ComponentModel;
using System.Drawing;
@@ -13,62 +10,47 @@ namespace Volian.Svg.Library
public SvgCircle() { ;}
public SvgCircle(PointF location, float radius, Color fillColor, Color lineColor, float lineWidth)
{
_CX.Value = location.X;
_CY.Value = location.Y;
_Radius.Value = radius;
CX.Value = location.X;
CY.Value = location.Y;
Radius.Value = radius;
FillColor = fillColor;
LineColor = lineColor;
LineWidth = new SvgMeasurement(lineWidth);
}
//XMLElementAttribute(ElementName = "PREFIX", IsNullable = false)
#endregion
#region Location
private SvgMeasurement _CX = new SvgMeasurement();
[XmlIgnore]
public SvgMeasurement CX
{
get { return _CX; }
set { _CX = value; }
}
[XmlAttribute("cx")]
#endregion
#region Location
[XmlIgnore]
public SvgMeasurement CX { get; set; } = new SvgMeasurement();
[XmlAttribute("cx")]
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
public string CX_XmlSurrogate
{
get { return SvgXmlConverter<SvgMeasurement>.GetString(_CX); }
set { _CX = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
get { return SvgXmlConverter<SvgMeasurement>.GetString(CX); }
set { CX = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
}
private SvgMeasurement _CY = new SvgMeasurement();
[XmlIgnore]
public SvgMeasurement CY
{
get { return _CY; }
set { _CY = value; }
}
[XmlAttribute("cy")]
[XmlIgnore]
public SvgMeasurement CY { get; set; } = new SvgMeasurement();
[XmlAttribute("cy")]
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
public string CY_XmlSurrogate
{
get { return SvgXmlConverter<SvgMeasurement>.GetString(_CY); }
set { _CY = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
get { return SvgXmlConverter<SvgMeasurement>.GetString(CY); }
set { CY = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
}
#endregion
#region Radius
private SvgMeasurement _Radius = new SvgMeasurement();
[XmlIgnore]
public SvgMeasurement Radius
{
get { return _Radius; }
set { _Radius = value; }
}
[XmlAttribute("r")]
#endregion
#region Radius
[XmlIgnore]
public SvgMeasurement Radius { get; set; } = new SvgMeasurement();
[XmlAttribute("r")]
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
public string X_XmlSurrogate
{
get { return SvgXmlConverter<SvgMeasurement>.GetString(_Radius); }
set { _Radius = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
get { return SvgXmlConverter<SvgMeasurement>.GetString(Radius); }
set { Radius = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
}
#endregion
}
-7
View File
@@ -1,10 +1,3 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Serialization;
using System.ComponentModel;
using System.Drawing;
namespace Volian.Svg.Library
{
public partial class SvgDefine : SvgGroup
+30 -52
View File
@@ -1,6 +1,3 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Serialization;
using System.ComponentModel;
using System.Drawing;
@@ -13,78 +10,59 @@ namespace Volian.Svg.Library
public SvgEllipse() { ;}
public SvgEllipse(PointF location, float radiusX, float radiusY, Color fillColor, Color lineColor, float lineWidth)
{
_CX.Value = location.X;
_CY.Value = location.Y;
_RX.Value = radiusX;
_RY.Value = radiusY;
CX.Value = location.X;
CY.Value = location.Y;
RX.Value = radiusX;
RY.Value = radiusY;
FillColor = fillColor;
LineColor = lineColor;
LineWidth = new SvgMeasurement(lineWidth);
}
//XMLElementAttribute(ElementName = "PREFIX", IsNullable = false)
#endregion
#region Location
private SvgMeasurement _CX = new SvgMeasurement();
[XmlIgnore]
public SvgMeasurement CX
{
get { return _CX; }
set { _CX = value; }
}
[XmlAttribute("cx")]
#endregion
#region Location
[XmlIgnore]
public SvgMeasurement CX { get; set; } = new SvgMeasurement();
[XmlAttribute("cx")]
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
public string CX_XmlSurrogate
{
get { return SvgXmlConverter<SvgMeasurement>.GetString(_CX); }
set { _CX = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
get { return SvgXmlConverter<SvgMeasurement>.GetString(CX); }
set { CX = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
}
private SvgMeasurement _CY = new SvgMeasurement();
[XmlIgnore]
public SvgMeasurement CY
{
get { return _CY; }
set { _CY = value; }
}
[XmlAttribute("cy")]
[XmlIgnore]
public SvgMeasurement CY { get; set; } = new SvgMeasurement();
[XmlAttribute("cy")]
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
public string CY_XmlSurrogate
{
get { return SvgXmlConverter<SvgMeasurement>.GetString(_CY); }
set { _CY = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
get { return SvgXmlConverter<SvgMeasurement>.GetString(CY); }
set { CY = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
}
#endregion
#region Size
private SvgMeasurement _RX = new SvgMeasurement();
[XmlIgnore]
public SvgMeasurement RX
{
get { return _RX; }
set { _RX = value; }
}
[XmlAttribute("rx")]
#endregion
#region Size
[XmlIgnore]
public SvgMeasurement RX { get; set; } = new SvgMeasurement();
[XmlAttribute("rx")]
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
public string RX_RXmlSurrogate
{
get { return SvgXmlConverter<SvgMeasurement>.GetString(_RX); }
set { _RX = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
get { return SvgXmlConverter<SvgMeasurement>.GetString(RX); }
set { RX = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
}
private SvgMeasurement _RY = new SvgMeasurement();
[XmlIgnore]
public SvgMeasurement RY
{
get { return _RY; }
set { _RY = value; }
}
[XmlAttribute("ry")]
[XmlIgnore]
public SvgMeasurement RY { get; set; } = new SvgMeasurement();
[XmlAttribute("ry")]
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
public string RY_XmlSurrogate
{
get { return SvgXmlConverter<SvgMeasurement>.GetString(_RY); }
set { _RY = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
get { return SvgXmlConverter<SvgMeasurement>.GetString(RY); }
set { RY = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
}
#endregion
}
+16 -43
View File
@@ -1,6 +1,3 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
namespace Volian.Svg.Library
@@ -9,34 +6,18 @@ namespace Volian.Svg.Library
{
#region ctor
public SvgFillSettings() { ;}
public SvgFillSettings(Color myColor)
{
_Fill = ColorTranslator.ToHtml(myColor);
}
//public SvgFillSettings(string myFill)
//{
// _Fill = myFill;
//}
#endregion
#region Inheritance
private SvgFillSettings _MyParentsSettings = null;
public SvgFillSettings MyParentsSettings
{
get { return _MyParentsSettings; }
set
{
_MyParentsSettings = value;
}
}
#endregion
#region Internal Inherited Properties
protected string InheritedFill
public SvgFillSettings(Color myColor) => Fill = ColorTranslator.ToHtml(myColor);
#endregion
#region Inheritance
public SvgFillSettings MyParentsSettings { get; set; } = null;
#endregion
#region Internal Inherited Properties
protected string InheritedFill
{
get
{
// Fill = "", "0" - Default, otherwise the value
if (_Fill != "" && _Fill != "0" && _Fill.ToLower() != "empty") return _Fill; // Current Value
if (_MyParentsSettings != null) return _MyParentsSettings.InheritedFill; // Inherited
if (Fill != "" && Fill != "0" && Fill.ToLower() != "empty") return Fill; // Current Value
if (MyParentsSettings != null) return MyParentsSettings.InheritedFill; // Inherited
return "Black"; // Default
}
}
@@ -54,20 +35,12 @@ namespace Volian.Svg.Library
}
set
{
if (value == Color.Transparent || value == Color.Empty)
_Fill = "none";
else
_Fill = ColorTranslator.ToHtml(value);
}
Fill = value == Color.Transparent || value == Color.Empty ? "none" : ColorTranslator.ToHtml(value);
}
}
#endregion
#region Properties
private string _Fill = string.Empty; // Default value is None
public string Fill
{
get { return _Fill; }
set { _Fill = value; }
}
#endregion
}
#endregion
#region Properties
public string Fill { get; set; } = string.Empty;
#endregion
}
}
+11 -37
View File
@@ -1,6 +1,3 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
namespace Volian.Svg.Library
@@ -17,33 +14,17 @@ namespace Volian.Svg.Library
_FontWeight = ((myFont.Style & FontStyle.Bold) == FontStyle.Bold ? "bold" : "normal");
_TextDecoration = ((myFont.Style & FontStyle.Underline) == FontStyle.Underline ? "underline" : "normal");
}
//public SvgFontSettings(string myFontFamily, string myFontSize, string mySvgStyle, string myFontWeight, string myTextDecoration)
//{
// _FontFamilyName = myFontFamily;
// _FontSize = myFontSize;
// _SVGFontStyle = mySvgStyle;
// _FontWeight = myFontWeight;
// _TextDecoration = myTextDecoration;
//}
#endregion
#region Inheritance
private SvgFontSettings _MyParentsSettings = null;
public SvgFontSettings MyParentsSettings
{
get { return _MyParentsSettings; }
set
{
_MyParentsSettings = value;
}
}
#endregion
#region Internal Inherited Properties
protected string InheritedFontFamily
#endregion
#region Inheritance
public SvgFontSettings MyParentsSettings { get; set; } = null;
#endregion
#region Internal Inherited Properties
protected string InheritedFontFamily
{
get
{
if (_FontFamily != "") return _FontFamily;
if (_MyParentsSettings != null) return _MyParentsSettings.InheritedFontFamily; // Default
if (MyParentsSettings != null) return MyParentsSettings.InheritedFontFamily; // Default
return "Arial"; // Absolute Default
}
}
@@ -52,7 +33,7 @@ namespace Volian.Svg.Library
get
{
if (_FontSize != "") return _FontSize; // Current Value
if (_MyParentsSettings != null) return _MyParentsSettings.InheritedFontSize; // Default
if (MyParentsSettings != null) return MyParentsSettings.InheritedFontSize; // Default
return "9PT"; // Absolute Default
}
}
@@ -61,7 +42,7 @@ namespace Volian.Svg.Library
get
{
if (_SVGFontStyle != "") return _SVGFontStyle; // Current Value
if (_MyParentsSettings != null) return _MyParentsSettings.InheritedFontStyle;// Default
if (MyParentsSettings != null) return MyParentsSettings.InheritedFontStyle;// Default
return "normal"; // Absolute Default
}
}
@@ -70,7 +51,7 @@ namespace Volian.Svg.Library
get
{
if (_FontWeight != "") return _FontWeight;// Current Value
if (_MyParentsSettings != null) return _MyParentsSettings.InheritedFontWeight;// Default
if (MyParentsSettings != null) return MyParentsSettings.InheritedFontWeight;// Default
return "normal"; // Absolute Default
}
}
@@ -79,7 +60,7 @@ namespace Volian.Svg.Library
get
{
if (_TextDecoration != "") return _TextDecoration;// Current Value
if (_MyParentsSettings != null) return _MyParentsSettings.InheritedTextDecoration;// Default
if (MyParentsSettings != null) return MyParentsSettings.InheritedTextDecoration;// Default
return "normal"; // Absolute Default
}
}
@@ -110,13 +91,6 @@ namespace Volian.Svg.Library
}
set
{
// This was disposing fonts that are saved in our static dictionary.
// caused problems with the step editor display after printing (found with Wolf Creek Chem procedure RW-G02 Step 6.1.17) - jsj 7/14/2017
//if (_Font != null)
//{
// Console.WriteLine("font dispose {0}, {1}", _Font, _Font.Style);
// //_Font.Dispose();
//}
if (value != null)
{
_FontFamily = value.FontFamily.Name;
+33 -60
View File
@@ -1,75 +1,48 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Serialization;
using System.ComponentModel;
using System.Drawing;
namespace Volian.Svg.Library
{
public partial class SvgGroup : SvgPartInheritance
{
#region Description
private string _Description = string.Empty;
[System.ComponentModel.DefaultValueAttribute("")]
[XmlElement("desc")]
public string Description
#region Description
[System.ComponentModel.DefaultValueAttribute("")]
[XmlElement("desc")]
public string Description { get; set; } = string.Empty;
#endregion
#region Title
[System.ComponentModel.DefaultValueAttribute("")]
[XmlElement("title")]
public string Title { get; set; } = string.Empty;
#endregion
#region Parts
// SVG Parts
[XmlElement("use", typeof(SvgUse))]
[XmlElement("image", typeof(SvgImage))]
[XmlElement("text", typeof(SvgText))]
[XmlElement("line", typeof(SvgLine))]
[XmlElement("circle", typeof(SvgCircle))]
[XmlElement("rect", typeof(SvgRectangle))]
[XmlElement("ellipse", typeof(SvgEllipse))]
[XmlElement("svg", typeof(Svg))]
[XmlElement("g", typeof(SvgGroup))]
[XmlElement("defs", typeof(SvgDefine))]
public SvgParts SvgParts { get; set; } = new SvgParts();
public SvgPart Add(SvgPart svgPart)
{
get { return _Description; }
set { _Description = value; }
}
#endregion
#region Title
private string _Title = string.Empty;
[System.ComponentModel.DefaultValueAttribute("")]
[XmlElement("title")]
public string Title
{
get { return _Title; }
set { _Title = value; }
}
#endregion
#region Parts
// SVG Parts
SvgParts _SvgParts = new SvgParts();
//[XmlElement("foreignObject", typeof(SvgRtf))]
[XmlElement("use", typeof(SvgUse))]
[XmlElement("image", typeof(SvgImage))]
[XmlElement("text", typeof(SvgText))]
[XmlElement("line", typeof(SvgLine))]
[XmlElement("circle", typeof(SvgCircle))]
[XmlElement("rect", typeof(SvgRectangle))]
[XmlElement("ellipse", typeof(SvgEllipse))]
[XmlElement("svg", typeof(Svg))]
[XmlElement("g", typeof(SvgGroup))]
[XmlElement("defs", typeof(SvgDefine))]
public SvgParts SvgParts
{
get { return _SvgParts; }
set { _SvgParts = value; }
}
public SvgPart Add(SvgPart svgPart)
{
_SvgParts.Add(svgPart);
SvgParts.Add(svgPart);
return svgPart;
}
public void RemoveAt(int i)
{
_SvgParts.RemoveAt(i);
}
public int Count
{ get { return _SvgParts.Count; } }
#endregion
#region Dictionary of Parts
internal override void AddLookup(Dictionary<string, SvgPart> lookUp)
public void RemoveAt(int i) => SvgParts.RemoveAt(i);
public int Count => SvgParts.Count;
#endregion
#region Dictionary of Parts
internal override void AddLookup(Dictionary<string, SvgPart> lookUp)
{
base.AddLookup(lookUp);
SvgParts.AddLookup(lookUp);
}
#endregion
public override string ToString()
{
return ID;
}
}
#endregion
public override string ToString() => ID;
}
}
+39 -65
View File
@@ -1,6 +1,3 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Serialization;
using System.ComponentModel;
using System.Drawing;
@@ -13,87 +10,64 @@ namespace Volian.Svg.Library
public SvgImage() { ;}
public SvgImage(PointF location, SizeF size, string path)
{
_X.Value = location.X;
_Y.Value = location.Y;
_Width.Value = size.Width;
_Height.Value = size.Height;
_ImagePath = path;
X.Value = location.X;
Y.Value = location.Y;
Width.Value = size.Width;
Height.Value = size.Height;
ImagePath = path;
}
#endregion
#region Location
private SvgMeasurement _X = new SvgMeasurement();
[XmlIgnore]
public SvgMeasurement X
{
get { return _X; }
set { _X = value; }
}
[XmlAttribute("x")]
#endregion
#region Location
[XmlIgnore]
public SvgMeasurement X { get; set; } = new SvgMeasurement();
[XmlAttribute("x")]
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
public string X_XmlSurrogate
{
get { return SvgXmlConverter<SvgMeasurement>.GetString(_X); }
set { _X = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
get { return SvgXmlConverter<SvgMeasurement>.GetString(X); }
set { X = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
}
private SvgMeasurement _Y = new SvgMeasurement();
[XmlIgnore]
public SvgMeasurement Y
{
get { return _Y; }
set { _Y = value; }
}
[XmlAttribute("y")]
[XmlIgnore]
public SvgMeasurement Y { get; set; } = new SvgMeasurement();
[XmlAttribute("y")]
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
public string Y_XmlSurrogate
{
get { return SvgXmlConverter<SvgMeasurement>.GetString(_Y); }
set { _Y = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
get { return SvgXmlConverter<SvgMeasurement>.GetString(Y); }
set { Y = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
}
#endregion
#region Size
private SvgMeasurement _Width = new SvgMeasurement();
[XmlIgnore]
public SvgMeasurement Width
{
get { return _Width; }
set { _Width = value; }
}
[XmlAttribute("width")]
#endregion
#region Size
[XmlIgnore]
public SvgMeasurement Width { get; set; } = new SvgMeasurement();
[XmlAttribute("width")]
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
public string Width_WidthmlSurrogate
{
get { return SvgXmlConverter<SvgMeasurement>.GetString(_Width); }
set { _Width = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
get { return SvgXmlConverter<SvgMeasurement>.GetString(Width); }
set { Width = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
}
private SvgMeasurement _Height = new SvgMeasurement();
[XmlIgnore]
public SvgMeasurement Height
{
get { return _Height; }
set { _Height = value; }
}
[XmlAttribute("height")]
[XmlIgnore]
public SvgMeasurement Height { get; set; } = new SvgMeasurement();
[XmlAttribute("height")]
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
public string Height_XmlSurrogate
{
get { return SvgXmlConverter<SvgMeasurement>.GetString(_Height); }
set { _Height = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
get { return SvgXmlConverter<SvgMeasurement>.GetString(Height); }
set { Height = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
}
#endregion
#region Path to Image File
private string _ImagePath = null;
[XmlAttribute(AttributeName = "href", Namespace = "http://www.w3.org/1999/xlink")]
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
public string ImagePath
{
get { return _ImagePath; }
set { _ImagePath = value; }
}
#endregion
}
#endregion
#region Path to Image File
[XmlAttribute(AttributeName = "href", Namespace = "http://www.w3.org/1999/xlink")]
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
public string ImagePath { get; set; } = null;
#endregion
}
}
@@ -1,7 +1,3 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Volian.Svg.Library
{
internal class SvgInheritedSettings
@@ -19,69 +15,54 @@ namespace Volian.Svg.Library
MyFontSettings.MyParentsSettings = value.MyFontSettings;
}
}
#endregion
#region Line Settings
private SvgLineSettings _MyLineSettings = new SvgLineSettings();
public SvgLineSettings MyLineSettings
#endregion
#region Line Settings
public SvgLineSettings MyLineSettings { get; set; } = new SvgLineSettings();
public string Stroke
{
get { return _MyLineSettings; }
set { _MyLineSettings = value; }
}
public string Stroke
{
get { return _MyLineSettings.Stroke; }
set { _MyLineSettings.Stroke = value; }
get { return MyLineSettings.Stroke; }
set { MyLineSettings.Stroke = value; }
}
public string StrokeWidth
{
get { return _MyLineSettings.StrokeWidth; }
set { _MyLineSettings.StrokeWidth = value; }
get { return MyLineSettings.StrokeWidth; }
set { MyLineSettings.StrokeWidth = value; }
}
#endregion
#region Fill Settings
private SvgFillSettings _MyFillSettings = new SvgFillSettings();
internal SvgFillSettings MyFillSettings
#endregion
#region Fill Settings
internal SvgFillSettings MyFillSettings { get; set; } = new SvgFillSettings();
public string Fill
{
get { return _MyFillSettings; }
set { _MyFillSettings = value; }
get { return MyFillSettings.Fill; }
set { MyFillSettings.Fill = value; }
}
public string Fill
#endregion
#region Font Settings
internal SvgFontSettings MyFontSettings { get; set; } = new SvgFontSettings();
public string FontFamily
{
get { return _MyFillSettings.Fill; }
set { _MyFillSettings.Fill = value; }
}
#endregion
#region Font Settings
private SvgFontSettings _MyFontSettings = new SvgFontSettings();
internal SvgFontSettings MyFontSettings
{
get { return _MyFontSettings; }
set { _MyFontSettings = value; }
}
public string FontFamily
{
get { return _MyFontSettings.FontFamily; }
set { _MyFontSettings.FontFamily = value; }
get { return MyFontSettings.FontFamily; }
set { MyFontSettings.FontFamily = value; }
}
public string FontSize
{
get { return _MyFontSettings.FontSize; }
set { _MyFontSettings.FontSize = value; }
get { return MyFontSettings.FontSize; }
set { MyFontSettings.FontSize = value; }
}
public string SVGFontStyle
{
get { return _MyFontSettings.SVGFontStyle; }
set { _MyFontSettings.SVGFontStyle = value; }
get { return MyFontSettings.SVGFontStyle; }
set { MyFontSettings.SVGFontStyle = value; }
}
public string FontWeight
{
get { return _MyFontSettings.FontWeight; }
set { _MyFontSettings.FontWeight = value; }
get { return MyFontSettings.FontWeight; }
set { MyFontSettings.FontWeight = value; }
}
public string TextDecoration
{
get { return _MyFontSettings.TextDecoration; }
set { _MyFontSettings.TextDecoration = value; }
get { return MyFontSettings.TextDecoration; }
set { MyFontSettings.TextDecoration = value; }
}
#endregion
}
+38 -114
View File
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Serialization;
using System.ComponentModel;
using System.Drawing;
@@ -13,146 +11,72 @@ namespace Volian.Svg.Library
public SvgLine() { ;}
public SvgLine(PointF location1, PointF location2, Color lineColor, float lineWidth)
{
_X1.Value = location1.X;
_Y1.Value = location1.Y;
_X2.Value = location2.X;
_Y2.Value = location2.Y;
X1.Value = location1.X;
Y1.Value = location1.Y;
X2.Value = location2.X;
Y2.Value = location2.Y;
LineColor = lineColor;
LineWidth = new SvgMeasurement(lineWidth);
}
//XMLElementAttribute(ElementName = "PREFIX", IsNullable = false)
#endregion
#region Location1
private SvgMeasurement _X1 = new SvgMeasurement();
[XmlIgnore]
public SvgMeasurement X1
{
get { return _X1; }
set { _X1 = value; }
}
[XmlAttribute("x1")]
#endregion
#region Location1
[XmlIgnore]
public SvgMeasurement X1 { get; set; } = new SvgMeasurement();
[XmlAttribute("x1")]
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
public string X1_XmlSurrogate
{
get { return SvgXmlConverter<SvgMeasurement>.GetString(_X1); }
set { _X1 = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
get { return SvgXmlConverter<SvgMeasurement>.GetString(X1); }
set { X1 = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
}
private SvgMeasurement _Y1 = new SvgMeasurement();
[XmlIgnore]
public SvgMeasurement Y1
{
get { return _Y1; }
set { _Y1 = value; }
}
[XmlAttribute("y1")]
[XmlIgnore]
public SvgMeasurement Y1 { get; set; } = new SvgMeasurement();
[XmlAttribute("y1")]
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
public string Y1_XmlSurrogate
{
get { return SvgXmlConverter<SvgMeasurement>.GetString(_Y1); }
set { _Y1 = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
get { return SvgXmlConverter<SvgMeasurement>.GetString(Y1); }
set { Y1 = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
}
#endregion
#region Location2
private SvgMeasurement _X2 = new SvgMeasurement();
[XmlIgnore]
public SvgMeasurement X2
{
get { return _X2; }
set { _X2 = value; }
}
[XmlAttribute("x2")]
#endregion
#region Location2
[XmlIgnore]
public SvgMeasurement X2 { get; set; } = new SvgMeasurement();
[XmlAttribute("x2")]
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
public string X2_XmlSurrogate
{
get { return SvgXmlConverter<SvgMeasurement>.GetString(_X2); }
set { _X2 = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
get { return SvgXmlConverter<SvgMeasurement>.GetString(X2); }
set { X2 = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
}
private SvgMeasurement _Y2 = new SvgMeasurement();
[XmlIgnore]
public SvgMeasurement Y2
{
get { return _Y2; }
set { _Y2 = value; }
}
[XmlAttribute("y2")]
[XmlIgnore]
public SvgMeasurement Y2 { get; set; } = new SvgMeasurement();
[XmlAttribute("y2")]
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
public string Y_XmlSurrogate
{
get { return SvgXmlConverter<SvgMeasurement>.GetString(_Y2); }
set { _Y2 = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
get { return SvgXmlConverter<SvgMeasurement>.GetString(Y2); }
set { Y2 = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
}
#endregion
#region Description
private string _Description = string.Empty;
[System.ComponentModel.DefaultValueAttribute("")]
[XmlElement("desc")]
public string Description
{
get { return _Description; }
set { _Description = value; }
}
#endregion
#region LineColor
//protected Color _LineColor = Color.Empty;
//[XmlIgnoreAttribute()]
//public Color LineColor
//{
// get { return _LineWidth.Value == 0 ? Color.LightGray : _LineColor == Color.Empty ? Color.Gray : _LineColor; }
// set { _LineColor = value; }
//}
private Color AdjustColorForWidth(Color myColor, float myWidth)
#endregion
#region Description
[System.ComponentModel.DefaultValueAttribute("")]
[XmlElement("desc")]
public string Description { get; set; } = string.Empty;
#endregion
#region LineColor
private Color AdjustColorForWidth(Color myColor, float myWidth)
{
if (myWidth > 1F) return myColor;
//Console.WriteLine("Line Width = {0}, Alpha = {1}", myWidth, Convert.ToInt32(myWidth * 255));
return Color.FromArgb(Convert.ToInt32(myWidth * 255), myColor);
}
// Serializes the 'BackgroundColor' Color to XML.
//[System.ComponentModel.DefaultValueAttribute("none")]
//[XmlAttribute("stroke")]
//public string Stroke
//{
// get { return _LineColor == Color.Empty ? "none" : _LineColor == Color.Black ? "" : ColorTranslator.ToHtml(_LineColor); }
// set { _LineColor = (value == "none" ? Color.Empty : (value == "" ? Color.Empty : ColorTranslator.FromHtml(value))); }
//}
#endregion
#region LineWidth
//private SvgMeasurement GetLineWidth()
//{
// if (_LineWidth.Value == -1) return new SvgMeasurement(1F);// Minimum Strokewidth
// if (_LineWidth.Value == 0) return new SvgMeasurement(.01F);// Minimum Strokewidth
// if (_LineColor == Color.Empty) return new SvgMeasurement( .01F);// No Color - Minimum Strokewidth
// return _LineWidth;
//}
//private SvgMeasurement _LineWidth = new SvgMeasurement();
//[XmlIgnore]
//public SvgMeasurement LineWidth
//{
// get { return _LineWidth; }
// set { _LineWidth = value; }
//}
//[XmlAttribute("stroke-width")]
//[Browsable(false)]
//[EditorBrowsable(EditorBrowsableState.Never)]
//public string LineWidth_XmlSurrogate
//{
// get
// {
// if (_LineWidth.Value == -1)
// return "none";
// return VolianXmlConverter<SvgMeasurement>.GetString(_LineWidth);
// }
// set
// {
// if (value == "none")
// _LineWidth = VolianXmlConverter<SvgMeasurement>.GetObject("-1");
// else
// _LineWidth = VolianXmlConverter<SvgMeasurement>.GetObject(value);
// }
//}
#endregion
}
}
+5 -11
View File
@@ -1,6 +1,3 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Xml.Serialization;
using System.ComponentModel;
@@ -50,12 +47,9 @@ namespace Volian.Svg.Library
get { return _MyLineSettings.OutlineWidth; }
set { _MyLineSettings.OutlineWidth = value; }
}
#endregion
#region Setup Inheritance
override internal void SetupInheritance(SvgInheritedSettings myParentsSettings)
{
_MyLineSettings.MyParentsSettings = myParentsSettings.MyLineSettings;
}
#endregion
}
#endregion
#region Setup Inheritance
override internal void SetupInheritance(SvgInheritedSettings myParentsSettings) => _MyLineSettings.MyParentsSettings = myParentsSettings.MyLineSettings;
#endregion
}
}
+24 -77
View File
@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.ComponentModel;
using System.Xml.Serialization;
namespace Volian.Svg.Library
{
@@ -13,34 +8,20 @@ namespace Volian.Svg.Library
public SvgLineSettings() { ;}
public SvgLineSettings(Color myColor, SvgMeasurement myWidth)
{
_Stroke = ColorTranslator.ToHtml(myColor);
_StrokeWidth = myWidth.ToString();
Stroke = ColorTranslator.ToHtml(myColor);
StrokeWidth = myWidth.ToString();
}
//public SvgLineSettings(string myStroke, string myStrokeWidth)
//{
// _Stroke = myStroke;
// _StrokeWidth = myStrokeWidth;
//}
#endregion
#region Inheritance
private SvgLineSettings _MyParentsSettings = null;
public SvgLineSettings MyParentsSettings
{
get { return _MyParentsSettings; }
set
{
_MyParentsSettings = value;
}
}
#endregion
#region Internal Inherited Properties
protected string InheritedStroke
#endregion
#region Inheritance
public SvgLineSettings MyParentsSettings { get; set; } = null;
#endregion
#region Internal Inherited Properties
protected string InheritedStroke
{
get
{
// Stroke = "", "0" - Default, otherwise the value
if (_Stroke != "" && _Stroke != "0") return _Stroke; // Current Value
if (_MyParentsSettings != null) return _MyParentsSettings.InheritedStroke;// Inherited
if (Stroke != "" && Stroke != "0") return Stroke; // Current Value
if (MyParentsSettings != null) return MyParentsSettings.InheritedStroke;// Inherited
return "None"; // Default
}
}
@@ -49,68 +30,47 @@ namespace Volian.Svg.Library
get
{
// StrokeWidth = "", "none" - Default, otherwise the value
if (_StrokeWidth != "" && _StrokeWidth != "none") return _StrokeWidth; // Current Value
if (_MyParentsSettings != null) return _MyParentsSettings.InheritedLineWidth; // Inherited
if (StrokeWidth != "" && StrokeWidth != "none") return StrokeWidth; // Current Value
if (MyParentsSettings != null) return MyParentsSettings.InheritedLineWidth; // Inherited
return "1PX"; // Default
}
}
//protected string InheritedOutlineWidth
//{
// get
// {
// // StrokeWidth = "", "none" - Default, otherwise the value
// if (_StrokeWidth != "" && _StrokeWidth.ToLower() != "none") return _StrokeWidth; // Current Value
// if (_MyParent != null) return _MyParent.InheritedLineWidth; // Inherited
// return "1PX"; // Default
// }
//}
#endregion
#region Inherited Values
public SvgMeasurement LineWidth
{
get
{
// Stroke = "None" - Light, otherwise the value
// StrokeWidth = "None" Light, otherwise the value
string myStroke = InheritedStroke;
string myWidth = InheritedLineWidth;
//if (myStroke.ToLower() == "none" || myWidth.ToLower() == "none") // Light
// return new SvgMeasurement(.001F, E_MeasurementUnits.PX);
SvgMeasurement myMeasurement = new SvgMeasurement(myWidth);
//myMeasurement.Value *= _Scale;
return myMeasurement;
}
set
{
_StrokeWidth = value.ToString();
StrokeWidth = value.ToString();
}
}
public SvgMeasurement OutlineWidth
{
get
{
// Stroke = "None" - Eliminate, otherwise the value
// StrokeWidth = "0" Eliminate, otherwise the value
string myStroke = InheritedStroke;
//string myWidth = InheritedOutlineWidth;
string myWidth = InheritedLineWidth;
if (myStroke.ToLower() == "none" || myWidth == "0") // Eliminate
return new SvgMeasurement(0, E_MeasurementUnits.PX);
SvgMeasurement myMeasurement = new SvgMeasurement(myWidth);
//myMeasurement.Value *= _Scale;
return myMeasurement;
}
set
{
_StrokeWidth = value.ToString();
StrokeWidth = value.ToString();
}
}
public Color LineColor
{
get
{
// Stroke = "None" - Eliminate, otherwise the value
// StrokeWidth = "None" Eliminate, otherwise the value
string myStroke = InheritedStroke;
string myWidth = InheritedLineWidth;
if (myStroke.ToLower() == "none" || myWidth.ToLower() == "none" || myWidth == "0") // Light
@@ -120,9 +80,9 @@ namespace Volian.Svg.Library
set
{
if (value == Color.Empty)
_Stroke = "none";
Stroke = "none";
else
_Stroke = ColorTranslator.ToHtml(value);
Stroke = ColorTranslator.ToHtml(value);
}
}
@@ -130,10 +90,7 @@ namespace Volian.Svg.Library
{
get
{
// Stroke = "None" - Eliminate, otherwise the value
// StrokeWidth = "0" Eliminate, otherwise the value
string myStroke = InheritedStroke;
//string myWidth = InheritedOutlineWidth;
string myWidth = InheritedLineWidth;
if (myStroke.ToLower() == "none" || myWidth == "0") // Eliminate
return Color.Empty;
@@ -142,26 +99,16 @@ namespace Volian.Svg.Library
set
{
if (value == Color.Empty)
_Stroke = "none";
Stroke = "none";
else
_Stroke = ColorTranslator.ToHtml(value);
Stroke = ColorTranslator.ToHtml(value);
}
}
#endregion
#region Properties
private string _Stroke = string.Empty; // Default value is None
public string Stroke
{
get { return _Stroke; }
set { _Stroke = value; }
}
private string _StrokeWidth = string.Empty; // Default value is 1PX
public string StrokeWidth
{
get { return _StrokeWidth; }
set { _StrokeWidth = value; }
}
#endregion
}
#endregion
#region Properties
public string Stroke { get; set; } = string.Empty;
public string StrokeWidth { get; set; } = string.Empty;
#endregion
}
}
+34 -108
View File
@@ -1,9 +1,5 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using System.Text.RegularExpressions;
namespace Volian.Svg.Library
@@ -57,24 +53,24 @@ namespace Volian.Svg.Library
public SvgMeasurement() { ;}
public SvgMeasurement(int value)
{
_Value = Convert.ToSingle(value);
Value = Convert.ToSingle(value);
_Units = E_MeasurementUnits.PX;
}
public SvgMeasurement(float value)
{
_Value = value;
Value = value;
_Units = E_MeasurementUnits.PX;
}
public SvgMeasurement(float value, E_MeasurementUnits units)
{
_Value = value;
Value = value;
_Units = units;
}
public SvgMeasurement(string val)
{
val = val.Replace("{size}", "10");// B2020-145 BWD SAMG TSG-6 Fix for Base Format {size} parameter rather than font size
MatchCollection mc = Regex.Matches(val.ToLower(), "([+-]?[.0-9]+)|(in|cm|mm|em|ex|pc|pt|px|percentage)");
_Value = Convert.ToSingle(mc[0].Value);
Value = Convert.ToSingle(mc[0].Value);
if (mc.Count == 2)
{
//Console.WriteLine("{0} - '{1}'", val, mc[1].Value.ToUpper());
@@ -93,108 +89,55 @@ namespace Volian.Svg.Library
{
float tmp = GetSizeInPoints(DPI);
_Units = value;
_Value *= (tmp / GetSizeInPoints(DPI));
Value *= (tmp / GetSizeInPoints(DPI));
}
}
private float _Value;
public float Value
{
get { return _Value; }
set { _Value = value; }
}
#endregion
#region ToString
public override string ToString()
public float Value { get; set; }
#endregion
#region ToString
public override string ToString()
{
switch (_Units)
{
case E_MeasurementUnits.PX: // Default
return string.Format("{0}", _Value);
return string.Format("{0}", Value);
case E_MeasurementUnits.PERCENTAGE: // Precentage is preceded by a space
return string.Format("{0} {1}", _Value, _Units);
return string.Format("{0} {1}", Value, _Units);
}
return string.Format("{0}{1}", _Value, _Units);
return string.Format("{0}{1}", Value, _Units);
}
#endregion
//public float SizeInPixels
//{
// get
// {
// switch (_Units)
// {
// case E_MeasurementUnits.PT: //Points - 72 per inch
// return _Value * DPI / 72F;
// case E_MeasurementUnits.PC: //Picas - 6 per inch
// return _Value * DPI / 6F;
// case E_MeasurementUnits.IN: //inches
// return _Value * DPI;
// case E_MeasurementUnits.CM: // Centimeter
// return _Value * DPI / 2.54F;
// case E_MeasurementUnits.MM: // Millimeter
// return _Value * DPI / 25.4F;
// case E_MeasurementUnits.EM: // EMs
// return _Value * DPI / 8;
// case E_MeasurementUnits.EX: // EXs
// return _Value * DPI / 16;
// default:
// return _Value;
// }
// }
//}
public float GetSizeInPoints(float myDPI)
{
switch (_Units)
{
case E_MeasurementUnits.PX: //Pixels myDPI per inch
return _Value * 72F / myDPI;
return Value * 72F / myDPI;
case E_MeasurementUnits.PC: //Picas - 6 per inch
return _Value * 72F / 6F;
return Value * 72F / 6F;
case E_MeasurementUnits.IN: //inches
return _Value * 72F;
return Value * 72F;
case E_MeasurementUnits.CM: // Centimeter
return _Value * 72F / 2.54F;
return Value * 72F / 2.54F;
case E_MeasurementUnits.MM: // Millimeter
return _Value * 72F / 25.4F;
return Value * 72F / 25.4F;
case E_MeasurementUnits.EM: // EMs
return _Value * 72F / 8;
return Value * 72F / 8;
case E_MeasurementUnits.EX: // EXs
return _Value * 72F / 16;
return Value * 72F / 16;
default: // Points
return _Value;
return Value;
}
}
//public float SizeInPoints
//{ get { return SizeInPixels * 72 / DPI; } }
//public float SizeInInches
//{ get { return SizeInPixels / DPI; } }
//public float SizeInCentimeters
//{ get { return SizeInPixels * 2.54F / DPI; } }
//public float SizeInMillimeters
//{ get { return SizeInPixels * 25.4F / DPI; } }
//public float SizeInEms
//{ get { return SizeInPixels * 5 / (6 * DPI); } }
//public float SizeInExs
//{ get { return SizeInPixels * 5 / (6 * DPI); } }
//public float SizeInPicas
//{ get { return SizeInPixels * 6 / DPI; } }
//public Unit SizeInUnits
//{ get { return new Unit((double)SizeInPoints, UnitTypeEnum.Point); } }
public float GetSizeInPixels(float myDPI)
{ return GetSizeInPoints(myDPI) * myDPI / 72F;}
public float GetSizeInInches(float myDPI)
{ return GetSizeInPoints(myDPI) / 72F; }
public float GetSizeInCentimeters(float myDPI)
{ return GetSizeInPoints(myDPI) * 2.54F / 72F; }
public float GetSizeInMillimeters(float myDPI)
{ return GetSizeInPoints(myDPI) * 25.4F / 72F; }
public float GetSizeInEms(float myDPI)
{ return GetSizeInPoints(myDPI) * 5 / (6 * 72F); }
public float GetSizeInExs(float myDPI)
{ return GetSizeInPoints(myDPI) * 5 / (6 * 72F); }
public float GetSizeInPicas(float myDPI)
{ return GetSizeInPoints(myDPI) * 6 / 72F; }
//public Unit GetSizeInUnits(float myDPI)
//{ return new Unit((double)GetSizeInPoints(myDPI), UnitTypeEnum.Point); }
public float GetSizeInPixels(float myDPI) => GetSizeInPoints(myDPI) * myDPI / 72F;
public float GetSizeInInches(float myDPI) => GetSizeInPoints(myDPI) / 72F;
public float GetSizeInCentimeters(float myDPI) => GetSizeInPoints(myDPI) * 2.54F / 72F;
public float GetSizeInMillimeters(float myDPI) => GetSizeInPoints(myDPI) * 25.4F / 72F;
public float GetSizeInEms(float myDPI) => GetSizeInPoints(myDPI) * 5 / (6 * 72F);
public float GetSizeInExs(float myDPI) => GetSizeInPoints(myDPI) * 5 / (6 * 72F);
public float GetSizeInPicas(float myDPI) => GetSizeInPoints(myDPI) * 6 / 72F;
public static float StringToPoints(string value)
{
SvgMeasurement tmp = new SvgMeasurement(value);
@@ -226,26 +169,9 @@ namespace Volian.Svg.Library
}
public class MeasurementTypeConverter : ExpandableObjectConverter
{
public override bool CanConvertTo(ITypeDescriptorContext context, Type t)
{
return t == typeof(String);
}
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is SvgMeasurement)
{
return value.ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
public override bool CanConvertFrom(ITypeDescriptorContext context, Type t)
{
return t == typeof(String);
}
public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object val)
{
SvgMeasurement measurement = new SvgMeasurement((string)val);
return measurement;
}
}
public override bool CanConvertTo(ITypeDescriptorContext context, Type t) => t == typeof(String);
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType) => destType == typeof(string) && value is SvgMeasurement ? value.ToString() : base.ConvertTo(context, culture, value, destType);
public override bool CanConvertFrom(ITypeDescriptorContext context, Type t) => t == typeof(String);
public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object val) => new SvgMeasurement((string)val);
}
}
-25
View File
@@ -1,7 +1,4 @@
using System;
using System.IO;
using System.Xml.Serialization;
using System.Drawing;
using System.ComponentModel;
using System.Collections.Generic;
@@ -21,28 +18,6 @@ namespace Volian.Svg.Library
set { _ID = value; }
}
#endregion
//#region Parent and Containing Svg
//// ToDo: MyParent
//private SvgPartGrouping _MyParent;
//[XmlIgnore()]
//public SvgPartGrouping MyParent
//{
// get { return _MyParent; }
// set { _MyParent = value; }
//}
//// ToDo: MySvg
//private Svg _MySvg;
//public Svg MySvg
//{
// get { return _MySvg; }
// set { _MySvg = value; }
//}
//internal void SetParent(SvgPartGrouping myParent)
//{
// _MyParent = myParent;
// _MySvg = myParent.MySvg == null? MyParent : myParent.MySvg;
//}
//#endregion
#region Setup Inheritance
virtual internal void SetupInheritance(SvgInheritedSettings myParentsSettings) { ; }
#endregion
+6 -15
View File
@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Serialization;
using System.ComponentModel;
using System.Drawing;
namespace Volian.Svg.Library
{
@@ -78,14 +73,10 @@ namespace Volian.Svg.Library
get { return _MyInheritedSettings.TextDecoration; }
set { _MyInheritedSettings.TextDecoration = value; }
}
#endregion
#endregion
#region Setup Inheritance
override internal void SetupInheritance(SvgInheritedSettings myParentsSettings)
{
_MyInheritedSettings.MyParentsSettings = myParentsSettings;
//_SvgParts.SetupInheritance(_MyInheritedSettings);
}
#endregion
}
#endregion
#endregion
#region Setup Inheritance
override internal void SetupInheritance(SvgInheritedSettings myParentsSettings) => _MyInheritedSettings.MyParentsSettings = myParentsSettings;
#endregion
}
}
+77 -128
View File
@@ -1,7 +1,6 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Drawing;
using System.ComponentModel;
using System.Text;
@@ -38,52 +37,39 @@ namespace Volian.Svg.Library
{
}
/// <summary>
/// <para>
/// Initializes a new instance of <see cref='SVGPart'/> based on another <see cref='SVGPart'/>.
/// </para>
/// </summary>
/// <param name='value'>
/// A <see cref='SVGPart'/> from which the contents are copied
/// </param>
public SvgParts(SvgParts value)
{
this.AddRange(value);
}
/// <summary>
/// <para>
/// Initializes a new instance of <see cref='SVGPart'/> based on another <see cref='SVGPart'/>.
/// </para>
/// </summary>
/// <param name='value'>
/// A <see cref='SVGPart'/> from which the contents are copied
/// </param>
public SvgParts(SvgParts value) => this.AddRange(value);
/// <summary>
/// <para>
/// Initializes a new instance of <see cref='SVGPart'/> containing any array of <see cref='SVGPart'/> objects.
/// </para>
/// </summary>
/// <param name='value'>
/// A array of <see cref='SVGPart'/> objects with which to intialize the collection
/// </param>
public SvgParts(SvgPart[] value)
{
this.AddRange(value);
}
/// <summary>
/// <para>
/// Initializes a new instance of <see cref='SVGPart'/> containing any array of <see cref='SVGPart'/> objects.
/// </para>
/// </summary>
/// <param name='value'>
/// A array of <see cref='SVGPart'/> objects with which to intialize the collection
/// </param>
public SvgParts(SvgPart[] value) => this.AddRange(value);
/// <summary>
/// <para>Represents the entry at the specified index of the <see cref='SVGPart'/>.</para>
/// </summary>
/// <param name='index'><para>The zero-based index of the entry to locate in the collection.</para></param>
/// <value>
/// <para> The entry at the specified index of the collection.</para>
/// </value>
/// <exception cref='System.ArgumentOutOfRangeException'><paramref name='index'/> is outside the valid range of indexes for the collection.</exception>
public SvgPart this[int index]
/// <summary>
/// <para>Represents the entry at the specified index of the <see cref='SVGPart'/>.</para>
/// </summary>
/// <param name='index'><para>The zero-based index of the entry to locate in the collection.</para></param>
/// <value>
/// <para> The entry at the specified index of the collection.</para>
/// </value>
/// <exception cref='System.ArgumentOutOfRangeException'><paramref name='index'/> is outside the valid range of indexes for the collection.</exception>
public SvgPart this[int index]
{
get { return ((SvgPart)(List[index])); }
set { List[index] = value; }
}
//#region SetupInheritance
//internal void SetupInheritance(SvgInheritedSettings myParentsSettings)
//{
// foreach (SvgPart svgPart in List)
// svgPart.SetupInheritance(myParentsSettings);
//}
//#endregion
#region Dictionary of Parts
internal void AddLookup(Dictionary<string, SvgPart> lookUp)
{
@@ -194,29 +180,26 @@ namespace Volian.Svg.Library
List.CopyTo(array, index);
}
/// <summary>
/// <para>Returns the index of a <see cref='SVGPart'/> in
/// the <see cref='SVGPart'/> .</para>
/// </summary>
/// <param name='value'>The <see cref='SVGPart'/> to locate.</param>
/// <returns>
/// <para>The index of the <see cref='SVGPart'/> of <paramref name='value'/> in the
/// <see cref='SVGPart'/>, if found; otherwise, -1.</para>
/// </returns>
/// <seealso cref='SVGParts.Contains'/>
public int IndexOf(SvgPart value)
{
return List.IndexOf(value);
}
/// <summary>
/// <para>Returns the index of a <see cref='SVGPart'/> in
/// the <see cref='SVGPart'/> .</para>
/// </summary>
/// <param name='value'>The <see cref='SVGPart'/> to locate.</param>
/// <returns>
/// <para>The index of the <see cref='SVGPart'/> of <paramref name='value'/> in the
/// <see cref='SVGPart'/>, if found; otherwise, -1.</para>
/// </returns>
/// <seealso cref='SVGParts.Contains'/>
public int IndexOf(SvgPart value) => List.IndexOf(value);
/// <summary>
/// <para>Inserts a <see cref='SVGPart'/> into the <see cref='SVGParts'/> at the specified index.</para>
/// </summary>
/// <param name='index'>The zero-based index where <paramref name='value'/> should be inserted.</param>
/// <param name=' value'>The <see cref='SVGPart'/> to insert.</param>
/// <returns><para>None.</para></returns>
/// <seealso cref='SVGParts.Add'/>
public void Insert(int index, SvgPart value)
/// <summary>
/// <para>Inserts a <see cref='SVGPart'/> into the <see cref='SVGParts'/> at the specified index.</para>
/// </summary>
/// <param name='index'>The zero-based index where <paramref name='value'/> should be inserted.</param>
/// <param name=' value'>The <see cref='SVGPart'/> to insert.</param>
/// <returns><para>None.</para></returns>
/// <seealso cref='SVGParts.Add'/>
public void Insert(int index, SvgPart value)
{
List.Insert(index, value);
if (OnItemAdd != null) { OnItemAdd(this, new SVGPartArgs(value)); }
@@ -288,45 +271,25 @@ namespace Volian.Svg.Library
/// Event arguments for the SVGParts collection class.
public class SVGPartArgs : EventArgs
{
private SvgParts t;
/// Default constructor.
public SVGPartArgs()
{
t = new SvgParts();
}
/// Default constructor.
public SVGPartArgs() => SVGParts = new SvgParts();
/// Initializes with a SVGPart.
/// Data object.
public SVGPartArgs(SvgPart t)
: this()
{
this.t.Add(t);
}
/// Initializes with a SVGPart.
/// Data object.
public SVGPartArgs(SvgPart t) : this() => this.SVGParts.Add(t);
/// Initializes with a collection of SVGPart objects.
/// Collection of data.
public SVGPartArgs(SvgParts ts)
: this()
{
this.t.AddRange(ts);
}
/// Initializes with a collection of SVGPart objects.
/// Collection of data.
public SVGPartArgs(SvgParts ts) : this() => this.SVGParts.AddRange(ts);
/// Initializes with an array of SVGPart objects.
/// Array of data.
public SVGPartArgs(SvgPart[] ts)
: this()
{
this.t.AddRange(ts);
}
/// Initializes with an array of SVGPart objects.
/// Array of data.
public SVGPartArgs(SvgPart[] ts) : this() => this.SVGParts.AddRange(ts);
/// Gets or sets the data of this argument.
public SvgParts SVGParts
{
get { return t; }
set { t = value; }
}
}
/// Gets or sets the data of this argument.
public SvgParts SVGParts { get; set; }
}
/// SVGParts event handler.
public delegate void SVGPartHandler(object sender, SVGPartArgs e);
@@ -338,43 +301,29 @@ namespace Volian.Svg.Library
{
private SvgPart Item { get { return (SvgPart)_Item; } }
public SvgPartsPropertyDescriptor(SvgParts collection, int index) : base(collection, index) { ;}
public override string DisplayName
{ get { return Item.GetType().Name; } }
}
public override string DisplayName => Item.GetType().Name;
}
#endregion
[Serializable()]
public partial class vlnListPropertyDescriptor : PropertyDescriptor
{
protected object _Item = null;
public vlnListPropertyDescriptor(System.Collections.IList collection, int index)
: base("#" + index.ToString(), null)
{ _Item = collection[index]; }
public override bool CanResetValue(object component)
{ return true; }
public override Type ComponentType
{ get { return _Item.GetType(); } }
public override object GetValue(object component)
{ return _Item; }
public override bool IsReadOnly
{ get { return false; } }
public override Type PropertyType
{ get { return _Item.GetType(); } }
public override void ResetValue(object component)
public vlnListPropertyDescriptor(System.Collections.IList collection, int index)
: base($"#{index}", null) => _Item = collection[index];
public override bool CanResetValue(object component) => true;
public override Type ComponentType => _Item.GetType();
public override object GetValue(object component) => _Item;
public override bool IsReadOnly => false;
public override Type PropertyType => _Item.GetType();
public override void ResetValue(object component)
{ ;}
public override bool ShouldSerializeValue(object component)
{ return true; }
public override void SetValue(object component, object value)
{ /*_Item = value*/;}
//public override AttributeCollection Attributes
//{ get { return new AttributeCollection(null); } }
public override string DisplayName
{ get { return _Item.ToString(); } }
public override string Description
{ get { return _Item.ToString(); } }
public override string Name
{ get { return _Item.ToString(); } }
public override bool ShouldSerializeValue(object component) => true;
public override void SetValue(object component, object value) { /*_Item = value*/; }
public override string DisplayName => _Item.ToString();
public override string Description => _Item.ToString();
public override string Name => _Item.ToString();
} // Class
} // Class
#region Converter
internal class SVGPartsConverter : ExpandableObjectConverter
{
@@ -383,7 +332,7 @@ namespace Volian.Svg.Library
if (destType == typeof(string) && value is SvgParts)
{
// Return department and department role separated by comma.
return ((SvgParts)value).List.Count.ToString() + " SVG Drawing Parts";
return $"{((SvgParts)value).List.Count} SVG Drawing Parts";
}
return base.ConvertTo(context, culture, value, destType);
}
+35 -62
View File
@@ -1,6 +1,3 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Serialization;
using System.ComponentModel;
using System.Drawing;
@@ -13,88 +10,64 @@ namespace Volian.Svg.Library
public SvgRectangle() { ;}
public SvgRectangle(PointF location, SizeF size, Color fillColor, Color lineColor, float lineWidth)
{
_X.Value = location.X;
_Y.Value = location.Y;
_Width.Value = size.Width;
_Height.Value = size.Height;
X.Value = location.X;
Y.Value = location.Y;
Width.Value = size.Width;
Height.Value = size.Height;
FillColor = fillColor;
LineColor = lineColor;
LineWidth = new SvgMeasurement(lineWidth);
}
//XMLElementAttribute(ElementName = "PREFIX", IsNullable = false)
#endregion
#region Description
private string _Description = string.Empty;
[System.ComponentModel.DefaultValueAttribute("")]
[XmlElement("desc")]
public string Description
{
get { return _Description; }
set { _Description = value; }
}
#endregion
#region Location
private SvgMeasurement _X = new SvgMeasurement();
[XmlIgnore]
public SvgMeasurement X
{
get { return _X; }
set { _X = value; }
}
[XmlAttribute("x")]
#endregion
#region Description
[System.ComponentModel.DefaultValueAttribute("")]
[XmlElement("desc")]
public string Description { get; set; } = string.Empty;
#endregion
#region Location
[XmlIgnore]
public SvgMeasurement X { get; set; } = new SvgMeasurement();
[XmlAttribute("x")]
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
public string X_XmlSurrogate
{
get { return SvgXmlConverter<SvgMeasurement>.GetString(_X); }
set { _X = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
get { return SvgXmlConverter<SvgMeasurement>.GetString(X); }
set { X = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
}
private SvgMeasurement _Y = new SvgMeasurement();
[XmlIgnore]
public SvgMeasurement Y
{
get { return _Y; }
set { _Y = value; }
}
[XmlAttribute("y")]
[XmlIgnore]
public SvgMeasurement Y { get; set; } = new SvgMeasurement();
[XmlAttribute("y")]
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
public string Y_XmlSurrogate
{
get { return SvgXmlConverter<SvgMeasurement>.GetString(_Y); }
set { _Y = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
get { return SvgXmlConverter<SvgMeasurement>.GetString(Y); }
set { Y = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
}
#endregion
#region Size
private SvgMeasurement _Width = new SvgMeasurement();
[XmlIgnore]
public SvgMeasurement Width
{
get { return _Width; }
set { _Width = value; }
}
[XmlAttribute("width")]
#endregion
#region Size
[XmlIgnore]
public SvgMeasurement Width { get; set; } = new SvgMeasurement();
[XmlAttribute("width")]
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
public string Width_WidthmlSurrogate
{
get { return SvgXmlConverter<SvgMeasurement>.GetString(_Width); }
set { _Width = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
get { return SvgXmlConverter<SvgMeasurement>.GetString(Width); }
set { Width = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
}
private SvgMeasurement _Height = new SvgMeasurement();
[XmlIgnore]
public SvgMeasurement Height
{
get { return _Height; }
set { _Height = value; }
}
[XmlAttribute("height")]
[XmlIgnore]
public SvgMeasurement Height { get; set; } = new SvgMeasurement();
[XmlAttribute("height")]
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
public string Height_XmlSurrogate
{
get { return SvgXmlConverter<SvgMeasurement>.GetString(_Height); }
set { _Height = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
get { return SvgXmlConverter<SvgMeasurement>.GetString(Height); }
set { Height = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
}
#endregion
}
+30 -76
View File
@@ -1,48 +1,29 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
namespace Volian.Svg.Library
{
public class SvgScale
{
private float _XLowerLimit;
public float XLowerLimit
{
get { return _XLowerLimit; }
set { _XLowerLimit = value; }
}
private float _YLowerLimit;
public float YLowerLimit
{
get { return _YLowerLimit; }
set { _YLowerLimit = value; }
}
private float _Scale; // Scale from Logical to Physical
public float Scale
{ get { return _Scale; } }
private float _Width; // Physical Width
public float Width
{ get { return _Width; } }
private float _Height; // Physical Height
public float Height
{ get { return _Height; } }
public float XUpperLimit
{ get { return _Width * _Scale + _XLowerLimit; } }
public float YUpperLimit
{ get { return _Height * _Scale + _YLowerLimit; } }
private float _DPI;
public float DPI
{ get { return _DPI; } }
private SvgScale(SvgScale tmp,SvgMeasurement newX, SvgMeasurement newY)
public float XLowerLimit { get; set; }
public float YLowerLimit { get; set; }
private float _Scale; // Scale from Logical to Physical
public float Scale => _Scale;
private float _Width; // Physical Width
public float Width => _Width;
private float _Height; // Physical Height
public float Height => _Height;
public float XUpperLimit => _Width * _Scale + XLowerLimit;
public float YUpperLimit => _Height * _Scale + YLowerLimit;
private float _DPI;
public float DPI => _DPI;
private SvgScale(SvgScale tmp,SvgMeasurement newX, SvgMeasurement newY)
{
_DPI = tmp.DPI;
_Scale = tmp.Scale;
_Width = tmp.Width;
_Height = tmp.Height;
_XLowerLimit = tmp.XLowerLimit - newX.GetSizeInPixels(DPI);
_YLowerLimit = tmp.YLowerLimit - newY.GetSizeInPixels(DPI);
XLowerLimit = tmp.XLowerLimit - newX.GetSizeInPixels(DPI);
YLowerLimit = tmp.YLowerLimit - newY.GetSizeInPixels(DPI);
}
public SvgScale(float myDPI, RectangleF bounds,SvgMeasurement width, SvgMeasurement height, SvgViewBox myViewBox)
{
@@ -62,28 +43,16 @@ namespace Volian.Svg.Library
//Console.WriteLine("'Scale',{0}",_Scale);
_Width = outputWidth / _Scale;
_Height = outputHeight / _Scale;
_XLowerLimit = myViewBox.X + (inputWidth - _Width) / 2;
_YLowerLimit = myViewBox.Y + (inputHeight - _Height) / 2;
XLowerLimit = myViewBox.X + (inputWidth - _Width) / 2;
YLowerLimit = myViewBox.Y + (inputHeight - _Height) / 2;
//if (myDPI != 96) Console.WriteLine("DPI {0}", myDPI);
//Console.WriteLine("Scale,{0},{1},{2},{3},{4},{5},{6}", Scale, Width, Height, XLowerLimit, XUpperLimit, YLowerLimit, YUpperLimit);
}
public SvgScale AdjustOrigin(SvgMeasurement newX, SvgMeasurement newY)
{
return new SvgScale(this, newX, newY);
}
public float X(float x)
{
return _Scale * (x - XLowerLimit);
}
public float Y(float y)
{
return _Scale * (y - YLowerLimit);
}
public float AbsX(SvgMeasurement x)
{
return x.GetSizeInPixels(DPI) + Svg.AbsoluteOffset.X;
}
public float AbsY(iTextSharp.text.pdf.PdfContentByte cb, SvgMeasurement y)
public SvgScale AdjustOrigin(SvgMeasurement newX, SvgMeasurement newY) => new SvgScale(this, newX, newY);
public float X(float x) => _Scale * (x - XLowerLimit);
public float Y(float y) => _Scale * (y - YLowerLimit);
public float AbsX(SvgMeasurement x) => x.GetSizeInPixels(DPI) + Svg.AbsoluteOffset.X;
public float AbsY(iTextSharp.text.pdf.PdfContentByte cb, SvgMeasurement y)
{
// the following line of code is 'taken' from the 16bit code: \promsnt\exe\wined\togdi.cpp
// whenever doing an 'Absolute' macro.
@@ -91,36 +60,21 @@ namespace Volian.Svg.Library
yOffset = yOffset / 20; // convert from twips to points (point = 1/72 inch)
return cb.PdfDocument.PageSize.Height - y.GetSizeInPixels(DPI) + yOffset + Svg.AbsoluteOffset.Y;
}
public float Y(iTextSharp.text.pdf.PdfContentByte cb, float y)
{
return cb.PdfDocument.PageSize.Height - _Scale * (y - YLowerLimit);
}
public float M(float m)
{
return _Scale * m;
}
public float X(SvgMeasurement x)
public float Y(iTextSharp.text.pdf.PdfContentByte cb, float y) => cb.PdfDocument.PageSize.Height - _Scale * (y - YLowerLimit);
public float M(float m) => _Scale * m;
public float X(SvgMeasurement x)
{
float retval = _Scale * (x.GetSizeInPixels(DPI) - XLowerLimit);
return retval;
}
public float Y(SvgMeasurement y)
{
return _Scale * (y.GetSizeInPixels(DPI) - YLowerLimit);
}
public float Y(iTextSharp.text.pdf.PdfContentByte cb, SvgMeasurement y)
public float Y(SvgMeasurement y) => _Scale * (y.GetSizeInPixels(DPI) - YLowerLimit);
public float Y(iTextSharp.text.pdf.PdfContentByte cb, SvgMeasurement y)
{
float yOffset = 0; // = (cb.PdfWriter.CurrentPageNumber -1) * .8F * cb.PdfDocument.PageSize.Height;
float myY = yOffset + cb.PdfDocument.PageSize.Height - _Scale * (y.GetSizeInPixels(DPI) - YLowerLimit);
return myY;
}
public float YY(SvgMeasurement y)
{
return -_Scale * y.GetSizeInPixels(DPI);
}
public float M(SvgMeasurement m)
{
return _Scale * m.GetSizeInPixels(DPI);
}
}
public float YY(SvgMeasurement y) => -_Scale * y.GetSizeInPixels(DPI);
public float M(SvgMeasurement m) => _Scale * m.GetSizeInPixels(DPI);
}
}
+3 -6
View File
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Serialization;
using System.Xml;
@@ -60,11 +59,9 @@ namespace Volian.Svg.Library
}
public class NonXsiTextWriter : XmlTextWriter
{
public NonXsiTextWriter( TextWriter w ) : base( w ) {}
public NonXsiTextWriter( Stream w, Encoding encoding ) : base( w, encoding ) {
this.Formatting = Formatting.Indented;
}
public NonXsiTextWriter( string filename, Encoding encoding ) : base( filename, encoding ) {}
public NonXsiTextWriter( TextWriter w ) : base( w ) {}
public NonXsiTextWriter(Stream w, Encoding encoding) : base(w, encoding) => this.Formatting = Formatting.Indented;
public NonXsiTextWriter( string filename, Encoding encoding ) : base( filename, encoding ) {}
bool _skip = false;
public override void WriteStartAttribute( string prefix, string localName, string ns )
{
-2
View File
@@ -1,5 +1,3 @@
using System;
using System.IO;
using System.Xml.Serialization;
using System.Drawing;
using System.ComponentModel;
-3
View File
@@ -1,6 +1,3 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Serialization;
using System.Drawing;
+25 -48
View File
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Xml.Serialization;
using System.ComponentModel;
@@ -14,52 +10,38 @@ namespace Volian.Svg.Library
public SvgText() { ;}
public SvgText(PointF location, string text, Font font, Color fillColor)
{
_X.Value = location.X;
_Y.Value = location.Y;
X.Value = location.X;
Y.Value = location.Y;
Text = text;
Font = font;
FillColor = fillColor;
LineColor = Color.Empty;
LineWidth = new SvgMeasurement(0);
}
#endregion
#region Location
private SvgJustify _Justify = SvgJustify.Left;
[XmlAttribute("Justify")]
public SvgJustify Justify
{
get { return _Justify; }
set { _Justify = value; }
}
private SvgMeasurement _X = new SvgMeasurement();
[XmlIgnore]
public SvgMeasurement X
{
get { return _X; }
set { _X = value; }
}
[XmlAttribute("x")]
#endregion
#region Location
[XmlAttribute("Justify")]
public SvgJustify Justify { get; set; } = SvgJustify.Left;
[XmlIgnore]
public SvgMeasurement X { get; set; } = new SvgMeasurement();
[XmlAttribute("x")]
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
public string X_XmlSurrogate
{
get { return SvgXmlConverter<SvgMeasurement>.GetString(_X); }
set { _X = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
get { return SvgXmlConverter<SvgMeasurement>.GetString(X); }
set { X = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
}
private SvgMeasurement _Y = new SvgMeasurement();
[XmlIgnore]
public SvgMeasurement Y
{
get { return _Y; }
set { _Y = value; }
}
[XmlAttribute("y")]
[XmlIgnore]
public SvgMeasurement Y { get; set; } = new SvgMeasurement();
[XmlAttribute("y")]
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
public string Y_XmlSurrogate
{
get { return SvgXmlConverter<SvgMeasurement>.GetString(_Y); }
set { _Y = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
get { return SvgXmlConverter<SvgMeasurement>.GetString(Y); }
set { Y = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
}
#endregion
#region Text
@@ -124,19 +106,14 @@ namespace Volian.Svg.Library
get { return _MyFontSettings.TextDecoration; }
set { _MyFontSettings.TextDecoration = value; }
}
#endregion
#region Description
private string _Description = string.Empty;
[System.ComponentModel.DefaultValueAttribute("")]
[XmlElement("desc")]
public string Description
{
get { return _Description; }
set { _Description = value; }
}
#endregion
#region Setup Inheritance
override internal void SetupInheritance(SvgInheritedSettings myParentsSettings)
#endregion
#region Description
[System.ComponentModel.DefaultValueAttribute("")]
[XmlElement("desc")]
public string Description { get; set; } = string.Empty;
#endregion
#region Setup Inheritance
override internal void SetupInheritance(SvgInheritedSettings myParentsSettings)
{
base.SetupInheritance(myParentsSettings);
_MyFontSettings.MyParentsSettings = myParentsSettings.MyFontSettings;
+40 -72
View File
@@ -1,6 +1,3 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Serialization;
using System.ComponentModel;
using System.Drawing;
@@ -13,95 +10,66 @@ namespace Volian.Svg.Library
public SvgUse() { ;}
public SvgUse(PointF location, SizeF size, string id)
{
_X.Value = location.X;
_Y.Value = location.Y;
_Width.Value = size.Width;
_Height.Value = size.Height;
X.Value = location.X;
Y.Value = location.Y;
Width.Value = size.Width;
Height.Value = size.Height;
_ID = id;
}
#endregion
#region Location
private SvgMeasurement _X = new SvgMeasurement();
[XmlIgnore]
public SvgMeasurement X
{
get { return _X; }
set { _X = value; }
}
[XmlAttribute("x")]
#endregion
#region Location
[XmlIgnore]
public SvgMeasurement X { get; set; } = new SvgMeasurement();
[XmlAttribute("x")]
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
public string X_XmlSurrogate
{
get { return SvgXmlConverter<SvgMeasurement>.GetString(_X); }
set { _X = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
get { return SvgXmlConverter<SvgMeasurement>.GetString(X); }
set { X = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
}
private SvgMeasurement _Y = new SvgMeasurement();
[XmlIgnore]
public SvgMeasurement Y
{
get { return _Y; }
set { _Y = value; }
}
[XmlAttribute("y")]
[XmlIgnore]
public SvgMeasurement Y { get; set; } = new SvgMeasurement();
[XmlAttribute("y")]
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
public string Y_XmlSurrogate
{
get { return SvgXmlConverter<SvgMeasurement>.GetString(_Y); }
set { _Y = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
get { return SvgXmlConverter<SvgMeasurement>.GetString(Y); }
set { Y = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
}
#endregion
#region Size
private SvgMeasurement _Width = new SvgMeasurement();
[XmlIgnore]
public SvgMeasurement Width
{
get { return _Width; }
set { _Width = value; }
}
[XmlAttribute("width")]
#endregion
#region Size
[XmlIgnore]
public SvgMeasurement Width { get; set; } = new SvgMeasurement();
[XmlAttribute("width")]
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
public string Width_WidthmlSurrogate
{
get { return SvgXmlConverter<SvgMeasurement>.GetString(_Width); }
set { _Width = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
get { return SvgXmlConverter<SvgMeasurement>.GetString(Width); }
set { Width = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
}
private SvgMeasurement _Height = new SvgMeasurement();
[XmlIgnore]
public SvgMeasurement Height
{
get { return _Height; }
set { _Height = value; }
}
[XmlAttribute("height")]
[XmlIgnore]
public SvgMeasurement Height { get; set; } = new SvgMeasurement();
[XmlAttribute("height")]
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
public string Height_XmlSurrogate
{
get { return SvgXmlConverter<SvgMeasurement>.GetString(_Height); }
set { _Height = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
get { return SvgXmlConverter<SvgMeasurement>.GetString(Height); }
set { Height = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
}
#endregion
#region ID to be used
private string _UseID = null;
[XmlAttribute(AttributeName = "href", Namespace = "http://www.w3.org/1999/xlink")]
public string UseID
{
get { return _UseID; }
set { _UseID = value; }
}
#endregion
#region Setup Inheritance
override internal void SetupInheritance(SvgInheritedSettings myParentsSettings)
{
_MyInheritedSettings.MyParentsSettings = myParentsSettings;
}
#endregion
public override string ToString()
{
return string.Format("({0}, {1}) Template '{2}'", this.X, this.Y, this.UseID);
}
}
#endregion
#region ID to be used
[XmlAttribute(AttributeName = "href", Namespace = "http://www.w3.org/1999/xlink")]
public string UseID { get; set; } = null;
#endregion
#region Setup Inheritance
override internal void SetupInheritance(SvgInheritedSettings myParentsSettings) => _MyInheritedSettings.MyParentsSettings = myParentsSettings;
#endregion
public override string ToString() => string.Format("({0}, {1}) Template '{2}'", this.X, this.Y, this.UseID);
}
}
+14 -35
View File
@@ -1,8 +1,6 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.ComponentModel;
using System;
using System.Drawing;
using System.ComponentModel;
namespace Volian.Svg.Library
{
@@ -11,11 +9,8 @@ namespace Volian.Svg.Library
{
#region ctor
public SvgViewBox() { ;}
public SvgViewBox(float x, float y, float width, float height)
{
_MyRectangleF = new RectangleF(x, y, width, height);
}
public SvgViewBox(string val)
public SvgViewBox(float x, float y, float width, float height) => _MyRectangleF = new RectangleF(x, y, width, height);
public SvgViewBox(string val)
{
string[] parms = ((string)val).Split(' ');
_MyRectangleF = new RectangleF(Convert.ToSingle(parms[0]), Convert.ToSingle(parms[1]), Convert.ToSingle(parms[2]), Convert.ToSingle(parms[3]));
@@ -43,33 +38,17 @@ namespace Volian.Svg.Library
get { return _MyRectangleF.Height; }
set { _MyRectangleF.Height = value; }
}
#endregion
#region ToString
public override string ToString()
{
return string.Format("{0} {1} {2} {3}", X, Y, Width, Height);
}
#endregion
}
#endregion
#region ToString
public override string ToString() => string.Format("{0} {1} {2} {3}", X, Y, Width, Height);
#endregion
}
public class ViewBoxTypeConverter : ExpandableObjectConverter
{
public override bool CanConvertTo(ITypeDescriptorContext context, Type t)
{
return t == typeof(String);
}
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is SvgViewBox)
{
return value.ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
public override bool CanConvertFrom(ITypeDescriptorContext context, Type t)
{
return t == typeof(String);
}
public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object val)
public override bool CanConvertTo(ITypeDescriptorContext context, Type t) => t == typeof(string);
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType) => destType == typeof(string) && value is SvgViewBox ? value.ToString() : base.ConvertTo(context, culture, value, destType);
public override bool CanConvertFrom(ITypeDescriptorContext context, Type t) => t == typeof(string);
public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object val)
{
string[] parms = ((string)val).Split(' ');
SvgViewBox viewBox = new SvgViewBox(Convert.ToSingle(parms[0]), Convert.ToSingle(parms[1]), Convert.ToSingle(parms[2]), Convert.ToSingle(parms[3]));
+2 -9
View File
@@ -1,6 +1,3 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
namespace Volian.Svg.Library
@@ -13,10 +10,6 @@ namespace Volian.Svg.Library
TypeConverter FontConverter = TypeDescriptor.GetConverter(typeof(T));
return FontConverter.ConvertToInvariantString(myObject);
}
public static T GetObject(string value)
{
TypeConverter converter = TypeDescriptor.GetConverter(typeof(T));
return (T)converter.ConvertFromInvariantString(value);
}
}
public static T GetObject(string value) => (T)TypeDescriptor.GetConverter(typeof(T)).ConvertFromInvariantString(value);
}
}
@@ -89,7 +89,6 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="FontFind.cs" />
<Compile Include="Graphics.cs" />
<Compile Include="iTextSharp.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
+77 -446
View File
@@ -1,18 +1,10 @@
using System;
using System.Collections;
using System.Text;
using System.Collections.Generic;
using System.Xml.Serialization;
using iTextSharp.text;
using iTextSharp.text.pdf;
using iTextSharp.text.factories;
using Itenso.Rtf;
using Itenso.Rtf.Parser;
using Itenso.Rtf.Interpreter;
using Itenso.Rtf.Support;
using Microsoft.Win32;
using System.Text.RegularExpressions;
using System.Xml;
using System.IO;
using Volian.Base.Library;
@@ -97,23 +89,14 @@ namespace Volian.Svg.Library
{
get { return _MyText; }
}
private SvgText _MySvgText;
public SvgText MySvgText
{
get { return _MySvgText; }
set { _MySvgText = value; }
}
private SvgScale _MySvgScale;
public SvgScale MySvgScale
{
get { return _MySvgScale; }
set { _MySvgScale = value; }
}
public SvgProcessTextArgs(string myText, SvgText mySvgText, SvgScale mySvgScale)
public SvgText MySvgText { get; set; }
public SvgScale MySvgScale { get; set; }
public SvgProcessTextArgs(string myText, SvgText mySvgText, SvgScale mySvgScale)
{
_MyText = myText;
_MySvgText = mySvgText;
_MySvgScale = mySvgScale;
MySvgText = mySvgText;
MySvgScale = mySvgScale;
}
}
public partial class Svg : SvgGroup
@@ -121,7 +104,7 @@ namespace Volian.Svg.Library
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
public void DrawMacro(string macroDef, float x, float y, PdfContentByte cb)
{
_MyContentByte = cb;
MyContentByte = cb;
SvgMeasurement X = new SvgMeasurement(x, E_MeasurementUnits.PT);
SvgMeasurement Y = new SvgMeasurement(Height.GetSizeInPoints(72) - y, E_MeasurementUnits.PT);
if (!this.LookUp.ContainsKey(macroDef)) return; // AEP - DU1 (missing C22 macro for AEP)
@@ -157,45 +140,31 @@ namespace Volian.Svg.Library
top = (yll > yul ? (yll > top ? yll : top) : (yul > top ? yul : top));
tmp.BoundingBox = new iTextSharp.text.Rectangle(xll, yll, xul, yul);
}
private PdfContentByte _MyContentByte;
[XmlIgnore]
public PdfContentByte MyContentByte
{
get { return _MyContentByte; }
set { _MyContentByte = 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 SvgScale _MyScale;
[XmlIgnore]
public PdfContentByte MyContentByte { get; set; }
public float LeftMargin { get; set; } = 0;
public float TopMargin { get; set; } = 0;
private SvgScale _MyScale;
public SvgScale MyScale
{
get
{
if (_MyScale == null)
{
_MyScale = new SvgScale(72, new System.Drawing.RectangleF(0, 0, _MyContentByte.PdfWriter.PageSize.Width, _MyContentByte.PdfWriter.PageSize.Height), _Width, _Height, _ViewBox);
_MyScale.XLowerLimit -= _LeftMargin;
_MyScale.YLowerLimit -= _TopMargin;
_MyScale = new SvgScale(72, new System.Drawing.RectangleF(0, 0, MyContentByte.PdfWriter.PageSize.Width, MyContentByte.PdfWriter.PageSize.Height), Width, Height, ViewBox);
_MyScale.XLowerLimit -= LeftMargin;
_MyScale.YLowerLimit -= TopMargin;
}
return _MyScale;
}
}
public void Draw(PdfContentByte cb)
{
//myPdf.Clear();
_MyContentByte = cb;
MyContentByte = cb;
_Templates = new Dictionary<string, PdfTemplate>();
//RegisterFonts();
SvgParts.Draw(cb, MyScale, this, this); //72 - Points
}
public static iTextSharp.text.Font GetFont(string fontName)
@@ -214,36 +183,6 @@ namespace Volian.Svg.Library
VlnItextFont.RegisterFont(fontName);
return FontFactory.GetFont(fontName, BaseFont.IDENTITY_H, BaseFont.EMBEDDED, size, style, new iTextSharp.text.Color(color));
}
//private static string _FontFolder = null;
//public static string FontFolder
//{
// get
// {
// if (_FontFolder == null)
// {
// _FontFolder = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Fonts);
// if (_FontFolder == null) _FontFolder = (String)Registry.CurrentUser.OpenSubKey("Software").OpenSubKey("Microsoft").OpenSubKey("Windows").OpenSubKey("CurrentVersion").OpenSubKey("Explorer").OpenSubKey("Shell Folders").GetValue("Fontz");
// _MyLog.WarnFormat("FontFolder set to {0}", _FontFolder);
// }
// return _FontFolder;
// }
//}
private static int _StackTraceSkip = 1;
private static DateTime _LastTime = DateTime.Now;
private static DateTime _StartTime = DateTime.Now;
public static void ResetWhen()
{
_StartTime = _LastTime = DateTime.Now;
}
public static void WhenAndWhere()
{
DateTime thisTime = DateTime.Now;
System.Diagnostics.StackFrame sf = new System.Diagnostics.StackFrame(_StackTraceSkip, true);
Console.WriteLine("{0:000000},{1:000000},'{2}',{3},'{4}'", TimeSpan.FromTicks(thisTime.Ticks - _StartTime.Ticks).TotalMilliseconds,
TimeSpan.FromTicks(thisTime.Ticks - _LastTime.Ticks).TotalMilliseconds, sf.GetMethod().Name, sf.GetFileLineNumber()
,sf.GetFileName());
_LastTime = thisTime;
}
}
public partial class SvgArc : SvgShapePart
{
@@ -326,18 +265,13 @@ namespace Volian.Svg.Library
{
// TODO: Could I try creating a template
// Don't draw
// SvgParts.Draw(cb, myScale, mySvg, myParent);
PdfTemplate tmp = null;
if (ID != "") tmp = mySvg.GetTemplate(ID, cb); // the size will be adjusted as items are added.
SvgParts.Draw(tmp, myScale, mySvg, myParent);
}
public override void Draw(PdfTemplate tmp, SvgScale myScale, Svg mySvg, SvgPartInheritance myParent)
{
// TODO: Could I try creating a template
// Don't draw
// SvgParts.Draw(cb, myScale, mySvg, myParent);
//PdfTemplate tmp2 = mySvg.GetTemplate(ID); // the size will be adjusted as items are added.
//SvgParts.Draw(tmp2, myScale, mySvg, myParent);
}
}
public partial class SvgUse : SvgPartInheritance
@@ -348,24 +282,22 @@ namespace Volian.Svg.Library
{
// TODO: Could I use the template
SetupInheritance(myParent.MyInheritedSettings);
if (mySvg.LookUp.ContainsKey(_UseID))
mySvg[_UseID].Draw(cb, scale.AdjustOrigin(X, Y), mySvg, this);
if (mySvg.LookUp.ContainsKey(UseID))
mySvg[UseID].Draw(cb, scale.AdjustOrigin(X, Y), mySvg, this);
else
{
if (!_MissingMacros.Contains(_UseID))
if (!_MissingMacros.Contains(UseID))
{
_MissingMacros.Add(_UseID);
_MyLog.WarnFormat("Missing Macro '{0}'", _UseID);
_MissingMacros.Add(UseID);
_MyLog.WarnFormat("Missing Macro '{0}'", UseID);
}
}
//cb.AddTemplate(mySvg.GetTemplate(_UseID.Substring(1),cb), scale.X(X), scale.Y(cb, Y));
}
public override void Draw(PdfTemplate tmp, SvgScale scale, Svg mySvg, SvgPartInheritance myParent)
{
// TODO: Could I use the template
SetupInheritance(myParent.MyInheritedSettings);
//mySvg[_UseID.Substring(1)].Draw(tmp, scale.AdjustOrigin(X, Y), mySvg, this);
mySvg[_UseID].Draw(tmp, scale.AdjustOrigin(X, Y), mySvg, this);
mySvg[UseID].Draw(tmp, scale.AdjustOrigin(X, Y), mySvg, this);
}
}
public partial class SvgEllipse : SvgShapePart
@@ -410,7 +342,7 @@ namespace Volian.Svg.Library
public override void Draw(PdfContentByte cb, SvgScale myScale, Svg mySvg, SvgPartInheritance myParent)
{
SetupInheritance(myParent.MyInheritedSettings);
_SvgParts.Draw(cb, myScale, mySvg, this);
SvgParts.Draw(cb, myScale, mySvg, this);
}
public override void Draw(PdfTemplate tmp, SvgScale myScale, Svg mySvg, SvgPartInheritance myParent)
{
@@ -443,7 +375,8 @@ namespace Volian.Svg.Library
{
SetupInheritance(myParent.MyInheritedSettings);
tmp.SaveState();
try
#pragma warning disable CS0168 // Variable is declared but never used - ex kept for debugging
try
{
if (ImagePath != null)
{
@@ -457,7 +390,8 @@ namespace Volian.Svg.Library
{
//_MyLog.WarnFormat("SvgImage.Draw '{0}' {1} - {2}", ImagePath, ex.GetType().Name, ex.Message);
}
tmp.RestoreState();
#pragma warning restore CS0168 // Variable is declared but never used
tmp.RestoreState();
}
}
public partial class SvgLine : SvgLinePart
@@ -581,28 +515,19 @@ namespace Volian.Svg.Library
{
case SvgJustify.Left:
return Element.ALIGN_LEFT;
break;
case SvgJustify.Center:
return Element.ALIGN_CENTER;
break;
case SvgJustify.Right:
return Element.ALIGN_RIGHT;
break;
}
return Element.ALIGN_LEFT;
}
}
public class VlnSplitCharacter : ISplitCharacter
{
public bool IsSplitCharacter(int start, int current, int end, char[] cc, PdfChunk[] ck)
{
return (cc[current] == ' ');
}
public bool IsSplitCharacter(char c)
{
return (c == ' ');
}
}
public bool IsSplitCharacter(int start, int current, int end, char[] cc, PdfChunk[] ck) => (cc[current] == ' ');
public bool IsSplitCharacter(char c) => (c == ' ');
}
public static VlnSplitCharacter mySplitter = new VlnSplitCharacter();
// Draw's using PdfContentByte are for drawing PageList items.
public override void Draw(PdfContentByte cb, SvgScale scale, Svg mySvg, SvgPartInheritance myParent)
@@ -654,9 +579,6 @@ namespace Volian.Svg.Library
}
switch (Justify)
{
//case SvgJustify.Left:
// x = x;
// break;
case SvgJustify.Center:
x-=w/2;
break;
@@ -687,12 +609,6 @@ namespace Volian.Svg.Library
public static bool CompressPropSubSup = false;
private Phrase BuildPhrase(string text, float fontSize, int fontStyle, iTextSharp.text.Font font)
{
//if (text == "Caution")
//{
// if (iTextSharp.text.FontFactory.IsRegistered("VolianScript"))
// Console.WriteLine("Is Registered");
// Console.WriteLine("stop");
//}
bool fontUnderline = false;
float fontTextRise = 0;
@@ -700,8 +616,6 @@ namespace Volian.Svg.Library
text = Regex.Replace(text, @"\\'[0-9a-fA-F][0-9a-fA-F]", new MatchEvaluator(ReplaceHexCharacter));
text += " ";
//if (text.Contains("\\")) -- these 2 lines made \ul and \ulnone in page list text not get resolved and would then print
//text = text.Replace("\\", ((char)9586).ToString()); // B2016-155 convert backslash char to the unicode symbol - to allow processing rtf commands \ul, \up, \dn, etc.
// B2016-167: handle backslashes but don't do if the backslash is an underline rtf command
int stindx = text.IndexOf("\\");
while (stindx != -1)
@@ -892,170 +806,38 @@ namespace Volian.Svg.Library
tmp.RestoreState();
}
}
public class SvgPageTotal
{
public SvgPageTotal(System.Drawing.Font myFont, PdfContentByte cb)
{
_MyFont = myFont;
_MyTemplate = cb.CreateTemplate(100, 100);
_MyTemplate.BoundingBox= new Rectangle(-20, -20, 100, 100);
}
private int _PageCount=1;
private System.Drawing.Font _MyFont;
private PdfTemplate _MyTemplate;
public PdfTemplate MyTemplate
{
get { return _MyTemplate; }
}
public void Draw()
{
// Output Page Count
_MyTemplate.BeginText();
iTextSharp.text.Font font = Svg.GetFont(_MyFont.Name);
BaseFont baseFont = font.BaseFont;
_MyTemplate.SetFontAndSize(baseFont,_MyFont.Size);
_MyTemplate.SetTextMatrix(0, 0);
_MyTemplate.ShowText(_PageCount.ToString());
_MyTemplate.EndText();
}
}
public class SvgPageHelper : PdfPageEventHelper
{
private bool _SpecialCAS; // B2023-005: CAS page, rotate watermark
public bool SpecialCAS
public bool SpecialCAS { get; set; }
public bool IsLandscape { get; set; }
public bool IsWatermarkLandscape { get; set; }
public Svg MySvg { get; set; }
public PdfLayer PageListLayer { get; set; }
public PdfLayer WatermarkLayer { get; set; }
public string Watermark { get; set; } = string.Empty;
public string WatermarkColor { get; set; } = "BLUE";
public PdfLayer PROMSVersionLayer { get; set; }
public string PROMSVersion { get; set; } = string.Empty;
public bool DoZoomOMatic { get; set; } = false;
public int CurrentPageNumber { get; set; } = 0;
public int CurrentPageNumberNoFoldouts { get; set; } = 0;
public int CurrentTOCPageNumber { get; set; } = 0;
public bool OnFoldoutPage { get; set; } = false;
public bool CreatingFoldoutPage { get; set; } = false;
public bool CreatingSupInfoPage { get; set; } = false;
public SvgPageHelper(Svg mySvg)
{
get { return _SpecialCAS; }
set { _SpecialCAS = value; }
}
private bool _IsLandscape;
public bool IsLandscape
{
get { return _IsLandscape; }
set { _IsLandscape = value; }
}
// B2019-145: added the following property so that the code would know that an adjustment should be made to print the watermark
// in landscape mode. Note that 'IsLandscape' could not be used because it also does the pagelist items.
private bool _IsWatermarkLandscape;
public bool IsWatermarkLandscape
{
get { return _IsWatermarkLandscape; }
set { _IsWatermarkLandscape = value; }
}
// B2018-124 we no longer need is list was not hanling "Information Only" water mark
//private List<string> _AllowedWatermarks = new List<string>();
//public List<string> AllowedWatermarks
//{
// get { return _AllowedWatermarks; }
// set { _AllowedWatermarks = value; }
//}
private Svg _MySvg;
public Svg MySvg
{
get { return _MySvg; }
set { _MySvg = value; }
}
private PdfLayer _PageListLayer;
public PdfLayer PageListLayer
{
get { return _PageListLayer; }
set { _PageListLayer = value; }
}
private PdfLayer _WatermarkLayer;
public PdfLayer WatermarkLayer
{
get { return _WatermarkLayer; }
set { _WatermarkLayer = value; }
}
private string _Watermark=string.Empty;
public string Watermark
{
get { return _Watermark; }
set { _Watermark = value; }
}
private string _WatermarkColor = "BLUE";
public string WatermarkColor
{
get { return _WatermarkColor; }
set { _WatermarkColor = value; }
}
private PdfLayer _PROMSVersionLayer; //C2018-009 print PROMS version
public PdfLayer PROMSVersionLayer
{
get { return _PROMSVersionLayer; }
set { _PROMSVersionLayer = value; }
}
private string _PROMSVersion = string.Empty;
public string PROMSVersion
{
get { return _PROMSVersion; }
set { _PROMSVersion = value; }
}
private bool _DoZoomOMatic = false;
public bool DoZoomOMatic
{
get { return _DoZoomOMatic; }
set { _DoZoomOMatic = value; }
}
private int _CurrentPageNumber = 0;
public int CurrentPageNumber
{
get { return _CurrentPageNumber; }
set { _CurrentPageNumber = value; }
}
private int _CurrentPageNumberNoFoldouts = 0;
public int CurrentPageNumberNoFoldouts
{
get { return _CurrentPageNumberNoFoldouts; }
set { _CurrentPageNumberNoFoldouts = value; }
}
private int _CurrentTOCPageNumber = 0;
public int CurrentTOCPageNumber
{
get { return _CurrentTOCPageNumber; }
set { _CurrentTOCPageNumber = value; }
}
private bool _OnFoldoutPage = false;
public bool OnFoldoutPage
{
get { return _OnFoldoutPage; }
set { _OnFoldoutPage = value; }
}
private bool _CreatingFoldoutPage = false;
public bool CreatingFoldoutPage
{
get { return _CreatingFoldoutPage; }
set { _CreatingFoldoutPage = value; }
}
private bool _CreatingSupInfoPage = false;
public bool CreatingSupInfoPage
{
get { return _CreatingSupInfoPage; }
set { _CreatingSupInfoPage = value; }
}
public SvgPageHelper(Svg mySvg)
{
_MySvg = mySvg;
MySvg = mySvg;
}
public SvgPageHelper()
{
}
private int _BGPageOffset = 0;
public int BackgroundPageOffset
{
get { return _BGPageOffset; }
set { _BGPageOffset = value; }
}
protected virtual string ReplacePageListToken(Match match)
{
return string.Empty;
}
public override void OnOpenDocument(PdfWriter writer, Document document)
public int BackgroundPageOffset { get; set; } = 0;
protected virtual string ReplacePageListToken(Match match) => string.Empty;
public override void OnOpenDocument(PdfWriter writer, Document document)
{
//base.OnOpenDocument(writer, document);
//tmpTotal = writer.DirectContent.CreateTemplate(100, 100);
//tmpTotal.BoundingBox = new Rectangle(-20, -20, 100, 100);
//PdfContentByte cb = writer.DirectContent;
}
public override void OnEndPage(PdfWriter writer, Document document)
{
@@ -1093,8 +875,8 @@ namespace Volian.Svg.Library
{
get
{
if (_BackgroundReader == null && _BackgroundFile != null && File.Exists(_BackgroundFile))
_BackgroundReader = new PdfReader(_BackgroundFile);
if (_BackgroundReader == null && BackgroundFile != null && File.Exists(BackgroundFile))
_BackgroundReader = new PdfReader(BackgroundFile);
return _BackgroundReader;
}
}
@@ -1106,29 +888,17 @@ namespace Volian.Svg.Library
return BackgroundReader.Info["Producer"].ToString().StartsWith("iTextSharp");
}
}
private string _BackgroundFile = null;
public string BackgroundFile
{
get { return _BackgroundFile; }
set { _BackgroundFile = value; }
}
private PdfLayer _BackgroundLayer = null;
public PdfLayer BackgroundLayer
{
get { return _BackgroundLayer; }
set { _BackgroundLayer = value; }
}
private System.Drawing.PointF _BackgroundOffset = new System.Drawing.PointF(0, 0);
public string BackgroundFile { get; set; } = null;
public PdfLayer BackgroundLayer { get; set; } = null;
private System.Drawing.PointF _BackgroundOffset = new System.Drawing.PointF(0, 0);
public System.Drawing.PointF BackgroundOffset
{
get { return _BackgroundOffset; }
set { _BackgroundOffset = value; }
}
public int BackgroundPageCount
{
get { return BackgroundReader == null ? 0 : BackgroundReader.NumberOfPages; }
}
private PdfImportedPage GetBackgroundPage(PdfContentByte cb)
public int BackgroundPageCount => BackgroundReader == null ? 0 : BackgroundReader.NumberOfPages;
private PdfImportedPage GetBackgroundPage(PdfContentByte cb)
{
if (BackgroundReader == null) return null;
int page = cb.PdfWriter.CurrentPageNumber + BackgroundPageOffset;
@@ -1151,14 +921,10 @@ namespace Volian.Svg.Library
ZoomOMatic(cb, 36);
cb.RestoreState();
}
private bool _AllowAllWatermarks = false;
public bool AllowAllWatermarks
{
get { return _AllowAllWatermarks; }
set { _AllowAllWatermarks = value; }
}
//C2022-004 This will return the system drawing color from either the color name or ARGB values
public System.Drawing.Color GetWatermarkColor(string colorDescription)
public bool AllowAllWatermarks { get; set; } = false;
//C2022-004 This will return the system drawing color from either the color name or ARGB values
public System.Drawing.Color GetWatermarkColor(string colorDescription)
{
System.Drawing.Color systemColor;
if (colorDescription.StartsWith("[A=")) // if color is ARGB representation, parse out the values
@@ -1192,9 +958,8 @@ namespace Volian.Svg.Library
private void DrawWatermark(PdfContentByte cb)
{
if (Watermark == null || Watermark.ToLower().Contains("none") || Watermark == "") return;
//if (!AllowAllWatermarks && !AllowedWatermarks.Contains(Watermark)) return; -- B2018-124 not needed anymore with above if statement - this does not hanle "Information Only"
cb.SaveState();
if (_WatermarkLayer != null) cb.BeginLayer(_WatermarkLayer);
if (WatermarkLayer != null) cb.BeginLayer(WatermarkLayer);
// B2023-005: Beaver Valley, second page of CAS page is a 'foldout' on large paper - need to rotate the
// watermark
if (SpecialCAS)
@@ -1207,16 +972,13 @@ namespace Volian.Svg.Library
else if (IsLandscape || IsWatermarkLandscape) // B2019-145: Added for printing landscape watermark on step section pages.
{
// The watermark needs to be rotated back for landscape pagelist - B2016-191
//double a = -33 * (Math.PI / 180);
//System.Drawing.Drawing2D.Matrix myMatrix = new System.Drawing.Drawing2D.Matrix((float)Math.Cos(a), (float)Math.Sin(a), (float)-Math.Sin(a), (float)Math.Cos(a), -60, 320);
double a = -90 * (Math.PI / 180);
System.Drawing.Drawing2D.Matrix myMatrix = new System.Drawing.Drawing2D.Matrix((float)Math.Cos(a), (float)Math.Sin(a), (float)-Math.Sin(a), (float)Math.Cos(a), 0, cb.PdfDocument.PageSize.Height);
cb.Transform(myMatrix);
}
SvgWatermark myWatermark = new SvgWatermark(cb, Watermark, GetWatermarkColor(WatermarkColor), .15F);
//myWatermark.SetSquareDotPattern(.7F);
myWatermark.Draw();
if (_WatermarkLayer != null) cb.EndLayer();
if (WatermarkLayer != null) cb.EndLayer();
cb.RestoreState();
}
//C2018-009 print PROMS version
@@ -1226,32 +988,22 @@ namespace Volian.Svg.Library
string text = PROMSVersion;
float textBase =cb.PdfDocument.Top + 19;
float textLeft = cb.PdfDocument.Right - 15;
if (_PROMSVersionLayer != null) cb.BeginLayer(_PROMSVersionLayer);
if (PROMSVersionLayer != null) cb.BeginLayer(PROMSVersionLayer);
cb.BeginText();
cb.SetFontAndSize(BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.EMBEDDED), 6f);
cb.SetTextMatrix(textLeft, textBase);
cb.SetColorFill(new iTextSharp.text.Color(System.Drawing.Color.Indigo));
cb.ShowText(text);
cb.EndText();
if (_PROMSVersionLayer != null) cb.EndLayer();
if (PROMSVersionLayer != null) cb.EndLayer();
cb.RestoreState();
}
private void DrawPageList(PdfContentByte cb)
{
if (_MySvg != null)
if (MySvg != null)
{
cb.SaveState();
if (_PageListLayer != null) cb.BeginLayer(_PageListLayer);
// Do anything needed to finish off the page
//System.Drawing.Drawing2D.Matrix myMatrix = new System.Drawing.Drawing2D.Matrix();
//myMatrix.Rotate(90); // Rotate the Pagelist items by 90 Degrees.
//// Translate by the Height of the page.
//myMatrix.Translate(cb.PdfDocument.PageSize.Height, 0, System.Drawing.Drawing2D.MatrixOrder.Append);
//// This was for fun
//// myMatrix.Scale(.75F, .75F, System.Drawing.Drawing2D.MatrixOrder.Append);
//cb.Transform(myMatrix);
//// You can look at the value of the Matrix at this point, to create the matrix directly like I did below
//OR
if (PageListLayer != null) cb.BeginLayer(PageListLayer);
// Rotate 90 Degrees and Translate by the Height of the Page
if (IsLandscape)
@@ -1259,8 +1011,8 @@ namespace Volian.Svg.Library
System.Drawing.Drawing2D.Matrix myMatrix = new System.Drawing.Drawing2D.Matrix(0, 1, -1, 0, cb.PdfDocument.PageSize.Height, 0);
cb.Transform(myMatrix);
}
_MySvg.Draw(cb);
if (_PageListLayer != null) cb.EndLayer();
MySvg.Draw(cb);
if (PageListLayer != null) cb.EndLayer();
cb.RestoreState();
}
}
@@ -1277,7 +1029,7 @@ namespace Volian.Svg.Library
}
public override void OnStartPage(PdfWriter writer, Document document)
{
//base.OnStartPage(writer, document);
}
public override void OnCloseDocument(PdfWriter writer, Document document)
{
@@ -1289,137 +1041,24 @@ namespace Volian.Svg.Library
private PdfContentByte _ContentByte;
private string _Text;
private System.Drawing.Color _Color;
private PdfPatternPainter _PatternPainter;
private BaseFont _Basefont;
private float _Fontsize;
private float _XOffset;
private float _YOffset;
private float _TextAngle;
private float _Opacity;
public SvgWatermark(PdfContentByte contentByte, string text, System.Drawing.Color color, float opacity)
{
_ContentByte = contentByte;
_Text = text;
//float radius = .5F;
//float space = 3;
// B2021-081: Blue was too intense with an alpha of 255 Read was too light with an alpha of 96
if (color != System.Drawing.Color.Red)
_Color = System.Drawing.Color.FromArgb(96, color);
else
_Color = color; // C2021-019: save color for color override
_Opacity = opacity;
//SetDotPattern(radius, space);
//SetTextLayout();
}
#region commentedout
//private void SetTextLayout()
//{
// Rectangle pageSize = _ContentByte.PdfWriter.PageSize; // Get page size
// _Basefont = BaseFont.CreateFont(BaseFont.HELVETICA_BOLD, Encoding.ASCII.EncodingName, BaseFont.EMBEDDED);
// float hgtA = _Basefont.GetAscentPoint(_Text, 12);
// //float hgtD = basefont.GetDescentPoint(text,20);
// float wid = _Basefont.GetWidthPointKerned(_Text, 12);
// //Console.WriteLine("{0} {1} {2}",hgtA,hgtD,wid);
// float rho = wid / hgtA;
// float x2 = (rho * pageSize.Height - pageSize.Width) / (rho * rho - 1);
// float y1 = x2 * rho;
// float y2 = pageSize.Height - y1;
// float x1 = pageSize.Width - x2;
// _XOffset = x2 + x1 / 2;
// _YOffset = y1 / 2;
// _TextAngle = CalcAngle(y1, x1);
// _Fontsize = (float)(10 * Math.Sqrt(x2 * x2 + y2 * y2) / hgtA);
//}
//public void SetDotPattern(float radius, float space)
//{
// _PatternPainter = _ContentByte.CreatePattern(radius * 2, radius * 2, radius * 2 + space, radius * 2 + space);
// PdfGState gState = new PdfGState();
// gState.FillOpacity = _Opacity;
// _PatternPainter.SetGState(gState);
// _PatternPainter.SetColorFill(_Color);
// _PatternPainter.Circle(radius, radius, radius);
// _PatternPainter.Fill();
//}
//public void SetSquareDotPattern(float radius)
//{
// _PatternPainter = _ContentByte.CreatePattern(radius * 4, radius * 2, radius * 4, radius * 2);
// PdfGState gState = new PdfGState();
// gState.FillOpacity = .5f * _Opacity;
// _PatternPainter.SetGState(gState);
// _PatternPainter.SetColorFill(_Color);
// _PatternPainter.Rectangle(0, 0, radius, radius);
// _PatternPainter.Rectangle(radius * 2, radius, radius, radius);
// _PatternPainter.Fill();
//}
//public void SetHashPattern(float thickness, float size)
//{
// _PatternPainter = _ContentByte.CreatePattern(size, size, size, size);
// PdfGState gState = new PdfGState();
// gState.FillOpacity = _Opacity;
// gState.StrokeOpacity = _Opacity;
// _PatternPainter.SetGState(gState);
// _PatternPainter.SetLineWidth(.01F);
// _PatternPainter.SetColorStroke(_Color); // Set color
// _PatternPainter.MoveTo(0, 0);
// _PatternPainter.LineTo(size, size);
// _PatternPainter.MoveTo(size, 0);
// _PatternPainter.LineTo(0, size);
// _PatternPainter.Stroke();
//}
//public void SetTextPattern(float fontSize, float space)
//{
// float hgtA = _Basefont.GetAscentPoint(_Text, fontSize) + _Basefont.GetDescentPoint(_Text, fontSize);
// float wid = _Basefont.GetWidthPointKerned(_Text, fontSize);
// _PatternPainter = _ContentByte.CreatePattern(wid, hgtA, wid + space, hgtA + space);
// _PatternPainter.SetFontAndSize(_Basefont, fontSize);
// _PatternPainter.BoundingBox = new Rectangle(-20, -20, 100, 100);
// _PatternPainter.BeginText();
// PdfGState gs1 = new PdfGState();
// gs1.FillOpacity = _Opacity;
// _PatternPainter.SetGState(gs1);
// _PatternPainter.SetColorFill(_Color); // Set color
// _PatternPainter.ShowText(_Text);
// _PatternPainter.EndText();
//}
//public void SetTextPattern2(float fontSize)
//{
// BaseFont _Basefont2 = BaseFont.CreateFont(BaseFont.HELVETICA, Encoding.ASCII.EncodingName, BaseFont.EMBEDDED);
// float hgtA = _Basefont2.GetAscentPoint(_Text, fontSize);
// float wid = _Basefont2.GetWidthPointKerned(_Text, fontSize);
// _PatternPainter = _ContentByte.CreatePattern(wid * 2, hgtA * 2, wid * 2, hgtA * 2);
// _PatternPainter.SetFontAndSize(_Basefont2, fontSize);
// _PatternPainter.BoundingBox = new Rectangle(-20, -20, 100, 100);
// _PatternPainter.BeginText();
// PdfGState gs1 = new PdfGState();
// gs1.FillOpacity = _Opacity;
// _PatternPainter.SetGState(gs1);
// _PatternPainter.SetColorFill(_Color); // Set color
// _PatternPainter.ShowText(_Text);
// _PatternPainter.ShowTextAligned(PdfContentByte.ALIGN_LEFT, _Text, wid, hgtA, 0);
// _PatternPainter.EndText();
//}
#endregion
public void Draw()
{
_ContentByte.SaveState();
//_ContentByte.BeginText();
//_ContentByte.SetPatternFill(_PatternPainter);
//_ContentByte.SetTextRenderingMode(PdfContentByte.TEXT_RENDER_MODE_FILL_STROKE);
//_ContentByte.SetLineWidth(.5F);
//_ContentByte.SetFontAndSize(_Basefont, _Fontsize);// Set font and size
//_ContentByte.SetColorStroke(_Color);
//PdfGState gs2 = new PdfGState();
//gs2.StrokeOpacity = _Opacity;
//_ContentByte.SetGState(gs2);
//_ContentByte.ShowTextAlignedKerned(PdfContentByte.ALIGN_CENTER, _Text, _XOffset, _YOffset, _TextAngle);// Draw the text
//_ContentByte.EndText();
_ContentByte.AddImage(WatermarkImage);
_ContentByte.RestoreState();
}
//private float CalcAngle(float opposite, float adjacent)
//{
// return (float)(Math.Atan2(opposite, adjacent) * (180 / Math.PI));
//}
private Image _WatermarkImage;
public Image WatermarkImage
{
@@ -1452,7 +1091,6 @@ namespace Volian.Svg.Library
_Color, System.Drawing.Color.Transparent);
g.FillPath(aHatchBrush, gp);
g.DrawPath(new System.Drawing.Pen(_Color), gp);
//g.DrawRectangle(System.Drawing.Pens.Cyan, 0, 0, bnds.Width, bnds.Height);
}
_WatermarkImage = iTextSharp.text.Image.GetInstance(bmp, System.Drawing.Imaging.ImageFormat.Png);
_WatermarkImage.SetAbsolutePosition(72, 72);
@@ -1481,11 +1119,4 @@ namespace Volian.Svg.Library
}
}
public enum SvgWatermarkFill
{
Dots = 1,
Text1 = 2,
Text2 = 3,
Hash = 4
}
}