Back to top OpenSVG (c) Veridict AB, www.veridict.com
Edit this page

Class SvgElement

Represents the base class for all SVG elements.

Inheritance
object
SvgElement
SvgDefs
SvgStyle
SvgVisual
Implements
IXmlSerializable
IEquatable<SvgElement>
Inherited Members
object.Equals(object, object)
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: OpenSvg.SvgNodes
Assembly: OpenSvg.dll
Syntax
public abstract class SvgElement : IXmlSerializable, IEquatable<SvgElement>

Fields

| Edit this page View Source

id

Declaration
protected readonly StringAttr id
Field Value
Type Description
StringAttr

Properties

| Edit this page View Source

ID

Gets or sets the ID of the element.

Declaration
public string ID { get; set; }
Property Value
Type Description
string
| Edit this page View Source

Parent

Gets or sets the parent element of the element.

Declaration
public SvgElement? Parent { get; set; }
Property Value
Type Description
SvgElement
| Edit this page View Source

Root

Gets the root element of the element.

Declaration
public SvgElement Root { get; }
Property Value
Type Description
SvgElement
| Edit this page View Source

RootDocument

Gets the root document of the element.

Declaration
public SvgDocument RootDocument { get; }
Property Value
Type Description
SvgDocument
| Edit this page View Source

SvgName

Gets or sets the name of the SVG element.

Declaration
public abstract string SvgName { get; }
Property Value
Type Description
string
| Edit this page View Source

ViewPort

Gets the current viewport for the element.

Declaration
public Size ViewPort { get; }
Property Value
Type Description
Size

The absolute value for the viewport size, width and height.

Remarks
  • If the element is not an SvgDocument, the viewport will be equal to its closest SvgDocument ancestor.
  • If the closest SvgDocument ancestor has a relative defined size (e.g., 40%), the viewport will be calculated by traversing upwards, accumulating ratios until an ancestor with an absolute size is found.
  • If an SvgDocument has no size set, it is equivalent to having a ratio of 1 (100%).
  • If no topmost SvgDocument exists, or the topmost SvgDocument has a ratio or no size set, a default container size is assumed
See Also
ViewPortWidth
ViewPortHeight
DefaultContainerWidth
DefaultContainerHeight
| Edit this page View Source

ViewPortHeight

Gets the height of the current viewport for the element.

Declaration
public virtual float ViewPortHeight { get; }
Property Value
Type Description
float
| Edit this page View Source

ViewPortWidth

Gets the width of the current viewport for the element.

Declaration
public virtual float ViewPortWidth { get; }
Property Value
Type Description
float

Methods

| Edit this page View Source

Attributes()

Gets the attributes of the element.

Declaration
public IEnumerable<IAttr> Attributes()
Returns
Type Description
IEnumerable<IAttr>

The attributes of the element.

| Edit this page View Source

Equals(SvgElement?)

Determines whether the specified object is equal to the current object.

Declaration
public bool Equals(SvgElement? other)
Parameters
Type Name Description
SvgElement other

The object to compare with the current object.

Returns
Type Description
bool

true if the specified object is equal to the current object; otherwise, false.

| Edit this page View Source

Equals(object?)

Determines whether the specified object is equal to the current object.

Declaration
public override bool Equals(object? obj)
Parameters
Type Name Description
object obj

The object to compare with the current object.

Returns
Type Description
bool

true if the specified object is equal to the current object; otherwise, false.

Overrides
object.Equals(object)
| Edit this page View Source

GetHashCode()

Returns a hash code for the current object.

Declaration
public override int GetHashCode()
Returns
Type Description
int

A hash code for the current object.

Overrides
object.GetHashCode()
| Edit this page View Source

GetSchema()

Gets the schema for the element. Required by interface IXmlSerializable.

Declaration
public XmlSchema? GetSchema()
Returns
Type Description
XmlSchema

null

| Edit this page View Source

InformedEquals(SvgElement?)

Verbose comparison of two SvgElements, including all attributes and child elements.

Declaration
public (bool equal, string diffMessage) InformedEquals(SvgElement? other)
Parameters
Type Name Description
SvgElement other

The object to compare with the current object.

Returns
Type Description
(bool IsEqual, string ErrorMessage)

A tuple containing a boolean indicating whether the specified object is equal to the current object and a message describing the differences.

| Edit this page View Source

ReadXml(XmlReader)

Reads the XML representation of the element from the specified reader.

Declaration
public void ReadXml(XmlReader reader)
Parameters
Type Name Description
XmlReader reader

The reader from which the element is read.

| Edit this page View Source

ToSvgDocument()

Encapsulates the current SvgElement in an SvgDocument if it is not already a SvgDocument.

Declaration
public SvgDocument ToSvgDocument()
Returns
Type Description
SvgDocument

A new instance of SvgDocument containing this instance as a child, or this instance if it already is a SvgDocument.

| Edit this page View Source

ToSvgGroup()

Encapsulates the current SvgElement in an SvgGroup if it is not already a SvgGroup.

Declaration
public SvgGroup ToSvgGroup()
Returns
Type Description
SvgGroup

A new instance of SvgGroup containing this instance as a child, or this instance if it already is a SvgGroup.

| Edit this page View Source

WriteXml(XmlWriter)

Writes the XML representation of the element to the specified writer.

Declaration
public void WriteXml(XmlWriter writer)
Parameters
Type Name Description
XmlWriter writer

The writer to which the element is written.

Operators

| Edit this page View Source

operator ==(SvgElement, SvgElement)

Declaration
public static bool operator ==(SvgElement left, SvgElement right)
Parameters
Type Name Description
SvgElement left
SvgElement right
Returns
Type Description
bool
| Edit this page View Source

operator !=(SvgElement, SvgElement)

Declaration
public static bool operator !=(SvgElement left, SvgElement right)
Parameters
Type Name Description
SvgElement left
SvgElement right
Returns
Type Description
bool

Implements

IXmlSerializable
IEquatable<T>