public void DrawSwitch(SvgSwitch svgSwitch, bool ignoreDisplay) { if (!CanDraw(svgSwitch, ignoreDisplay)) { return; } _skCanvas.Save(); var skMatrix = SkiaUtil.GetSKMatrix(svgSwitch.Transforms); SetTransform(skMatrix); SetClipPath(svgSwitch, _disposable); var skPaintOpacity = SetOpacity(svgSwitch, _disposable); var skPaintFilter = SetFilter(svgSwitch, _disposable); // TODO: if (skPaintFilter != null) { _skCanvas.Restore(); } if (skPaintOpacity != null) { _skCanvas.Restore(); } _skCanvas.Restore(); }
public static SwitchDrawable Create(SvgSwitch svgSwitch, Rect skOwnerBounds, DrawableBase?parent, IAssetLoader assetLoader, Attributes ignoreAttributes = Attributes.None) { var drawable = new SwitchDrawable(assetLoader) { Element = svgSwitch, Parent = parent, IgnoreAttributes = ignoreAttributes }; drawable.IsDrawable = drawable.CanDraw(svgSwitch, drawable.IgnoreAttributes) && drawable.HasFeatures(svgSwitch, drawable.IgnoreAttributes); if (!drawable.IsDrawable) { return(drawable); } foreach (var child in svgSwitch.Children) { if (!child.IsKnownElement()) { continue; } var hasRequiredFeatures = child.HasRequiredFeatures(); var hasRequiredExtensions = child.HasRequiredExtensions(); var hasSystemLanguage = child.HasSystemLanguage(); if (hasRequiredFeatures && hasRequiredExtensions && hasSystemLanguage) { var childDrawable = DrawableFactory.Create(child, skOwnerBounds, parent, assetLoader, ignoreAttributes); if (childDrawable is { })
public SwitchDrawable(SvgSwitch svgSwitch, SKRect skOwnerBounds, Drawable?root, Drawable?parent, Attributes ignoreAttributes = Attributes.None) : base(svgSwitch, root, parent) { IgnoreAttributes = ignoreAttributes; IsDrawable = CanDraw(svgSwitch, IgnoreAttributes) && HasFeatures(svgSwitch, IgnoreAttributes); if (!IsDrawable) { return; } foreach (var child in svgSwitch.Children) { if (!IsKnownElement(child)) { continue; } bool hasRequiredFeatures = HasRequiredFeatures(child); bool hasRequiredExtensions = HasRequiredExtensions(child); bool hasSystemLanguage = HasSystemLanguage(child); if (hasRequiredFeatures && hasRequiredExtensions && hasSystemLanguage) { //var ignoreAttributesSwitch = ignoreAttributes // | Attributes.Visibility // | Attributes.Display // | Attributes.RequiredFeatures // | Attributes.RequiredExtensions // | Attributes.SystemLanguage; var drawable = DrawableFactory.Create(child, skOwnerBounds, root, parent, ignoreAttributes); if (drawable != null) { FirstChild = drawable; _disposable.Add(FirstChild); } break; } } if (FirstChild == null) { IsDrawable = false; return; } IsAntialias = SvgPaintingExtensions.IsAntialias(svgSwitch); TransformedBounds = FirstChild.TransformedBounds; Transform = SvgTransformsExtensions.ToSKMatrix(svgSwitch.Transforms); Fill = null; Stroke = null; // TODO: Transform _skBounds using _skMatrix. TransformedBounds = Transform.MapRect(TransformedBounds); }
public static DrawableBase?Create(SvgElement svgElement, Rect skOwnerBounds, DrawableBase?parent, IAssetLoader assetLoader, Attributes ignoreAttributes = Attributes.None) { return(svgElement switch { SvgAnchor svgAnchor => AnchorDrawable.Create(svgAnchor, skOwnerBounds, parent, assetLoader, ignoreAttributes), SvgFragment svgFragment => FragmentDrawable.Create(svgFragment, skOwnerBounds, parent, assetLoader, ignoreAttributes), SvgImage svgImage => ImageDrawable.Create(svgImage, skOwnerBounds, parent, assetLoader, ignoreAttributes), SvgSwitch svgSwitch => SwitchDrawable.Create(svgSwitch, skOwnerBounds, parent, assetLoader, ignoreAttributes), SvgUse svgUse => UseDrawable.Create(svgUse, skOwnerBounds, parent, assetLoader, ignoreAttributes), SvgCircle svgCircle => CircleDrawable.Create(svgCircle, skOwnerBounds, parent, assetLoader, ignoreAttributes), SvgEllipse svgEllipse => EllipseDrawable.Create(svgEllipse, skOwnerBounds, parent, assetLoader, ignoreAttributes), SvgRectangle svgRectangle => RectangleDrawable.Create(svgRectangle, skOwnerBounds, parent, assetLoader, ignoreAttributes), SvgGroup svgGroup => GroupDrawable.Create(svgGroup, skOwnerBounds, parent, assetLoader, ignoreAttributes), SvgLine svgLine => LineDrawable.Create(svgLine, skOwnerBounds, parent, assetLoader, ignoreAttributes), SvgPath svgPath => PathDrawable.Create(svgPath, skOwnerBounds, parent, assetLoader, ignoreAttributes), SvgPolyline svgPolyline => PolylineDrawable.Create(svgPolyline, skOwnerBounds, parent, assetLoader, ignoreAttributes), SvgPolygon svgPolygon => PolygonDrawable.Create(svgPolygon, skOwnerBounds, parent, assetLoader, ignoreAttributes), SvgText svgText => TextDrawable.Create(svgText, skOwnerBounds, parent, assetLoader, ignoreAttributes), _ => null, });
public static Drawable?Create(SvgElement svgElement, SKRect skOwnerBounds, Drawable?root, Drawable?parent, Attributes ignoreAttributes = Attributes.None) { return(svgElement switch { SvgAnchor svgAnchor => new AnchorDrawable(svgAnchor, skOwnerBounds, root, parent, ignoreAttributes), SvgFragment svgFragment => new FragmentDrawable(svgFragment, skOwnerBounds, root, parent, ignoreAttributes), SvgImage svgImage => new ImageDrawable(svgImage, skOwnerBounds, root, parent, ignoreAttributes), SvgSwitch svgSwitch => new SwitchDrawable(svgSwitch, skOwnerBounds, root, parent, ignoreAttributes), SvgUse svgUse => new UseDrawable(svgUse, skOwnerBounds, root, parent, ignoreAttributes), SvgCircle svgCircle => new CircleDrawable(svgCircle, skOwnerBounds, root, parent, ignoreAttributes), SvgEllipse svgEllipse => new EllipseDrawable(svgEllipse, skOwnerBounds, root, parent, ignoreAttributes), SvgRectangle svgRectangle => new RectangleDrawable(svgRectangle, skOwnerBounds, root, parent, ignoreAttributes), SvgGroup svgGroup => new GroupDrawable(svgGroup, skOwnerBounds, root, parent, ignoreAttributes), SvgLine svgLine => new LineDrawable(svgLine, skOwnerBounds, root, parent, ignoreAttributes), SvgPath svgPath => new PathDrawable(svgPath, skOwnerBounds, root, parent, ignoreAttributes), SvgPolyline svgPolyline => new PolylineDrawable(svgPolyline, skOwnerBounds, root, parent, ignoreAttributes), SvgPolygon svgPolygon => new PolygonDrawable(svgPolygon, skOwnerBounds, root, parent, ignoreAttributes), SvgText svgText => new TextDrawable(svgText, skOwnerBounds, root, parent, ignoreAttributes), _ => null, });
public Switch(SvgSwitch svgSwitch) { matrix = SvgHelper.GetSKMatrix(svgSwitch.Transforms); }
public ViewModelFactory(SvgSwitch svgSwitch, SvgThermostat svgThermostat) { this._svgSwitch = svgSwitch; this._svgThermostat = svgThermostat; }