Represents a <filter> element.
상속: SvgBaseElement
예제 #1
0
        //==========================================================================
        public virtual Drawing Draw()
        {
            Drawing drawing = GetBaseDrawing();

            if (drawing == null)
            {
                return(null);
            }

            BitmapEffect bitmap_effect = null;

            if (Filter != null)
            {
                if (Document.Elements.ContainsKey(Filter))
                {
                    SvgFilterElement filter_element = Document.Elements[Filter] as SvgFilterElement;
                    if (filter_element != null)
                    {
                        bitmap_effect = filter_element.ToBitmapEffect();
                    }
                }
            }

            Brush opacity_mask = null;

            if (Mask != null)
            {
                SvgMaskElement mask_element = Document.Elements[Mask] as SvgMaskElement;
                if (mask_element != null)
                {
                    opacity_mask = mask_element.GetOpacityMask();
                    if (opacity_mask != null)
                    {
                        if (Transform != null)
                        {
                            opacity_mask.Transform = Transform.ToTransform();
                        }
                    }
                }
            }

            if ((opacity_mask == null) && (bitmap_effect == null))
            {
                return(drawing);
            }


            DrawingGroup drawing_group = new DrawingGroup();

            drawing_group.BitmapEffect = bitmap_effect;
            drawing_group.OpacityMask  = opacity_mask;
            drawing_group.Children.Add(drawing);

            return(drawing_group);
        }
        //==========================================================================
        public override Drawing Draw()
        {
            DrawingGroup drawing_group = new DrawingGroup();

            drawing_group.Opacity = Opacity.ToDouble();
            if (Transform != null)
            {
                drawing_group.Transform = Transform.ToTransform();
            }

            foreach (SvgBaseElement element in Children)
            {
                Drawing drawing = null;

                if (element is SvgDrawableBaseElement)
                {
                    drawing = (element as SvgDrawableBaseElement).Draw();
                }
                else if (element is SvgDrawableContainerBaseElement)
                {
                    drawing = (element as SvgDrawableContainerBaseElement).Draw();
                }

                if (drawing != null)
                {
                    drawing_group.Children.Add(drawing);
                }
            }

            if (Filter != null)
            {
                SvgFilterElement filter_element = Document.Elements[Filter.Id] as SvgFilterElement;
                if (filter_element != null)
                {
                    drawing_group.BitmapEffect = filter_element.ToBitmapEffect();
                }
            }

            if (ClipPath != null)
            {
                SvgClipPathElement clip_path_element = Document.Elements[ClipPath.Id] as SvgClipPathElement;
                if (clip_path_element != null)
                {
                    drawing_group.ClipGeometry = clip_path_element.GetClipGeometry();
                }
            }

            if (Mask != null)
            {
                SvgMaskElement mask_element = Document.Elements[Mask.Id] as SvgMaskElement;
                if (mask_element != null)
                {
                    drawing_group.OpacityMask = mask_element.GetOpacityMask();

                    GeometryGroup geometry_group = new GeometryGroup();

                    if (drawing_group.ClipGeometry != null)
                    {
                        geometry_group.Children.Add(drawing_group.ClipGeometry);
                    }

                    geometry_group.Children.Add(mask_element.GetClipGeometry());
                    drawing_group.ClipGeometry = geometry_group;
                }
            }

            return(drawing_group);
        }
        //==========================================================================
        public virtual Drawing Draw()
        {
            DrawingGroup drawing_group = new DrawingGroup();

            drawing_group.Opacity = Opacity.ToDouble();
            if (Transform != null)
            {
                drawing_group.Transform = Transform.ToTransform();
            }

            if (ViewBox != null)
            {
                drawing_group.Children.Add(ViewBox.Process());
            }

            foreach (SvgBaseElement child_element in Children)
            {
                SvgBaseElement element = child_element;
                if (element is SvgUseElement)
                {
                    element = (element as SvgUseElement).GetElement();
                }

                Drawing drawing = null;

                if (element is SvgDrawableBaseElement)
                {
                    if ((element as SvgDrawableBaseElement).Display != SvgDisplay.None)
                    {
                        drawing = (element as SvgDrawableBaseElement).Draw();
                    }
                }
                else if (element is SvgDrawableContainerBaseElement)
                {
                    if ((element as SvgDrawableContainerBaseElement).Display != SvgDisplay.None)
                    {
                        drawing = (element as SvgDrawableContainerBaseElement).Draw();
                    }
                }

                if (drawing != null)
                {
                    drawing_group.Children.Add(drawing);
                }
            }

            if (Filter != null)
            {
                SvgFilterElement filter_element = Document.Elements[Filter.Id] as SvgFilterElement;
                if (filter_element != null)
                {
                    drawing_group.BitmapEffect = filter_element.ToBitmapEffect();
                }
            }

            if (ClipPath != null)
            {
                SvgClipPathElement clip_path_element = Document.Elements[ClipPath.Id] as SvgClipPathElement;
                if (clip_path_element != null)
                {
                    drawing_group.ClipGeometry = clip_path_element.GetClipGeometry();
                }
            }

            if (Mask != null)
            {
                SvgMaskElement mask_element = Document.Elements[Mask.Id] as SvgMaskElement;
                if (mask_element != null)
                {
                    DrawingBrush opacity_mask = mask_element.GetOpacityMask();

                    /*
                     * if(Transform != null)
                     * opacity_mask.Transform = Transform.ToTransform();
                     */
                    drawing_group.OpacityMask = opacity_mask;
                }
            }

            return(drawing_group);
        }
