Esempio n. 1
0
        public override IView ConvertToView(FigmaNode currentNode, ViewNode parent, ViewRenderService rendererService)
        {
            var vectorEntity    = (FigmaVector)currentNode;
            var vector          = new SvgView();
            var currengroupView = (NSView)vector.NativeObject;

            currengroupView.Configure(currentNode);

            if (vectorEntity.HasFills)
            {
                foreach (var fill in vectorEntity.fills)
                {
                    if (fill.type == "IMAGE")
                    {
                        //we need to add this to our service
                    }
                    else if (fill.type == "SOLID")
                    {
                        if (fill.visible)
                        {
                            //currengroupView.Layer.BackgroundColor = fill.color.ToCGColor ();
                        }
                    }
                    else
                    {
                        Console.WriteLine($"NOT IMPLEMENTED FILL : {fill.type}");
                    }
                    //currengroupView.Layer.Hidden = !fill.visible;
                }
            }

            return(vector);
        }
Esempio n. 2
0
        void ShowSvg(string name)
        {
            svgShapeView            = new SvgView(name);
            svgShapeView.Allocation = new Rectangle(40, 40, 300, 300);

            actionContainerView.SetView(svgShapeView);
        }
Esempio n. 3
0
        private void TestGetTranslation(float canvasDimension, float svgDimension, SvgAlignment alignment, float expected)
        {
            SvgView svgView = new SvgView();
            float   result  = svgView.CallPrivateMethod <float>("GetTranslation", canvasDimension, svgDimension, alignment);

            Assert.AreEqual(expected, result);
        }
Esempio n. 4
0
        public void EnsurePicture_AlreadyResolved()
        {
            SvgView view  = new SvgView();
            SKSvg   skSvg = new SKSvg();

            view.SetMemberValue("_skSvg", skSvg);
            view.CallPrivateMethod("EnsurePicture");
            Assert.AreEqual(skSvg, view.GetMemberValue <SKSvg>("_skSvg"));
        }
Esempio n. 5
0
 public void EnsurePicture_NoApplication()
 {
     TestHelpers.HandleInvocationException(() =>
     {
         SvgView view = new SvgView {
             ResourceId = "DoesNotExist"
         };
         view.CallPrivateMethod("EnsurePicture");
     }, typeof(InvalidOperationException));
 }
Esempio n. 6
0
        public void EnsurePicture_PrefixResolve()
        {
            SvgView.ResourceIdsPrefix = "XamaRed.Forms.Svg.Tests.Assets.";
            SvgView.MainPclAssembly   = typeof(EnsurePictureTests).Assembly;
            SvgView view = new SvgView {
                ResourceId = "inkscape.svg"
            };

            view.CallPrivateMethod("EnsurePicture");
        }
Esempio n. 7
0
        public void EnsurePicture_Simple()
        {
            SvgView.MainPclAssembly = typeof(EnsurePictureTests).Assembly;
            SvgView view = new SvgView {
                ResourceId = "XamaRed.Forms.Svg.Tests.Assets.inkscape.svg"
            };

            view.CallPrivateMethod("EnsurePicture");
            Assert.IsNotNull(view.GetMemberValue <SKSvg>("_skSvg"));
            Assert.IsNotNull(view.GetMemberValue <SKRect>("_svgRect"));
        }
Esempio n. 8
0
 public void EnsurePicture_NotFound()
 {
     TestHelpers.HandleInvocationException(() =>
     {
         SvgView.MainPclAssembly = typeof(EnsurePictureTests).Assembly;
         SvgView view            = new SvgView {
             ResourceId = "DoesNotExist"
         };
         view.CallPrivateMethod("EnsurePicture");
     }, typeof(FileNotFoundException));
 }
Esempio n. 9
0
        public void EnsurePicture_CacheAdd()
        {
            SvgView.MainPclAssembly = typeof(EnsurePictureTests).Assembly;
            SvgView view = new SvgView {
                ResourceId = "XamaRed.Forms.Svg.Tests.Assets.inkscape.svg"
            };

            view.CallPrivateMethod("EnsurePicture");
            IDictionary <string, SKSvg> cache = typeof(SvgView).GetStaticMemberValue <IDictionary <string, SKSvg> >("SvgCache");

            Assert.AreEqual(1, cache.Count);
        }
Esempio n. 10
0
 public void EnsurePicture_PrefixAbsolute()
 {
     TestHelpers.HandleInvocationException(() =>
     {
         SvgView.ResourceIdsPrefix = "XamaRed.Forms.Svg.Tests.Assets.";
         SvgView.MainPclAssembly   = typeof(EnsurePictureTests).Assembly;
         SvgView view = new SvgView {
             ResourceId = "XamaRed.Forms.Svg.Tests.Assets.inkscape.svg"
         };
         view.CallPrivateMethod("EnsurePicture");
     }, typeof(FileNotFoundException));
 }
        private void TestGetScale(SvgStretch stretch, int canvasWidth, int canvasHeight, float svgWidth, float svgHeight, float expectedScaleX, float expectedScaleY)
        {
            SvgView svgView = new SvgView {
                Stretch = stretch
            };

            svgView.SetMemberValue("_svgRect", new SKRect(0, 0, svgWidth, svgHeight));
            SKImageInfo canvasInfo = new SKImageInfo(canvasWidth, canvasHeight);
            SKMatrix    result     = svgView.CallPrivateMethod <SKMatrix>("GetScaleMatrix", canvasInfo);

            Assert.AreEqual(expectedScaleX, result.ScaleX);
            Assert.AreEqual(expectedScaleY, result.ScaleY);
        }