Commit ce8f2a64 authored by Eric Domke's avatar Eric Domke
Browse files

Fixing compile errors and spacing inconsistencies

parent 05c51974
...@@ -14,8 +14,7 @@ namespace Svg ...@@ -14,8 +14,7 @@ namespace Svg
return this.Content; return this.Content;
} }
public override SvgElement DeepCopy()
public override SvgElement DeepCopy()
{ {
return DeepCopy<SvgDescription>(); return DeepCopy<SvgDescription>();
} }
...@@ -23,9 +22,7 @@ namespace Svg ...@@ -23,9 +22,7 @@ namespace Svg
public override SvgElement DeepCopy<T>() public override SvgElement DeepCopy<T>()
{ {
var newObj = base.DeepCopy<T>() as SvgDescription; var newObj = base.DeepCopy<T>() as SvgDescription;
newObj.Text = this.Text;
return newObj; return newObj;
} }
} }
} }
\ No newline at end of file
...@@ -49,8 +49,8 @@ namespace Svg ...@@ -49,8 +49,8 @@ namespace Svg
/// </summary> /// </summary>
public SvgUse() public SvgUse()
{ {
this.X = 0; this.X = 0;
this.Y = 0; this.Y = 0;
} }
public override System.Drawing.Drawing2D.GraphicsPath Path public override System.Drawing.Drawing2D.GraphicsPath Path
...@@ -69,16 +69,16 @@ namespace Svg ...@@ -69,16 +69,16 @@ namespace Svg
get { return new System.Drawing.RectangleF(); } get { return new System.Drawing.RectangleF(); }
} }
// public override SvgElementCollection Children // public override SvgElementCollection Children
// { // {
// get // get
// { // {
// SvgElement element = this.OwnerDocument.IdManager.GetElementById(this.ReferencedElement); // SvgElement element = this.OwnerDocument.IdManager.GetElementById(this.ReferencedElement);
// SvgElementCollection elements = new SvgElementCollection(this, true); // SvgElementCollection elements = new SvgElementCollection(this, true);
// elements.Add(element); // elements.Add(element);
// return elements; // return elements;
// } // }
// } // }
protected override void Render(SvgRenderer renderer) protected override void Render(SvgRenderer renderer)
{ {
...@@ -99,20 +99,20 @@ namespace Svg ...@@ -99,20 +99,20 @@ namespace Svg
} }
public override SvgElement DeepCopy() public override SvgElement DeepCopy()
{ {
return DeepCopy<SvgUse>(); return DeepCopy<SvgUse>();
} }
public override SvgElement DeepCopy<T>() public override SvgElement DeepCopy<T>()
{ {
var newObj = base.DeepCopy<T>() as SvgUse; var newObj = base.DeepCopy<T>() as SvgUse;
newObj.ReferencedElement = this.ReferencedElement; newObj.ReferencedElement = this.ReferencedElement;
newObj.X = this.X; newObj.X = this.X;
newObj.Y = this.Y; newObj.Y = this.Y;
return newObj; return newObj;
} }
} }
} }
\ No newline at end of file
...@@ -14,10 +14,10 @@ namespace Svg.FilterEffects ...@@ -14,10 +14,10 @@ namespace Svg.FilterEffects
[SvgElement("feGaussianBlur")] [SvgElement("feGaussianBlur")]
public class SvgGaussianBlur : SvgFilterPrimitive public class SvgGaussianBlur : SvgFilterPrimitive
{ {
private float _stdDeviation; private float _stdDeviation;
private BlurType _blurType; private BlurType _blurType;
private int[] _kernel; private int[] _kernel;
private int _kernelSum; private int _kernelSum;
private int[,] _multable; private int[,] _multable;
...@@ -220,10 +220,10 @@ namespace Svg.FilterEffects ...@@ -220,10 +220,10 @@ namespace Svg.FilterEffects
} }
} }
/// <summary> /// <summary>
/// Gets or sets the radius of the blur (only allows for one value - not the two specified in the SVG Spec) /// Gets or sets the radius of the blur (only allows for one value - not the two specified in the SVG Spec)
/// </summary> /// </summary>
[SvgAttribute("stdDeviation")] [SvgAttribute("stdDeviation")]
public float StdDeviation public float StdDeviation
{ {
get { return _stdDeviation; } get { return _stdDeviation; }
...@@ -249,27 +249,27 @@ namespace Svg.FilterEffects ...@@ -249,27 +249,27 @@ namespace Svg.FilterEffects
} }
public override Bitmap Process()
{
//Todo
return null; public override Bitmap Process()
} {
//Todo
return null;
}
public override SvgElement DeepCopy() public override SvgElement DeepCopy()
{ {
return DeepCopy<SvgGaussianBlur>(); return DeepCopy<SvgGaussianBlur>();
} }
public override SvgElement DeepCopy<T>() public override SvgElement DeepCopy<T>()
{ {
var newObj = base.DeepCopy<T>() as SvgGaussianBlur; var newObj = base.DeepCopy<T>() as SvgGaussianBlur;
newObj.StdDeviation = this.StdDeviation; newObj.StdDeviation = this.StdDeviation;
newObj.BlurType = this.BlurType; newObj.BlurType = this.BlurType;
return newObj; return newObj;
} }
} }
} }
\ No newline at end of file
...@@ -130,7 +130,7 @@ namespace Svg ...@@ -130,7 +130,7 @@ namespace Svg
public PointF EndPoint; public PointF EndPoint;
public GradientPoints(PointF startPoint, PointF endPoint) public GradientPoints(PointF startPoint, PointF endPoint)
{ {
this.StartPoint = startPoint; this.StartPoint = startPoint;
this.EndPoint = endPoint; this.EndPoint = endPoint;
} }
...@@ -193,7 +193,7 @@ namespace Svg ...@@ -193,7 +193,7 @@ namespace Svg
for (var i = 0; i < colorBlend.Positions.Length; i++) for (var i = 0; i < colorBlend.Positions.Length; i++)
{ {
var originalPoint = MovePointAlongVector(specifiedStart, specifiedUnitVector, (float) specifiedLength * colorBlend.Positions[i]); var originalPoint = MovePointAlongVector(specifiedStart, specifiedUnitVector, (float)specifiedLength * colorBlend.Positions[i]);
var distanceFromEffectiveStart = CalculateDistance(effectiveStart, originalPoint); var distanceFromEffectiveStart = CalculateDistance(effectiveStart, originalPoint);
...@@ -253,7 +253,7 @@ namespace Svg ...@@ -253,7 +253,7 @@ namespace Svg
private float Y1 private float Y1
{ {
get; get;
set; set;
} }
......
...@@ -8,7 +8,6 @@ namespace Svg.Pathing ...@@ -8,7 +8,6 @@ namespace Svg.Pathing
{ {
public override void AddToPath(System.Drawing.Drawing2D.GraphicsPath graphicsPath) public override void AddToPath(System.Drawing.Drawing2D.GraphicsPath graphicsPath)
{ {
// Important for custom line caps. Force the path the close with an explicit line, not just an implicit close of the figure. // Important for custom line caps. Force the path the close with an explicit line, not just an implicit close of the figure.
if (graphicsPath.PointCount > 0 && !graphicsPath.PathPoints[0].Equals(graphicsPath.PathPoints[graphicsPath.PathPoints.Length - 1])) if (graphicsPath.PointCount > 0 && !graphicsPath.PathPoints[0].Equals(graphicsPath.PathPoints[graphicsPath.PathPoints.Length - 1]))
{ {
...@@ -19,11 +18,11 @@ namespace Svg.Pathing ...@@ -19,11 +18,11 @@ namespace Svg.Pathing
} }
graphicsPath.CloseFigure(); graphicsPath.CloseFigure();
} }
public override string ToString() public override string ToString()
{ {
return "z"; return "z";
} }
} }
} }
\ No newline at end of file
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
<OldToolsVersion>3.5</OldToolsVersion> <OldToolsVersion>3.5</OldToolsVersion>
<UpgradeBackupLocation> <UpgradeBackupLocation>
</UpgradeBackupLocation> </UpgradeBackupLocation>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<IsWebBootstrapper>false</IsWebBootstrapper> <IsWebBootstrapper>false</IsWebBootstrapper>
<SccProjectName> <SccProjectName>
</SccProjectName> </SccProjectName>
...@@ -121,7 +121,6 @@ ...@@ -121,7 +121,6 @@
<Compile Include="Extensions.cs" /> <Compile Include="Extensions.cs" />
<Compile Include="Painting\ISvgBoundable.cs" /> <Compile Include="Painting\ISvgBoundable.cs" />
<Compile Include="Painting\SvgDeferredPaintServer.cs" /> <Compile Include="Painting\SvgDeferredPaintServer.cs" />
<Compile Include="Painting\ISvgBoundable.cs" />
<Compile Include="Painting\SvgMarker.cs" /> <Compile Include="Painting\SvgMarker.cs" />
<Compile Include="Document Structure\SvgDefinitionList.cs" /> <Compile Include="Document Structure\SvgDefinitionList.cs" />
<Compile Include="Document Structure\SvgDescription.cs" /> <Compile Include="Document Structure\SvgDescription.cs" />
......
...@@ -17,17 +17,18 @@ namespace Svg ...@@ -17,17 +17,18 @@ namespace Svg
/// <summary> /// <summary>
/// Initializes the <see cref="SvgText"/> class. /// Initializes the <see cref="SvgText"/> class.
/// </summary> /// </summary>
public SvgText() : base() {} public SvgText() : base() { }
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="SvgText"/> class. /// Initializes a new instance of the <see cref="SvgText"/> class.
/// </summary> /// </summary>
/// <param name="text">The text.</param> /// <param name="text">The text.</param>
public SvgText(string text) : this() public SvgText(string text)
: this()
{ {
this.Text = text; this.Text = text;
} }
public override SvgElement DeepCopy() public override SvgElement DeepCopy()
{ {
return DeepCopy<SvgText>(); return DeepCopy<SvgText>();
......
...@@ -16,7 +16,7 @@ namespace Svg ...@@ -16,7 +16,7 @@ namespace Svg
@default, @default,
preserve preserve
} }
public abstract class SvgTextBase : SvgVisualElement public abstract class SvgTextBase : SvgVisualElement
{ {
private SvgUnitCollection _x = new SvgUnitCollection(); private SvgUnitCollection _x = new SvgUnitCollection();
...@@ -28,7 +28,7 @@ namespace Svg ...@@ -28,7 +28,7 @@ namespace Svg
private SvgTextAnchor _textAnchor = SvgTextAnchor.Start; private SvgTextAnchor _textAnchor = SvgTextAnchor.Start;
private static readonly SvgRenderer _stringMeasure; private static readonly SvgRenderer _stringMeasure;
private const string DefaultFontFamily = "Times New Roman"; private const string DefaultFontFamily = "Times New Roman";
private XmlSpaceHandling _space = XmlSpaceHandling.@default; private XmlSpaceHandling _space = XmlSpaceHandling.@default;
/// <summary> /// <summary>
...@@ -40,7 +40,7 @@ namespace Svg ...@@ -40,7 +40,7 @@ namespace Svg
_stringMeasure = SvgRenderer.FromImage(bitmap); _stringMeasure = SvgRenderer.FromImage(bitmap);
_stringMeasure.TextRenderingHint = TextRenderingHint.AntiAlias; _stringMeasure.TextRenderingHint = TextRenderingHint.AntiAlias;
} }
/// <summary> /// <summary>
/// Gets or sets the text to be rendered. /// Gets or sets the text to be rendered.
/// </summary> /// </summary>
...@@ -68,16 +68,16 @@ namespace Svg ...@@ -68,16 +68,16 @@ namespace Svg
[SvgAttribute("x")] [SvgAttribute("x")]
public virtual SvgUnitCollection X public virtual SvgUnitCollection X
{ {
get { return this._x; } get { return this._x; }
set set
{ {
if(_x != value) if (_x != value)
{ {
this._x = value; this._x = value;
this.IsPathDirty = true; this.IsPathDirty = true;
OnAttributeChanged(new AttributeEventArgs{ Attribute = "x", Value = value }); OnAttributeChanged(new AttributeEventArgs { Attribute = "x", Value = value });
} }
} }
} }
/// <summary> /// <summary>
...@@ -106,16 +106,16 @@ namespace Svg ...@@ -106,16 +106,16 @@ namespace Svg
[SvgAttribute("y")] [SvgAttribute("y")]
public virtual SvgUnitCollection Y public virtual SvgUnitCollection Y
{ {
get { return this._y; } get { return this._y; }
set set
{ {
if(_y != value) if (_y != value)
{ {
this._y = value; this._y = value;
this.IsPathDirty = true; this.IsPathDirty = true;
OnAttributeChanged(new AttributeEventArgs{ Attribute = "y", Value = value }); OnAttributeChanged(new AttributeEventArgs { Attribute = "y", Value = value });
} }
} }
} }
/// <summary> /// <summary>
...@@ -202,7 +202,7 @@ namespace Svg ...@@ -202,7 +202,7 @@ namespace Svg
private static string ValidateFontFamily(string fontFamilyList) private static string ValidateFontFamily(string fontFamilyList)
{ {
// Split font family list on "," and then trim start and end spaces and quotes. // Split font family list on "," and then trim start and end spaces and quotes.
var fontParts = fontFamilyList.Split(new[] { ',' }).Select(fontName => fontName.Trim(new[] { '"', ' ','\'' })); var fontParts = fontFamilyList.Split(new[] { ',' }).Select(fontName => fontName.Trim(new[] { '"', ' ', '\'' }));
var families = System.Drawing.FontFamily.Families; var families = System.Drawing.FontFamily.Families;
...@@ -261,7 +261,7 @@ namespace Svg ...@@ -261,7 +261,7 @@ namespace Svg
protected class BoundsData protected class BoundsData
{ {
private List<NodeBounds> _nodes = new List<NodeBounds>(); private List<NodeBounds> _nodes = new List<NodeBounds>();
public IList<NodeBounds> Nodes public IList<NodeBounds> Nodes
{ {
get { return _nodes; } get { return _nodes; }
} }
...@@ -276,10 +276,10 @@ namespace Svg ...@@ -276,10 +276,10 @@ namespace Svg
float totalWidth = 0; float totalWidth = 0;
var result = new BoundsData(); var result = new BoundsData();
var nodes = (from n in this.Nodes var nodes = (from n in this.Nodes
where (n is SvgContentNode || n is SvgTextBase) && !string.IsNullOrEmpty(n.Content) where (n is SvgContentNode || n is SvgTextBase) && !string.IsNullOrEmpty(n.Content)
select n).ToList(); select n).ToList();
if (nodes.FirstOrDefault() is SvgContentNode && _x.Count > 1) if (nodes.FirstOrDefault() is SvgContentNode && _x.Count > 1)
{ {
string ch; string ch;
...@@ -287,15 +287,18 @@ namespace Svg ...@@ -287,15 +287,18 @@ namespace Svg
nodes.RemoveAt(0); nodes.RemoveAt(0);
int posCount = Math.Min(content.Content.Length, _x.Count); int posCount = Math.Min(content.Content.Length, _x.Count);
var text = PrepareText(content.Content, false, (nodes.Count > 1 && nodes[1] is SvgTextBase)); var text = PrepareText(content.Content, false, (nodes.Count > 1 && nodes[1] is SvgTextBase));
for (var i = 0; i < posCount; i++) for (var i = 0; i < posCount; i++)
{ {
ch = (i == posCount - 1 ? text.Substring(i) : text.Substring(i, 1)); ch = (i == posCount - 1 ? text.Substring(i) : text.Substring(i, 1));
stringBounds = _stringMeasure.MeasureString(ch, font); stringBounds = _stringMeasure.MeasureString(ch, font);
totalHeight = Math.Max(totalHeight, stringBounds.Height); totalHeight = Math.Max(totalHeight, stringBounds.Height);
result.Nodes.Add(new NodeBounds() { Bounds = stringBounds, result.Nodes.Add(new NodeBounds()
Node = new SvgContentNode() { Content = ch}, {
xOffset = (i == 0 ? 0 : _x[i].ToDeviceValue(this) - _x[0].ToDeviceValue(this))}); Bounds = stringBounds,
Node = new SvgContentNode() { Content = ch },
xOffset = (i == 0 ? 0 : _x[i].ToDeviceValue(this) - _x[0].ToDeviceValue(this))
});
} }
} }
...@@ -349,7 +352,7 @@ namespace Svg ...@@ -349,7 +352,7 @@ namespace Svg
{ {
// Measure the overall bounds of all the text // Measure the overall bounds of all the text
var boundsData = GetTextBounds(); var boundsData = GetTextBounds();
var font = GetFont(); var font = GetFont();
SvgTextBase innerText; SvgTextBase innerText;
float x = (_x.Count < 1 ? _calcX : _x[0].ToDeviceValue(this)) + (_dx.Count < 1 ? 0 : _dx[0].ToDeviceValue(this)); float x = (_x.Count < 1 ? _calcX : _x[0].ToDeviceValue(this)) + (_dx.Count < 1 ? 0 : _dx[0].ToDeviceValue(this));
...@@ -379,7 +382,7 @@ namespace Svg ...@@ -379,7 +382,7 @@ namespace Svg
{ {
// Minus FontSize because the x/y coords mark the bottom left, not bottom top. // Minus FontSize because the x/y coords mark the bottom left, not bottom top.
DrawString(_path, x + data.xOffset, y - boundsData.Bounds.Height, font, DrawString(_path, x + data.xOffset, y - boundsData.Bounds.Height, font,
PrepareText(data.Node.Content, i > 0 && boundsData.Nodes[i-1].Node is SvgTextBase, PrepareText(data.Node.Content, i > 0 && boundsData.Nodes[i - 1].Node is SvgTextBase,
i < boundsData.Nodes.Count - 1 && boundsData.Nodes[i + 1].Node is SvgTextBase)); i < boundsData.Nodes.Count - 1 && boundsData.Nodes[i + 1].Node is SvgTextBase));
} }
else else
...@@ -436,7 +439,7 @@ namespace Svg ...@@ -436,7 +439,7 @@ namespace Svg
{ {
fontSize = fontSizeUnit.ToDeviceValue(this); fontSize = fontSizeUnit.ToDeviceValue(this);
} }
var fontStyle = System.Drawing.FontStyle.Regular; var fontStyle = System.Drawing.FontStyle.Regular;
// Get the font-weight // Get the font-weight
...@@ -486,60 +489,60 @@ namespace Svg ...@@ -486,60 +489,60 @@ namespace Svg
/// Draws a string on a path at a specified location and with a specified font. /// Draws a string on a path at a specified location and with a specified font.
/// </summary> /// </summary>
internal void DrawString(GraphicsPath path, float x, float y, Font font, string text) internal void DrawString(GraphicsPath path, float x, float y, Font font, string text)
{ {
PointF location = new PointF(x, y); PointF location = new PointF(x, y);
// No way to do letter-spacing or word-spacing, so do manually // No way to do letter-spacing or word-spacing, so do manually
if (this.LetterSpacing.Value > 0.0f || this.WordSpacing.Value > 0.0f) if (this.LetterSpacing.Value > 0.0f || this.WordSpacing.Value > 0.0f)
{ {
// Cut up into words, or just leave as required // Cut up into words, or just leave as required
string[] words = (this.WordSpacing.Value > 0.0f) ? text.Split(' ') : new string[] { text }; string[] words = (this.WordSpacing.Value > 0.0f) ? text.Split(' ') : new string[] { text };
float wordSpacing = this.WordSpacing.ToDeviceValue(this); float wordSpacing = this.WordSpacing.ToDeviceValue(this);
float letterSpacing = this.LetterSpacing.ToDeviceValue(this); float letterSpacing = this.LetterSpacing.ToDeviceValue(this);
float start = x; float start = x;
foreach (string word in words) foreach (string word in words)
{ {
// Only do if there is line spacing, just write the word otherwise // Only do if there is line spacing, just write the word otherwise
if (this.LetterSpacing.Value > 0.0f) if (this.LetterSpacing.Value > 0.0f)
{ {
char[] characters = word.ToCharArray(); char[] characters = word.ToCharArray();
foreach (char currentCharacter in characters) foreach (char currentCharacter in characters)
{ {
path.AddString(currentCharacter.ToString(), font.FontFamily, (int)font.Style, font.Size, location, StringFormat.GenericTypographic); path.AddString(currentCharacter.ToString(), font.FontFamily, (int)font.Style, font.Size, location, StringFormat.GenericTypographic);
location = new PointF(path.GetBounds().Width + start + letterSpacing, location.Y); location = new PointF(path.GetBounds().Width + start + letterSpacing, location.Y);
} }
} }
else else
{ {
path.AddString(word, font.FontFamily, (int)font.Style, font.Size, location, StringFormat.GenericTypographic); path.AddString(word, font.FontFamily, (int)font.Style, font.Size, location, StringFormat.GenericTypographic);
} }
// Move the location of the word to be written along // Move the location of the word to be written along
location = new PointF(path.GetBounds().Width + start + wordSpacing, location.Y); location = new PointF(path.GetBounds().Width + start + wordSpacing, location.Y);
} }
} }
else else
{ {
if (!string.IsNullOrEmpty(text)) if (!string.IsNullOrEmpty(text))
{ {
path.AddString(text, font.FontFamily, (int)font.Style, font.Size, location, StringFormat.GenericTypographic); path.AddString(text, font.FontFamily, (int)font.Style, font.Size, location, StringFormat.GenericTypographic);
} }
} }
} }
[SvgAttribute("onchange")] [SvgAttribute("onchange")]
public event EventHandler<StringArg> Change; public event EventHandler<StringArg> Change;
//change //change
protected void OnChange(string newString, string sessionID) protected void OnChange(string newString, string sessionID)
{ {
RaiseChange(this, new StringArg {s = newString, SessionID = sessionID}); RaiseChange(this, new StringArg { s = newString, SessionID = sessionID });
} }
protected void RaiseChange(object sender, StringArg s) protected void RaiseChange(object sender, StringArg s)
{ {
var handler = Change; var handler = Change;
if (handler != null) if (handler != null)
{ {
handler(sender, s); handler(sender, s);
...@@ -547,24 +550,24 @@ namespace Svg ...@@ -547,24 +550,24 @@ namespace Svg
} }
#if Net4 #if Net4
public override void RegisterEvents(ISvgEventCaller caller) public override void RegisterEvents(ISvgEventCaller caller)
{ {
//register basic events //register basic events
base.RegisterEvents(caller); base.RegisterEvents(caller);
//add change event for text //add change event for text
caller.RegisterAction<string, string>(this.ID + "/onchange", OnChange); caller.RegisterAction<string, string>(this.ID + "/onchange", OnChange);
} }
public override void UnregisterEvents(ISvgEventCaller caller) public override void UnregisterEvents(ISvgEventCaller caller)
{ {
//unregister base events //unregister base events
base.UnregisterEvents(caller); base.UnregisterEvents(caller);
//unregister change event //unregister change event
caller.UnregisterAction(this.ID + "/onchange"); caller.UnregisterAction(this.ID + "/onchange");
} }
#endif #endif
} }
} }
...@@ -8,24 +8,24 @@ using System.Text; ...@@ -8,24 +8,24 @@ using System.Text;
namespace Svg namespace Svg
{ {
[SvgElement("tspan")] [SvgElement("tspan")]
public class SvgTextSpan : SvgTextBase public class SvgTextSpan : SvgTextBase
{ {
public override SvgElement DeepCopy() public override SvgElement DeepCopy()
{ {
return DeepCopy<SvgTextSpan>(); return DeepCopy<SvgTextSpan>();
} }
public override SvgElement DeepCopy<T>() public override SvgElement DeepCopy<T>()
{ {
var newObj = base.DeepCopy<T>() as SvgTextSpan; var newObj = base.DeepCopy<T>() as SvgTextSpan;
newObj.X = this.X; newObj.X = this.X;
newObj.Y = this.Y; newObj.Y = this.Y;
newObj.Dx = this.Dx; newObj.Dx = this.Dx;
newObj.Dy = this.Dy; newObj.Dy = this.Dy;
newObj.Text = this.Text; newObj.Text = this.Text;
return newObj; return newObj;
} }
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment