using System; using System.Collections.Generic; using System.Text; using System.Drawing; using System.Drawing.Drawing2D; using System.Xml; using System.Web.UI.WebControls; using System.ComponentModel; namespace Svg { /// /// An SVG element to render circles to the document. /// public class SvgCircle : SvgGraphicsElement { private GraphicsPath _path; /// /// Gets the center point of the circle. /// /// The center. public SvgPoint Center { get { return new SvgPoint(this.CenterX, this.CenterY); } } /// /// Gets or sets the center X co-ordinate. /// /// The center X. [SvgAttribute("cx")] public SvgUnit CenterX { get { return this.Attributes.GetAttribute("cx"); } set { if (this.Attributes.GetAttribute("cx") != value) { this.Attributes["cx"] = value; this.IsPathDirty = true; } } } /// /// Gets or sets the center Y co-ordinate. /// /// The center Y. [SvgAttribute("cy")] public SvgUnit CenterY { get { return this.Attributes.GetAttribute("cy"); } set { if (this.Attributes.GetAttribute("cy") != value) { this.Attributes["cy"] = value; this.IsPathDirty = true; } } } /// /// Gets or sets the radius of the circle. /// /// The radius. [SvgAttribute("r")] public SvgUnit Radius { get { return this.Attributes.GetAttribute("r"); } set { if (this.Attributes.GetAttribute("r") != value) { this.Attributes["r"] = value; this.IsPathDirty = true; } } } /// /// Gets the name of the element. /// protected override string ElementName { get { return "circle"; } } /// /// Gets the bounds of the circle. /// /// The rectangular bounds of the circle. public override RectangleF Bounds { get { return this.Path.GetBounds(); } } /// /// Gets a value indicating whether the circle requires anti-aliasing when being rendered. /// /// /// true if the circle requires anti-aliasing; otherwise, false. /// protected override bool RequiresSmoothRendering { get { return true; } } /// /// Gets the representing this element. /// public override GraphicsPath Path { get { if (this._path == null || this.IsPathDirty) { _path = new GraphicsPath(); _path.StartFigure(); _path.AddEllipse(this.Center.ToDeviceValue().X - this.Radius.ToDeviceValue(), this.Center.ToDeviceValue().Y - this.Radius.ToDeviceValue(), 2 * this.Radius.ToDeviceValue(), 2 * this.Radius.ToDeviceValue()); _path.CloseFigure(); this.IsPathDirty = false; } return _path; } } /// /// Renders the circle to the specified object. /// /// The graphics object. protected override void Render(Graphics graphics) { // Don't draw if there is no radius set if (this.Radius.Value > 0.0f) { base.Render(graphics); } } /// /// Initializes a new instance of the class. /// public SvgCircle() { } } }