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
c912ea85
Commit
c912ea85
authored
Dec 19, 2008
by
davescriven
Browse files
- Renamed SvgGraphicsElement to SvgVisualElement to better describe what the base class represents.
parent
b6c5fa36
Changes
24
Show whitespace changes
Inline
Side-by-side
Basic Shapes/SvgCircle.cs
View file @
c912ea85
...
@@ -12,7 +12,7 @@ namespace Svg
...
@@ -12,7 +12,7 @@ namespace Svg
/// <summary>
/// <summary>
/// An SVG element to render circles to the document.
/// An SVG element to render circles to the document.
/// </summary>
/// </summary>
public
class
SvgCircle
:
Svg
Graphics
Element
public
class
SvgCircle
:
Svg
Visual
Element
{
{
private
GraphicsPath
_path
;
private
GraphicsPath
_path
;
...
...
Basic Shapes/SvgEllipse.cs
View file @
c912ea85
...
@@ -11,7 +11,7 @@ namespace Svg
...
@@ -11,7 +11,7 @@ namespace Svg
/// <summary>
/// <summary>
/// Represents and SVG ellipse element.
/// Represents and SVG ellipse element.
/// </summary>
/// </summary>
public
class
SvgEllipse
:
Svg
Graphics
Element
public
class
SvgEllipse
:
Svg
Visual
Element
{
{
private
SvgUnit
_radiusX
;
private
SvgUnit
_radiusX
;
private
SvgUnit
_radiusY
;
private
SvgUnit
_radiusY
;
...
...
Basic Shapes/SvgLine.cs
View file @
c912ea85
...
@@ -10,7 +10,7 @@ namespace Svg
...
@@ -10,7 +10,7 @@ namespace Svg
/// <summary>
/// <summary>
/// Represents and SVG line element.
/// Represents and SVG line element.
/// </summary>
/// </summary>
public
class
SvgLine
:
Svg
Graphics
Element
public
class
SvgLine
:
Svg
Visual
Element
{
{
private
SvgUnit
_startX
;
private
SvgUnit
_startX
;
private
SvgUnit
_startY
;
private
SvgUnit
_startY
;
...
...
Basic Shapes/SvgPolygon.cs
View file @
c912ea85
...
@@ -11,7 +11,7 @@ namespace Svg
...
@@ -11,7 +11,7 @@ namespace Svg
/// <summary>
/// <summary>
/// SvgPolygon defines a closed shape consisting of a set of connected straight line segments.
/// SvgPolygon defines a closed shape consisting of a set of connected straight line segments.
/// </summary>
/// </summary>
public
class
SvgPolygon
:
Svg
Graphics
Element
public
class
SvgPolygon
:
Svg
Visual
Element
{
{
protected
GraphicsPath
_path
;
protected
GraphicsPath
_path
;
protected
SvgUnitCollection
_points
;
protected
SvgUnitCollection
_points
;
...
...
Basic Shapes/SvgPolyline.cs
View file @
c912ea85
...
@@ -8,7 +8,7 @@ using System.Diagnostics;
...
@@ -8,7 +8,7 @@ using System.Diagnostics;
namespace
Svg
namespace
Svg
{
{
/// <summary>
/// <summary>
/// SvgPolyline defines a set of connected straight line segments. Typically, SvgPolyline defines open shapes.
/// SvgPolyline defines a set of connected straight line segments. Typically,
<see cref="
SvgPolyline
"/>
defines open shapes.
/// </summary>
/// </summary>
public
class
SvgPolyline
:
SvgPolygon
public
class
SvgPolyline
:
SvgPolygon
{
{
...
...
Basic Shapes/SvgRectangle.cs
View file @
c912ea85
...
@@ -7,7 +7,7 @@ namespace Svg
...
@@ -7,7 +7,7 @@ namespace Svg
/// <summary>
/// <summary>
/// Represents and SVG rectangle that could also have reounded edges.
/// Represents and SVG rectangle that could also have reounded edges.
/// </summary>
/// </summary>
public
class
SvgRectangle
:
Svg
Graphics
Element
public
class
SvgRectangle
:
Svg
Visual
Element
{
{
private
SvgUnit
_cornerRadiusX
;
private
SvgUnit
_cornerRadiusX
;
private
SvgUnit
_cornerRadiusY
;
private
SvgUnit
_cornerRadiusY
;
...
...
Basic Shapes/Svg
Graphics
Element.cs
→
Basic Shapes/Svg
Visual
Element.cs
View file @
c912ea85
...
@@ -13,7 +13,7 @@ namespace Svg
...
@@ -13,7 +13,7 @@ namespace Svg
/// <summary>
/// <summary>
/// The class that all SVG elements should derive from when they are to be rendered.
/// The class that all SVG elements should derive from when they are to be rendered.
/// </summary>
/// </summary>
public
abstract
partial
class
Svg
Graphics
Element
:
SvgElement
,
ISvgStylable
,
ISvgClipable
public
abstract
partial
class
Svg
Visual
Element
:
SvgElement
,
ISvgStylable
,
ISvgClipable
{
{
private
bool
_dirty
;
private
bool
_dirty
;
private
bool
_requiresSmoothRendering
;
private
bool
_requiresSmoothRendering
;
...
@@ -62,7 +62,7 @@ namespace Svg
...
@@ -62,7 +62,7 @@ namespace Svg
/// <summary>
/// <summary>
/// Initializes a new instance of the <see cref="SvgGraphicsElement"/> class.
/// Initializes a new instance of the <see cref="SvgGraphicsElement"/> class.
/// </summary>
/// </summary>
public
Svg
Graphics
Element
()
public
Svg
Visual
Element
()
{
{
this
.
_dirty
=
true
;
this
.
_dirty
=
true
;
this
.
_requiresSmoothRendering
=
false
;
this
.
_requiresSmoothRendering
=
false
;
...
@@ -130,6 +130,10 @@ namespace Svg
...
@@ -130,6 +130,10 @@ namespace Svg
}
}
}
}
/// <summary>
/// Sets the clipping region of the specified <see cref="SvgRenderer"/>.
/// </summary>
/// <param name="renderer">The <see cref="SvgRenderer"/> to have its clipping region set.</param>
protected
internal
virtual
void
SetClip
(
SvgRenderer
renderer
)
protected
internal
virtual
void
SetClip
(
SvgRenderer
renderer
)
{
{
if
(
this
.
ClipPath
!=
null
)
if
(
this
.
ClipPath
!=
null
)
...
@@ -144,6 +148,10 @@ namespace Svg
...
@@ -144,6 +148,10 @@ namespace Svg
}
}
}
}
/// <summary>
/// Resets the clipping region of the specified <see cref="SvgRenderer"/> back to where it was before the <see cref="SetClip"/> method was called.
/// </summary>
/// <param name="renderer">The <see cref="SvgRenderer"/> to have its clipping region reset.</param>
protected
internal
virtual
void
ResetClip
(
SvgRenderer
renderer
)
protected
internal
virtual
void
ResetClip
(
SvgRenderer
renderer
)
{
{
if
(
this
.
ClipPath
!=
null
)
if
(
this
.
ClipPath
!=
null
)
...
@@ -153,11 +161,19 @@ namespace Svg
...
@@ -153,11 +161,19 @@ namespace Svg
}
}
}
}
/// <summary>
/// Sets the clipping region of the specified <see cref="SvgRenderer"/>.
/// </summary>
/// <param name="renderer">The <see cref="SvgRenderer"/> to have its clipping region set.</param>
void
ISvgClipable
.
SetClip
(
SvgRenderer
renderer
)
void
ISvgClipable
.
SetClip
(
SvgRenderer
renderer
)
{
{
this
.
SetClip
(
renderer
);
this
.
SetClip
(
renderer
);
}
}
/// <summary>
/// Resets the clipping region of the specified <see cref="SvgRenderer"/> back to where it was before the <see cref="SetClip"/> method was called.
/// </summary>
/// <param name="renderer">The <see cref="SvgRenderer"/> to have its clipping region reset.</param>
void
ISvgClipable
.
ResetClip
(
SvgRenderer
renderer
)
void
ISvgClipable
.
ResetClip
(
SvgRenderer
renderer
)
{
{
this
.
ResetClip
(
renderer
);
this
.
ResetClip
(
renderer
);
...
...
Basic Shapes/Svg
Graphics
ElementEvents.cs
→
Basic Shapes/Svg
Visual
ElementEvents.cs
View file @
c912ea85
...
@@ -4,7 +4,7 @@ using System.Text;
...
@@ -4,7 +4,7 @@ using System.Text;
namespace
Svg
namespace
Svg
{
{
public
abstract
partial
class
Svg
Graphics
Element
public
abstract
partial
class
Svg
Visual
Element
{
{
private
static
readonly
object
_mouseOverKey
=
new
object
();
private
static
readonly
object
_mouseOverKey
=
new
object
();
private
static
readonly
object
_mouseOutKey
=
new
object
();
private
static
readonly
object
_mouseOutKey
=
new
object
();
...
...
Basic Shapes/Svg
Graphics
ElementStyle.cs
→
Basic Shapes/Svg
Visual
ElementStyle.cs
View file @
c912ea85
...
@@ -6,7 +6,7 @@ using System.ComponentModel;
...
@@ -6,7 +6,7 @@ using System.ComponentModel;
namespace
Svg
namespace
Svg
{
{
public
abstract
partial
class
Svg
Graphics
Element
public
abstract
partial
class
Svg
Visual
Element
{
{
private
static
float
FixOpacityValue
(
float
value
)
private
static
float
FixOpacityValue
(
float
value
)
{
{
...
...
Clipping and Masking/ISvgClipable.cs
View file @
c912ea85
...
@@ -6,13 +6,24 @@ using System.Drawing.Drawing2D;
...
@@ -6,13 +6,24 @@ using System.Drawing.Drawing2D;
namespace
Svg
namespace
Svg
{
{
/// <summary>
/// Defines the methods and properties that an <see cref="SvgElement"/> must implement to support clipping.
/// </summary>
public
interface
ISvgClipable
public
interface
ISvgClipable
{
{
/// <summary>
/// <summary>
/// Gets or sets the ID of the associated <see cref="SvgClipPath"/> if one has been specified.
/// Gets or sets the ID of the associated <see cref="SvgClipPath"/> if one has been specified.
/// </summary>
/// </summary>
Uri
ClipPath
{
get
;
set
;
}
Uri
ClipPath
{
get
;
set
;
}
/// <summary>
/// Sets the clipping region of the specified <see cref="SvgRenderer"/>.
/// </summary>
/// <param name="renderer">The <see cref="SvgRenderer"/> to have its clipping region set.</param>
void
SetClip
(
SvgRenderer
renderer
);
void
SetClip
(
SvgRenderer
renderer
);
/// <summary>
/// Resets the clipping region of the specified <see cref="SvgRenderer"/> back to where it was before the <see cref="SetClip"/> method was called.
/// </summary>
/// <param name="renderer">The <see cref="SvgRenderer"/> to have its clipping region reset.</param>
void
ResetClip
(
SvgRenderer
renderer
);
void
ResetClip
(
SvgRenderer
renderer
);
}
}
}
}
\ No newline at end of file
Clipping and Masking/SvgClipPath.cs
View file @
c912ea85
...
@@ -61,7 +61,7 @@ namespace Svg
...
@@ -61,7 +61,7 @@ namespace Svg
/// <param name="element"></param>
/// <param name="element"></param>
private
void
ComplementRegion
(
Region
region
,
SvgElement
element
)
private
void
ComplementRegion
(
Region
region
,
SvgElement
element
)
{
{
Svg
Graphics
Element
graphicsElement
=
element
as
Svg
Graphics
Element
;
Svg
Visual
Element
graphicsElement
=
element
as
Svg
Visual
Element
;
if
(
graphicsElement
!=
null
&&
graphicsElement
.
Path
!=
null
)
if
(
graphicsElement
!=
null
&&
graphicsElement
.
Path
!=
null
)
{
{
...
...
Document Structure/SvgDocument.cs
View file @
c912ea85
...
@@ -41,7 +41,9 @@ namespace Svg
...
@@ -41,7 +41,9 @@ namespace Svg
get
get
{
{
if
(
_idManager
==
null
)
if
(
_idManager
==
null
)
{
_idManager
=
new
SvgElementIdManager
(
this
);
_idManager
=
new
SvgElementIdManager
(
this
);
}
return
_idManager
;
return
_idManager
;
}
}
...
@@ -122,6 +124,11 @@ namespace Svg
...
@@ -122,6 +124,11 @@ namespace Svg
/// <returns>An <see cref="SvgDocument"/> with the contents loaded.</returns>
/// <returns>An <see cref="SvgDocument"/> with the contents loaded.</returns>
public
static
SvgDocument
Open
(
string
path
,
Dictionary
<
string
,
string
>
entities
)
public
static
SvgDocument
Open
(
string
path
,
Dictionary
<
string
,
string
>
entities
)
{
{
if
(
string
.
IsNullOrEmpty
(
path
))
{
throw
new
ArgumentNullException
(
"path"
);
}
if
(!
File
.
Exists
(
path
))
if
(!
File
.
Exists
(
path
))
{
{
throw
new
FileNotFoundException
(
"The specified document cannot be found."
,
path
);
throw
new
FileNotFoundException
(
"The specified document cannot be found."
,
path
);
...
@@ -146,6 +153,11 @@ namespace Svg
...
@@ -146,6 +153,11 @@ namespace Svg
/// <param name="entities">Custom entity definitions.</param>
/// <param name="entities">Custom entity definitions.</param>
public
static
SvgDocument
Open
(
Stream
stream
,
Dictionary
<
string
,
string
>
entities
)
public
static
SvgDocument
Open
(
Stream
stream
,
Dictionary
<
string
,
string
>
entities
)
{
{
if
(
stream
==
null
)
{
throw
new
ArgumentNullException
(
"stream"
);
}
Trace
.
TraceInformation
(
"Begin Read"
);
Trace
.
TraceInformation
(
"Begin Read"
);
using
(
var
reader
=
new
SvgTextReader
(
stream
,
entities
))
using
(
var
reader
=
new
SvgTextReader
(
stream
,
entities
))
...
...
Document Structure/SvgGroup.cs
View file @
c912ea85
...
@@ -9,7 +9,7 @@ namespace Svg
...
@@ -9,7 +9,7 @@ namespace Svg
/// <summary>
/// <summary>
/// An element used to group SVG shapes.
/// An element used to group SVG shapes.
/// </summary>
/// </summary>
public
class
SvgGroup
:
Svg
Graphics
Element
public
class
SvgGroup
:
Svg
Visual
Element
{
{
public
SvgGroup
()
public
SvgGroup
()
{
{
...
...
Document Structure/SvgUse.cs
View file @
c912ea85
...
@@ -8,7 +8,7 @@ using System.Drawing.Drawing2D;
...
@@ -8,7 +8,7 @@ using System.Drawing.Drawing2D;
namespace
Svg
namespace
Svg
{
{
public
class
SvgUse
:
Svg
Graphics
Element
public
class
SvgUse
:
Svg
Visual
Element
{
{
private
Uri
_referencedElement
;
private
Uri
_referencedElement
;
...
@@ -48,7 +48,7 @@ namespace Svg
...
@@ -48,7 +48,7 @@ namespace Svg
{
{
get
get
{
{
Svg
Graphics
Element
element
=
(
Svg
Graphics
Element
)
this
.
OwnerDocument
.
IdManager
.
GetElementById
(
this
.
ReferencedElement
);
Svg
Visual
Element
element
=
(
Svg
Visual
Element
)
this
.
OwnerDocument
.
IdManager
.
GetElementById
(
this
.
ReferencedElement
);
return
(
element
!=
null
)
?
element
.
Path
:
null
;
return
(
element
!=
null
)
?
element
.
Path
:
null
;
}
}
}
}
...
@@ -73,7 +73,7 @@ namespace Svg
...
@@ -73,7 +73,7 @@ namespace Svg
{
{
this
.
PushTransforms
(
renderer
);
this
.
PushTransforms
(
renderer
);
Svg
Graphics
Element
element
=
(
Svg
Graphics
Element
)
this
.
OwnerDocument
.
IdManager
.
GetElementById
(
this
.
ReferencedElement
);
Svg
Visual
Element
element
=
(
Svg
Visual
Element
)
this
.
OwnerDocument
.
IdManager
.
GetElementById
(
this
.
ReferencedElement
);
// For the time of rendering we want the referenced element to inherit
// For the time of rendering we want the referenced element to inherit
// this elements transforms
// this elements transforms
SvgElement
parent
=
element
.
_parent
;
SvgElement
parent
=
element
.
_parent
;
...
...
Painting/SvgColourServer.cs
View file @
c912ea85
...
@@ -24,7 +24,7 @@ namespace Svg
...
@@ -24,7 +24,7 @@ namespace Svg
set
{
this
.
_colour
=
value
;
}
set
{
this
.
_colour
=
value
;
}
}
}
public
override
Brush
GetBrush
(
Svg
Graphics
Element
styleOwner
,
float
opacity
)
public
override
Brush
GetBrush
(
Svg
Visual
Element
styleOwner
,
float
opacity
)
{
{
int
alpha
=
(
int
)((
opacity
*
(
this
.
Colour
.
A
/
255
)
)
*
255
);
int
alpha
=
(
int
)((
opacity
*
(
this
.
Colour
.
A
/
255
)
)
*
255
);
Color
colour
=
Color
.
FromArgb
(
alpha
,
this
.
Colour
);
Color
colour
=
Color
.
FromArgb
(
alpha
,
this
.
Colour
);
...
...
Painting/SvgGradientServer.cs
View file @
c912ea85
...
@@ -7,6 +7,9 @@ using System.Drawing.Drawing2D;
...
@@ -7,6 +7,9 @@ using System.Drawing.Drawing2D;
namespace
Svg
namespace
Svg
{
{
/// <summary>
/// Provides the base class for all paint servers that wish to render a gradient.
/// </summary>
public
abstract
class
SvgGradientServer
:
SvgPaintServer
public
abstract
class
SvgGradientServer
:
SvgPaintServer
{
{
private
SvgCoordinateUnits
_gradientUnits
;
private
SvgCoordinateUnits
_gradientUnits
;
...
@@ -14,6 +17,9 @@ namespace Svg
...
@@ -14,6 +17,9 @@ namespace Svg
private
SvgGradientServer
_inheritGradient
;
private
SvgGradientServer
_inheritGradient
;
private
List
<
SvgGradientStop
>
_stops
;
private
List
<
SvgGradientStop
>
_stops
;
/// <summary>
/// Initializes a new instance of the <see cref="SvgGradientServer"/> class.
/// </summary>
internal
SvgGradientServer
()
internal
SvgGradientServer
()
{
{
this
.
GradientUnits
=
SvgCoordinateUnits
.
ObjectBoundingBox
;
this
.
GradientUnits
=
SvgCoordinateUnits
.
ObjectBoundingBox
;
...
@@ -23,7 +29,10 @@ namespace Svg
...
@@ -23,7 +29,10 @@ namespace Svg
protected
override
void
AddElement
(
SvgElement
child
,
int
index
)
protected
override
void
AddElement
(
SvgElement
child
,
int
index
)
{
{
if
(
child
is
SvgGradientStop
)
if
(
child
is
SvgGradientStop
)
{
this
.
Stops
.
Add
((
SvgGradientStop
)
child
);
this
.
Stops
.
Add
((
SvgGradientStop
)
child
);
}
base
.
AddElement
(
child
,
index
);
base
.
AddElement
(
child
,
index
);
}
}
...
@@ -59,7 +68,7 @@ namespace Svg
...
@@ -59,7 +68,7 @@ namespace Svg
set
{
this
.
_inheritGradient
=
value
;
}
set
{
this
.
_inheritGradient
=
value
;
}
}
}
protected
ColorBlend
GetColourBlend
(
Svg
Graphics
Element
owner
,
float
opacity
)
protected
ColorBlend
GetColourBlend
(
Svg
Visual
Element
owner
,
float
opacity
)
{
{
ColorBlend
blend
=
new
ColorBlend
();
ColorBlend
blend
=
new
ColorBlend
();
int
colourBlends
=
this
.
Stops
.
Count
;
int
colourBlends
=
this
.
Stops
.
Count
;
...
...
Painting/SvgLinearGradientServer.cs
View file @
c912ea85
...
@@ -72,7 +72,7 @@ namespace Svg
...
@@ -72,7 +72,7 @@ namespace Svg
get
{
return
new
SvgPoint
(
this
.
X2
,
this
.
Y2
);
}
get
{
return
new
SvgPoint
(
this
.
X2
,
this
.
Y2
);
}
}
}
public
override
Brush
GetBrush
(
Svg
Graphics
Element
owner
,
float
opacity
)
public
override
Brush
GetBrush
(
Svg
Visual
Element
owner
,
float
opacity
)
{
{
// Need at least 2 colours to do the gradient fill
// Need at least 2 colours to do the gradient fill
if
(
this
.
Stops
.
Count
<
2
)
if
(
this
.
Stops
.
Count
<
2
)
...
...
Painting/SvgPaintServer.cs
View file @
c912ea85
...
@@ -22,7 +22,7 @@ namespace Svg
...
@@ -22,7 +22,7 @@ namespace Svg
// Never render paint servers or their children
// Never render paint servers or their children
}
}
public
abstract
Brush
GetBrush
(
Svg
Graphics
Element
styleOwner
,
float
opacity
);
public
abstract
Brush
GetBrush
(
Svg
Visual
Element
styleOwner
,
float
opacity
);
public
override
string
ToString
()
public
override
string
ToString
()
{
{
...
...
Painting/SvgPatternServer.cs
View file @
c912ea85
...
@@ -60,7 +60,7 @@ namespace Svg
...
@@ -60,7 +60,7 @@ namespace Svg
this
.
_height
=
new
SvgUnit
(
0.0f
);
this
.
_height
=
new
SvgUnit
(
0.0f
);
}
}
public
override
Brush
GetBrush
(
Svg
Graphics
Element
renderingElement
,
float
opacity
)
public
override
Brush
GetBrush
(
Svg
Visual
Element
renderingElement
,
float
opacity
)
{
{
// If there aren't any children, return null
// If there aren't any children, return null
if
(
this
.
Children
.
Count
==
0
)
if
(
this
.
Children
.
Count
==
0
)
...
...
Painting/SvgRadialGradientServer.cs
View file @
c912ea85
...
@@ -50,7 +50,7 @@ namespace Svg
...
@@ -50,7 +50,7 @@ namespace Svg
{
{
}
}
public
override
Brush
GetBrush
(
Svg
Graphics
Element
renderingElement
,
float
opacity
)
public
override
Brush
GetBrush
(
Svg
Visual
Element
renderingElement
,
float
opacity
)
{
{
GraphicsPath
path
=
new
GraphicsPath
();
GraphicsPath
path
=
new
GraphicsPath
();
float
left
=
this
.
CenterX
.
ToDeviceValue
(
renderingElement
);
float
left
=
this
.
CenterX
.
ToDeviceValue
(
renderingElement
);
...
...
Prev
1
2
Next
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