Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
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
d5c84b66
Commit
d5c84b66
authored
16 years ago
by
Axyonych
Browse files
Options
Download
Email Patches
Plain Diff
-Fixed SvgRectangle default fill color.
parent
ab3a7c58
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Basic Shapes/SvgRectangle.cs
+72
-49
Basic Shapes/SvgRectangle.cs
with
72 additions
and
49 deletions
+72
-49
Basic Shapes/SvgRectangle.cs
+
72
-
49
View file @
d5c84b66
using
System
;
using
System.Collections.Generic
;
using
System.Text
;
using
System.Drawing
;
using
System.Drawing.Drawing2D
;
using
System.Xml
;
using
System.ComponentModel
;
namespace
Svg
{
[
Serializable
()
]
[
Serializable
]
public
class
SvgRectangle
:
SvgGraphicsElement
{
private
SvgUnit
_width
;
private
SvgUnit
_height
;
private
SvgUnit
_x
;
private
SvgUnit
_y
;
private
SvgUnit
_cornerRadiusX
;
private
SvgUnit
_cornerRadiusY
;
private
SvgUnit
_height
;
private
GraphicsPath
_path
;
private
SvgUnit
_width
;
private
SvgUnit
_x
;
private
SvgUnit
_y
;
public
SvgRectangle
()
{
_width
=
new
SvgUnit
(
0.0f
);
_height
=
new
SvgUnit
(
0.0f
);
}
public
SvgPoint
Location
{
get
{
return
new
SvgPoint
(
this
.
X
,
this
.
Y
);
}
get
{
return
new
SvgPoint
(
X
,
Y
);
}
}
public
override
SvgPaintServer
Fill
{
get
{
return
(
this
.
Attributes
[
"Fill"
]
==
null
)
?
new
SvgColourServer
(
Color
.
Black
)
:
(
SvgPaintServer
)
this
.
Attributes
[
"Fill"
];
}
set
{
this
.
Attributes
[
"Fill"
]
=
value
;
}
}
[
SvgAttribute
(
"x"
)]
public
SvgUnit
X
{
get
{
return
this
.
_x
;
}
set
{
this
.
_x
=
value
;
this
.
IsPathDirty
=
true
;
}
get
{
return
_x
;
}
set
{
_x
=
value
;
IsPathDirty
=
true
;
}
}
[
SvgAttribute
(
"y"
)]
public
SvgUnit
Y
{
get
{
return
this
.
_y
;
}
set
{
this
.
_y
=
value
;
this
.
IsPathDirty
=
true
;
}
get
{
return
_y
;
}
set
{
_y
=
value
;
IsPathDirty
=
true
;
}
}
[
SvgAttribute
(
"width"
)]
public
SvgUnit
Width
{
get
{
return
this
.
_width
;
}
set
{
this
.
_width
=
value
;
this
.
IsPathDirty
=
true
;
}
get
{
return
_width
;
}
set
{
_width
=
value
;
IsPathDirty
=
true
;
}
}
[
SvgAttribute
(
"height"
)]
public
SvgUnit
Height
{
get
{
return
this
.
_height
;
}
set
{
this
.
_height
=
value
;
this
.
IsPathDirty
=
true
;
}
get
{
return
_height
;
}
set
{
_height
=
value
;
IsPathDirty
=
true
;
}
}
[
SvgAttribute
(
"rx"
)]
...
...
@@ -58,12 +82,16 @@ namespace Svg
get
{
// If ry has been set and rx hasn't, use it's value
if
(
this
.
_cornerRadiusX
.
Value
==
0.0f
&&
this
.
_cornerRadiusY
.
Value
>
0.0f
)
return
this
.
_cornerRadiusY
;
if
(
_cornerRadiusX
.
Value
==
0.0f
&&
_cornerRadiusY
.
Value
>
0.0f
)
return
_cornerRadiusY
;
return
this
.
_cornerRadiusX
;
return
_cornerRadiusX
;
}
set
{
_cornerRadiusX
=
value
;
IsPathDirty
=
true
;
}
set
{
this
.
_cornerRadiusX
=
value
;
this
.
IsPathDirty
=
true
;
}
}
[
SvgAttribute
(
"ry"
)]
...
...
@@ -72,38 +100,39 @@ namespace Svg
get
{
// If rx has been set and ry hasn't, use it's value
if
(
this
.
_cornerRadiusY
.
Value
==
0.0f
&&
this
.
_cornerRadiusX
.
Value
>
0.0f
)
return
this
.
_cornerRadiusX
;
if
(
_cornerRadiusY
.
Value
==
0.0f
&&
_cornerRadiusX
.
Value
>
0.0f
)
return
_cornerRadiusX
;
return
this
.
_cornerRadiusY
;
return
_cornerRadiusY
;
}
set
{
this
.
_cornerRadiusY
=
value
;
this
.
IsPathDirty
=
true
;
_cornerRadiusY
=
value
;
IsPathDirty
=
true
;
}
}
protected
override
bool
RequiresSmoothRendering
{
get
{
return
(
this
.
CornerRadiusX
.
Value
>
0
||
this
.
CornerRadiusY
.
Value
>
0
);
}
get
{
return
(
CornerRadiusX
.
Value
>
0
||
CornerRadiusY
.
Value
>
0
);
}
}
public
override
RectangleF
Bounds
{
get
{
return
this
.
Path
.
GetBounds
();
}
get
{
return
Path
.
GetBounds
();
}
}
public
override
GraphicsPath
Path
{
get
{
if
(
this
.
_path
==
null
||
this
.
IsPathDirty
)
if
(
_path
==
null
||
IsPathDirty
)
{
// If the corners aren't to be rounded just create a rectangle
if
(
this
.
CornerRadiusX
.
Value
==
0.0f
&&
this
.
CornerRadiusY
.
Value
==
0.0f
)
if
(
CornerRadiusX
.
Value
==
0.0f
&&
CornerRadiusY
.
Value
==
0.0f
)
{
RectangleF
rectangle
=
new
RectangleF
(
this
.
Location
.
ToDeviceValue
(),
new
SizeF
(
this
.
Width
.
ToDeviceValue
(),
this
.
Height
.
ToDeviceValue
()));
var
rectangle
=
new
RectangleF
(
Location
.
ToDeviceValue
(),
new
SizeF
(
Width
.
ToDeviceValue
(),
Height
.
ToDeviceValue
()));
_path
=
new
GraphicsPath
();
_path
.
StartFigure
();
...
...
@@ -113,14 +142,14 @@ namespace Svg
else
{
_path
=
new
GraphicsPath
();
RectangleF
arcBounds
=
new
RectangleF
();
PointF
lineStart
=
new
PointF
();
PointF
lineEnd
=
new
PointF
();
float
width
=
this
.
Width
.
ToDeviceValue
();
float
height
=
this
.
Height
.
ToDeviceValue
();
float
rx
=
this
.
CornerRadiusX
.
ToDeviceValue
();
float
ry
=
this
.
CornerRadiusY
.
ToDeviceValue
();
PointF
location
=
this
.
Location
.
ToDeviceValue
();
var
arcBounds
=
new
RectangleF
();
var
lineStart
=
new
PointF
();
var
lineEnd
=
new
PointF
();
var
width
=
Width
.
ToDeviceValue
();
var
height
=
Height
.
ToDeviceValue
();
var
rx
=
CornerRadiusX
.
ToDeviceValue
();
var
ry
=
CornerRadiusY
.
ToDeviceValue
();
var
location
=
Location
.
ToDeviceValue
();
// Start
_path
.
StartFigure
();
...
...
@@ -132,7 +161,7 @@ namespace Svg
_path
.
AddArc
(
arcBounds
,
180
,
90
);
// Add first line
lineStart
.
X
=
location
.
X
+
rx
;
lineStart
.
X
=
location
.
X
+
rx
;
lineStart
.
Y
=
location
.
Y
;
lineEnd
.
X
=
location
.
X
+
width
-
rx
;
lineEnd
.
Y
=
lineStart
.
Y
;
...
...
@@ -174,7 +203,7 @@ namespace Svg
// Close
_path
.
CloseFigure
();
}
this
.
IsPathDirty
=
false
;
IsPathDirty
=
false
;
}
return
_path
;
}
...
...
@@ -182,14 +211,8 @@ namespace Svg
protected
override
void
Render
(
Graphics
graphics
)
{
if
(
this
.
Width
.
Value
>
0.0f
&&
this
.
Height
.
Value
>
0.0f
)
if
(
Width
.
Value
>
0.0f
&&
Height
.
Value
>
0.0f
)
base
.
Render
(
graphics
);
}
public
SvgRectangle
()
{
this
.
_width
=
new
SvgUnit
(
0.0f
);
this
.
_height
=
new
SvgUnit
(
0.0f
);
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
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
Menu
Projects
Groups
Snippets
Help