using System; using System.Collections.Generic; using System.Text; using System.Drawing; using System.Drawing.Drawing2D; namespace Svg { /// /// /// public sealed class SvgClipPath : SvgElement { private SvgCoordinateUnits _clipPathUnits; private bool _pathDirty; private Region _region; /// /// /// [SvgAttribute("clipPathUnits")] public SvgCoordinateUnits ClipPathUnits { get { return this._clipPathUnits; } set { this._clipPathUnits = value; } } /// /// Initializes a new instance of the class. /// public SvgClipPath() { this._clipPathUnits = SvgCoordinateUnits.ObjectBoundingBox; } /// /// Gets this 's region to be clipped. /// /// A new containing the area to be clipped. protected internal Region GetClipRegion() { if (_region == null || _pathDirty) { _region = new Region(); foreach (SvgElement element in this.Children) { ComplementRegion(_region, element); } _pathDirty = false; } return _region; } /// /// /// /// /// private void ComplementRegion(Region region, SvgElement element) { SvgGraphicsElement graphicsElement = element as SvgGraphicsElement; if (graphicsElement != null && graphicsElement.Path != null) { region.Complement(graphicsElement.Path); } foreach (SvgElement child in element.Children) { ComplementRegion(region, child); } } protected override void AddElement(SvgElement child, int index) { base.AddElement(child, index); this._pathDirty = true; } protected override void RemoveElement(SvgElement child) { base.RemoveElement(child); this._pathDirty = true; } /// /// Renders the and contents to the specified object. /// /// The object to render to. protected override void Render(SvgRenderer renderer) { // Do nothing } } }