예제 #4
0
        //==========================================================================
        public virtual Drawing Draw()
        {
            DrawingGroup drawing_group = new DrawingGroup();

            drawing_group.Opacity = Opacity.ToDouble();
            if (Transform != null)
            {
                drawing_group.Transform = Transform.ToTransform();
            }

            //if (ViewBox != null)
            //    drawing_group.Children.Add(ViewBox.Process());

            foreach (SvgBaseElement child_element in Children)
            {
                SvgBaseElement element = child_element;
                if (element is SvgUseElement)
                {
                    element = (element as SvgUseElement).GetElement();
                }

                Drawing drawing = null;

                if (element is SvgDrawableBaseElement)
                {
                    if ((element as SvgDrawableBaseElement).Display != SvgDisplay.None)
                    {
                        drawing = (element as SvgDrawableBaseElement).Draw();
                    }
                }
                else if (element is SvgDrawableContainerBaseElement)
                {
                    if ((element as SvgDrawableContainerBaseElement).Display != SvgDisplay.None)
                    {
                        drawing = (element as SvgDrawableContainerBaseElement).Draw();
                    }
                }

                if (drawing != null)
                {
                    drawing_group.Children.Add(drawing);
                }
            }

            if (Filter != null)
            {
                SvgFilterElement filter_element = Document.Elements[Filter.Id] as SvgFilterElement;
                if (filter_element != null)
                {
                    drawing_group.BitmapEffect = filter_element.ToBitmapEffect();
                }
            }

            if (ClipPath != null)
            {
                SvgClipPathElement clip_path_element = Document.Elements[ClipPath.Id] as SvgClipPathElement;
                if (clip_path_element != null)
                {
                    drawing_group.ClipGeometry = clip_path_element.GetClipGeometry();
                }
            }

            if (Mask != null)
            {
                SvgMaskElement mask_element = Document.Elements[Mask.Id] as SvgMaskElement;
                if (mask_element != null)
                {
                    DrawingBrush opacity_mask = mask_element.GetOpacityMask();

                    /*
                     * if(Transform != null)
                     * opacity_mask.Transform = Transform.ToTransform();
                     */
                    drawing_group.OpacityMask = opacity_mask;
                }
            }

            // add base element size
            if (this is SvgSVGElement)
            {
                var svg = this as SvgSVGElement;

                DrawingVisual  visual = new DrawingVisual();
                DrawingContext dc     = visual.RenderOpen();

                Rect rect = new Rect(new System.Windows.Point(0, 0), new System.Windows.Size(svg.Width.Value, svg.Height.Value));
                dc.DrawRectangle(System.Windows.Media.Brushes.Transparent, (System.Windows.Media.Pen)null, rect);
                dc.Close();

                drawing_group.Children.Add(visual.Drawing);
            }

            return(drawing_group);
        }