Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ImportedProjects
SVG
Commits
ce8f2a64
Commit
ce8f2a64
authored
Jul 30, 2014
by
Eric Domke
Browse files
Fixing compile errors and spacing inconsistencies
parent
05c51974
Changes
9
Hide whitespace changes
Inline
Side-by-side
Source/Document Structure/SvgDescription.cs
View file @
ce8f2a64
...
...
@@ -14,8 +14,7 @@ namespace Svg
return
this
.
Content
;
}
public
override
SvgElement
DeepCopy
()
public
override
SvgElement
DeepCopy
()
{
return
DeepCopy
<
SvgDescription
>();
}
...
...
@@ -23,9 +22,7 @@ namespace Svg
public
override
SvgElement
DeepCopy
<
T
>()
{
var
newObj
=
base
.
DeepCopy
<
T
>()
as
SvgDescription
;
newObj
.
Text
=
this
.
Text
;
return
newObj
;
}
}
}
\ No newline at end of file
Source/Document Structure/SvgUse.cs
View file @
ce8f2a64
...
...
@@ -49,8 +49,8 @@ namespace Svg
/// </summary>
public
SvgUse
()
{
this
.
X
=
0
;
this
.
Y
=
0
;
this
.
X
=
0
;
this
.
Y
=
0
;
}
public
override
System
.
Drawing
.
Drawing2D
.
GraphicsPath
Path
...
...
@@ -69,16 +69,16 @@ namespace Svg
get
{
return
new
System
.
Drawing
.
RectangleF
();
}
}
// public override SvgElementCollection Children
// {
// get
// {
// SvgElement element = this.OwnerDocument.IdManager.GetElementById(this.ReferencedElement);
// SvgElementCollection elements = new SvgElementCollection(this, true);
// elements.Add(element);
// return elements;
// }
// }
// public override SvgElementCollection Children
// {
// get
// {
// SvgElement element = this.OwnerDocument.IdManager.GetElementById(this.ReferencedElement);
// SvgElementCollection elements = new SvgElementCollection(this, true);
// elements.Add(element);
// return elements;
// }
// }
protected
override
void
Render
(
SvgRenderer
renderer
)
{
...
...
@@ -99,20 +99,20 @@ namespace Svg
}
public
override
SvgElement
DeepCopy
()
{
return
DeepCopy
<
SvgUse
>();
}
public
override
SvgElement
DeepCopy
()
{
return
DeepCopy
<
SvgUse
>();
}
public
override
SvgElement
DeepCopy
<
T
>()
{
var
newObj
=
base
.
DeepCopy
<
T
>()
as
SvgUse
;
newObj
.
ReferencedElement
=
this
.
ReferencedElement
;
newObj
.
X
=
this
.
X
;
newObj
.
Y
=
this
.
Y
;
public
override
SvgElement
DeepCopy
<
T
>()
{
var
newObj
=
base
.
DeepCopy
<
T
>()
as
SvgUse
;
newObj
.
ReferencedElement
=
this
.
ReferencedElement
;
newObj
.
X
=
this
.
X
;
newObj
.
Y
=
this
.
Y
;
return
newObj
;
}
return
newObj
;
}
}
}
\ No newline at end of file
Source/Filter Effects/feGaussianBlur/SvgGaussianBlur.cs
View file @
ce8f2a64
...
...
@@ -14,10 +14,10 @@ namespace Svg.FilterEffects
[
SvgElement
(
"feGaussianBlur"
)]
public
class
SvgGaussianBlur
:
SvgFilterPrimitive
{
private
float
_stdDeviation
;
private
BlurType
_blurType
;
private
int
[]
_kernel
;
private
float
_stdDeviation
;
private
BlurType
_blurType
;
private
int
[]
_kernel
;
private
int
_kernelSum
;
private
int
[,]
_multable
;
...
...
@@ -220,10 +220,10 @@ namespace Svg.FilterEffects
}
}
/// <summary>
/// Gets or sets the radius of the blur (only allows for one value - not the two specified in the SVG Spec)
/// </summary>
[
SvgAttribute
(
"stdDeviation"
)]
/// <summary>
/// Gets or sets the radius of the blur (only allows for one value - not the two specified in the SVG Spec)
/// </summary>
[
SvgAttribute
(
"stdDeviation"
)]
public
float
StdDeviation
{
get
{
return
_stdDeviation
;
}
...
...
@@ -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
()
{
return
DeepCopy
<
SvgGaussianBlur
>();
}
public
override
SvgElement
DeepCopy
()
{
return
DeepCopy
<
SvgGaussianBlur
>();
}
public
override
SvgElement
DeepCopy
<
T
>()
{
var
newObj
=
base
.
DeepCopy
<
T
>()
as
SvgGaussianBlur
;
newObj
.
StdDeviation
=
this
.
StdDeviation
;
newObj
.
BlurType
=
this
.
BlurType
;
return
newObj
;
}
public
override
SvgElement
DeepCopy
<
T
>()
{
var
newObj
=
base
.
DeepCopy
<
T
>()
as
SvgGaussianBlur
;
newObj
.
StdDeviation
=
this
.
StdDeviation
;
newObj
.
BlurType
=
this
.
BlurType
;
return
newObj
;
}
}
}
\ No newline at end of file
Source/Painting/SvgLinearGradientServer.cs
View file @
ce8f2a64
...
...
@@ -130,7 +130,7 @@ namespace Svg
public
PointF
EndPoint
;
public
GradientPoints
(
PointF
startPoint
,
PointF
endPoint
)
{
{
this
.
StartPoint
=
startPoint
;
this
.
EndPoint
=
endPoint
;
}
...
...
@@ -193,7 +193,7 @@ namespace Svg
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
);
...
...
@@ -253,7 +253,7 @@ namespace Svg
private
float
Y1
{
get
;
get
;
set
;
}
...
...
Source/Paths/SvgClosePathSegment.cs
View file @
ce8f2a64
...
...
@@ -8,7 +8,6 @@ namespace Svg.Pathing
{
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.
if
(
graphicsPath
.
PointCount
>
0
&&
!
graphicsPath
.
PathPoints
[
0
].
Equals
(
graphicsPath
.
PathPoints
[
graphicsPath
.
PathPoints
.
Length
-
1
]))
{
...
...
@@ -19,11 +18,11 @@ namespace Svg.Pathing
}
graphicsPath
.
CloseFigure
();
}
public
override
string
ToString
()
{
return
"z"
;
}
{
return
"z"
;
}
}
}
\ No newline at end of file
Source/Svg.csproj
View file @
ce8f2a64
...
...
@@ -16,7 +16,7 @@
<OldToolsVersion>
3.5
</OldToolsVersion>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<TargetFrameworkVersion>
v
4.0
</TargetFrameworkVersion>
<TargetFrameworkVersion>
v
3.5
</TargetFrameworkVersion>
<IsWebBootstrapper>
false
</IsWebBootstrapper>
<SccProjectName>
</SccProjectName>
...
...
@@ -121,7 +121,6 @@
<Compile
Include=
"Extensions.cs"
/>
<Compile
Include=
"Painting\ISvgBoundable.cs"
/>
<Compile
Include=
"Painting\SvgDeferredPaintServer.cs"
/>
<Compile
Include=
"Painting\ISvgBoundable.cs"
/>
<Compile
Include=
"Painting\SvgMarker.cs"
/>
<Compile
Include=
"Document Structure\SvgDefinitionList.cs"
/>
<Compile
Include=
"Document Structure\SvgDescription.cs"
/>
...
...
Source/Text/SvgText.cs
View file @
ce8f2a64
...
...
@@ -17,17 +17,18 @@ namespace Svg
/// <summary>
/// Initializes the <see cref="SvgText"/> class.
/// </summary>
public
SvgText
()
:
base
()
{}
public
SvgText
()
:
base
()
{
}
/// <summary>
/// Initializes a new instance of the <see cref="SvgText"/> class.
/// </summary>
/// <param name="text">The text.</param>
public
SvgText
(
string
text
)
:
this
()
public
SvgText
(
string
text
)
:
this
()
{
this
.
Text
=
text
;
}
public
override
SvgElement
DeepCopy
()
{
return
DeepCopy
<
SvgText
>();
...
...
Source/Text/SvgTextBase.cs
View file @
ce8f2a64
...
...
@@ -16,7 +16,7 @@ namespace Svg
@default
,
preserve
}
public
abstract
class
SvgTextBase
:
SvgVisualElement
{
private
SvgUnitCollection
_x
=
new
SvgUnitCollection
();
...
...
@@ -28,7 +28,7 @@ namespace Svg
private
SvgTextAnchor
_textAnchor
=
SvgTextAnchor
.
Start
;
private
static
readonly
SvgRenderer
_stringMeasure
;
private
const
string
DefaultFontFamily
=
"Times New Roman"
;
private
XmlSpaceHandling
_space
=
XmlSpaceHandling
.
@default
;
/// <summary>
...
...
@@ -40,7 +40,7 @@ namespace Svg
_stringMeasure
=
SvgRenderer
.
FromImage
(
bitmap
);
_stringMeasure
.
TextRenderingHint
=
TextRenderingHint
.
AntiAlias
;
}
/// <summary>
/// Gets or sets the text to be rendered.
/// </summary>
...
...
@@ -68,16 +68,16 @@ namespace Svg
[
SvgAttribute
(
"x"
)]
public
virtual
SvgUnitCollection
X
{
get
{
return
this
.
_x
;
}
set
{
if
(
_x
!=
value
)
{
this
.
_x
=
value
;
this
.
IsPathDirty
=
true
;
OnAttributeChanged
(
new
AttributeEventArgs
{
Attribute
=
"x"
,
Value
=
value
});
}
}
get
{
return
this
.
_x
;
}
set
{
if
(
_x
!=
value
)
{
this
.
_x
=
value
;
this
.
IsPathDirty
=
true
;
OnAttributeChanged
(
new
AttributeEventArgs
{
Attribute
=
"x"
,
Value
=
value
});
}
}
}
/// <summary>
...
...
@@ -106,16 +106,16 @@ namespace Svg
[
SvgAttribute
(
"y"
)]
public
virtual
SvgUnitCollection
Y
{
get
{
return
this
.
_y
;
}
set
{
if
(
_y
!=
value
)
{
this
.
_y
=
value
;
this
.
IsPathDirty
=
true
;
OnAttributeChanged
(
new
AttributeEventArgs
{
Attribute
=
"y"
,
Value
=
value
});
}
}
get
{
return
this
.
_y
;
}
set
{
if
(
_y
!=
value
)
{
this
.
_y
=
value
;
this
.
IsPathDirty
=
true
;
OnAttributeChanged
(
new
AttributeEventArgs
{
Attribute
=
"y"
,
Value
=
value
});
}
}
}
/// <summary>
...
...
@@ -202,7 +202,7 @@ namespace Svg
private
static
string
ValidateFontFamily
(
string
fontFamilyList
)
{
// 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
;
...
...
@@ -261,7 +261,7 @@ namespace Svg
protected
class
BoundsData
{
private
List
<
NodeBounds
>
_nodes
=
new
List
<
NodeBounds
>();
public
IList
<
NodeBounds
>
Nodes
public
IList
<
NodeBounds
>
Nodes
{
get
{
return
_nodes
;
}
}
...
...
@@ -276,10 +276,10 @@ namespace Svg
float
totalWidth
=
0
;
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
)
select
n
).
ToList
();
if
(
nodes
.
FirstOrDefault
()
is
SvgContentNode
&&
_x
.
Count
>
1
)
{
string
ch
;
...
...
@@ -287,15 +287,18 @@ namespace Svg
nodes
.
RemoveAt
(
0
);
int
posCount
=
Math
.
Min
(
content
.
Content
.
Length
,
_x
.
Count
);
var
text
=
PrepareText
(
content
.
Content
,
false
,
(
nodes
.
Count
>
1
&&
nodes
[
1
]
is
SvgTextBase
));
for
(
var
i
=
0
;
i
<
posCount
;
i
++)
{
ch
=
(
i
==
posCount
-
1
?
text
.
Substring
(
i
)
:
text
.
Substring
(
i
,
1
));
stringBounds
=
_stringMeasure
.
MeasureString
(
ch
,
font
);
totalHeight
=
Math
.
Max
(
totalHeight
,
stringBounds
.
Height
);
result
.
Nodes
.
Add
(
new
NodeBounds
()
{
Bounds
=
stringBounds
,
Node
=
new
SvgContentNode
()
{
Content
=
ch
},
xOffset
=
(
i
==
0
?
0
:
_x
[
i
].
ToDeviceValue
(
this
)
-
_x
[
0
].
ToDeviceValue
(
this
))});
result
.
Nodes
.
Add
(
new
NodeBounds
()
{
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
{
// Measure the overall bounds of all the text
var
boundsData
=
GetTextBounds
();
var
font
=
GetFont
();
SvgTextBase
innerText
;
float
x
=
(
_x
.
Count
<
1
?
_calcX
:
_x
[
0
].
ToDeviceValue
(
this
))
+
(
_dx
.
Count
<
1
?
0
:
_dx
[
0
].
ToDeviceValue
(
this
));
...
...
@@ -379,7 +382,7 @@ namespace Svg
{
// Minus FontSize because the x/y coords mark the bottom left, not bottom top.
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
));
}
else
...
...
@@ -436,7 +439,7 @@ namespace Svg
{
fontSize
=
fontSizeUnit
.
ToDeviceValue
(
this
);
}
var
fontStyle
=
System
.
Drawing
.
FontStyle
.
Regular
;
// Get the font-weight
...
...
@@ -486,60 +489,60 @@ namespace Svg
/// Draws a string on a path at a specified location and with a specified font.
/// </summary>
internal
void
DrawString
(
GraphicsPath
path
,
float
x
,
float
y
,
Font
font
,
string
text
)
{
PointF
location
=
new
PointF
(
x
,
y
);
// No way to do letter-spacing or word-spacing, so do manually
if
(
this
.
LetterSpacing
.
Value
>
0.0f
||
this
.
WordSpacing
.
Value
>
0.0f
)
{
// Cut up into words, or just leave as required
string
[]
words
=
(
this
.
WordSpacing
.
Value
>
0.0f
)
?
text
.
Split
(
' '
)
:
new
string
[]
{
text
};
float
wordSpacing
=
this
.
WordSpacing
.
ToDeviceValue
(
this
);
float
letterSpacing
=
this
.
LetterSpacing
.
ToDeviceValue
(
this
);
float
start
=
x
;
foreach
(
string
word
in
words
)
{
// Only do if there is line spacing, just write the word otherwise
if
(
this
.
LetterSpacing
.
Value
>
0.0f
)
{
char
[]
characters
=
word
.
ToCharArray
();
foreach
(
char
currentCharacter
in
characters
)
{
{
PointF
location
=
new
PointF
(
x
,
y
);
// No way to do letter-spacing or word-spacing, so do manually
if
(
this
.
LetterSpacing
.
Value
>
0.0f
||
this
.
WordSpacing
.
Value
>
0.0f
)
{
// Cut up into words, or just leave as required
string
[]
words
=
(
this
.
WordSpacing
.
Value
>
0.0f
)
?
text
.
Split
(
' '
)
:
new
string
[]
{
text
};
float
wordSpacing
=
this
.
WordSpacing
.
ToDeviceValue
(
this
);
float
letterSpacing
=
this
.
LetterSpacing
.
ToDeviceValue
(
this
);
float
start
=
x
;
foreach
(
string
word
in
words
)
{
// Only do if there is line spacing, just write the word otherwise
if
(
this
.
LetterSpacing
.
Value
>
0.0f
)
{
char
[]
characters
=
word
.
ToCharArray
();
foreach
(
char
currentCharacter
in
characters
)
{
path
.
AddString
(
currentCharacter
.
ToString
(),
font
.
FontFamily
,
(
int
)
font
.
Style
,
font
.
Size
,
location
,
StringFormat
.
GenericTypographic
);
location
=
new
PointF
(
path
.
GetBounds
().
Width
+
start
+
letterSpacing
,
location
.
Y
);
}
}
else
{
location
=
new
PointF
(
path
.
GetBounds
().
Width
+
start
+
letterSpacing
,
location
.
Y
);
}
}
else
{
path
.
AddString
(
word
,
font
.
FontFamily
,
(
int
)
font
.
Style
,
font
.
Size
,
location
,
StringFormat
.
GenericTypographic
);
}
// Move the location of the word to be written along
location
=
new
PointF
(
path
.
GetBounds
().
Width
+
start
+
wordSpacing
,
location
.
Y
);
}
}
else
{
if
(!
string
.
IsNullOrEmpty
(
text
))
{
path
.
AddString
(
text
,
font
.
FontFamily
,
(
int
)
font
.
Style
,
font
.
Size
,
location
,
StringFormat
.
GenericTypographic
);
}
}
}
[
SvgAttribute
(
"onchange"
)]
}
// Move the location of the word to be written along
location
=
new
PointF
(
path
.
GetBounds
().
Width
+
start
+
wordSpacing
,
location
.
Y
);
}
}
else
{
if
(!
string
.
IsNullOrEmpty
(
text
))
{
path
.
AddString
(
text
,
font
.
FontFamily
,
(
int
)
font
.
Style
,
font
.
Size
,
location
,
StringFormat
.
GenericTypographic
);
}
}
}
[
SvgAttribute
(
"onchange"
)]
public
event
EventHandler
<
StringArg
>
Change
;
//change
//change
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
)
{
var
handler
=
Change
;
var
handler
=
Change
;
if
(
handler
!=
null
)
{
handler
(
sender
,
s
);
...
...
@@ -547,24 +550,24 @@ namespace Svg
}
#if Net4
public
override
void
RegisterEvents
(
ISvgEventCaller
caller
)
{
//register basic events
base
.
RegisterEvents
(
caller
);
//add change event for text
public
override
void
RegisterEvents
(
ISvgEventCaller
caller
)
{
//register basic events
base
.
RegisterEvents
(
caller
);
//add change event for text
caller
.
RegisterAction
<
string
,
string
>(
this
.
ID
+
"/onchange"
,
OnChange
);
}
public
override
void
UnregisterEvents
(
ISvgEventCaller
caller
)
{
//unregister base events
base
.
UnregisterEvents
(
caller
);
//unregister change event
caller
.
UnregisterAction
(
this
.
ID
+
"/onchange"
);
}
}
public
override
void
UnregisterEvents
(
ISvgEventCaller
caller
)
{
//unregister base events
base
.
UnregisterEvents
(
caller
);
//unregister change event
caller
.
UnregisterAction
(
this
.
ID
+
"/onchange"
);
}
#endif
}
}
Source/Text/SvgTextSpan.cs
View file @
ce8f2a64
...
...
@@ -8,24 +8,24 @@ using System.Text;
namespace
Svg
{
[
SvgElement
(
"tspan"
)]
public
class
SvgTextSpan
:
SvgTextBase
public
class
SvgTextSpan
:
SvgTextBase
{
public
override
SvgElement
DeepCopy
()
{
return
DeepCopy
<
SvgTextSpan
>();
}
public
override
SvgElement
DeepCopy
()
{
return
DeepCopy
<
SvgTextSpan
>();
}
public
override
SvgElement
DeepCopy
<
T
>()
{
var
newObj
=
base
.
DeepCopy
<
T
>()
as
SvgTextSpan
;
newObj
.
X
=
this
.
X
;
newObj
.
Y
=
this
.
Y
;
newObj
.
Dx
=
this
.
Dx
;
newObj
.
Dy
=
this
.
Dy
;
newObj
.
Text
=
this
.
Text
;
public
override
SvgElement
DeepCopy
<
T
>()
{
var
newObj
=
base
.
DeepCopy
<
T
>()
as
SvgTextSpan
;
newObj
.
X
=
this
.
X
;
newObj
.
Y
=
this
.
Y
;
newObj
.
Dx
=
this
.
Dx
;
newObj
.
Dy
=
this
.
Dy
;
newObj
.
Text
=
this
.
Text
;
return
newObj
;
}
return
newObj
;
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment