Esempio n. 1
0
        /// <summary>
        /// Sets the clipping region of the specified <see cref="ISvgRenderer"/>.
        /// </summary>
        /// <param name="renderer">The <see cref="ISvgRenderer"/> to have its clipping region set.</param>
        protected internal virtual void SetClip(ISvgRenderer renderer)
        {
            if (this.ClipPath != null || !string.IsNullOrEmpty(this.Clip))
            {
                this._previousClip = renderer.GetClip();

                if (this.ClipPath != null)
                {
                    SvgClipPath clipPath = this.OwnerDocument.GetElementById <SvgClipPath>(this.ClipPath.ToString());
                    if (clipPath != null)
                    {
                        renderer.SetClip(clipPath.GetClipRegion(this, renderer), CombineMode.Intersect);
                    }
                }

                var clip = this.Clip;
                if (!string.IsNullOrEmpty(clip) && clip.StartsWith("rect("))
                {
                    clip = clip.Trim();
                    var offsets = (from o in clip.Substring(5, clip.Length - 6).Split(',')
                                   select float.Parse(o.Trim(), NumberStyles.Any, CultureInfo.InvariantCulture)).ToList();
                    var bounds   = this.Bounds;
                    var clipRect = new RectangleF(bounds.Left + offsets[3], bounds.Top + offsets[0],
                                                  bounds.Width - (offsets[3] + offsets[1]),
                                                  bounds.Height - (offsets[2] + offsets[0]));
                    renderer.SetClip(new Region(clipRect), CombineMode.Intersect);
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Gets the Clip Path if available.  Returns null if not set
        /// </summary>
        /// <returns></returns>
        protected SvgClipPath GetSvgClipPath()
        {
            if (ClipPath == null)
            {
                return(null);
            }
            SvgClipPath clipPath = this.OwnerDocument.GetElementById <SvgClipPath>(this.ClipPath.ToString());

            return(clipPath);
        }
Esempio n. 3
0
        /// <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)
        {
            if (this.ClipPath != null)
            {
                SvgClipPath clipPath = this.OwnerDocument.GetElementById <SvgClipPath>(this.ClipPath.ToString());
                this._previousClip = renderer.Clip;

                if (clipPath != null)
                {
                    renderer.Clip = clipPath.GetClipRegion(this);
                }
            }
        }
Esempio n. 4
0
        /// <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)
        {
            SvgClipPath clipPath = GetSvgClipPath();

            if (clipPath != null)
            {
                this._previousClip = renderer.Clip;

                if (clipPath != null)
                {
                    renderer.Clip = clipPath.GetClipRegion(this);
                }
            }
        }