Beispiel #1
0
        // ReSharper disable once UnusedMember.Local
        private static TestLauncher GetGdiLauncher()
        {
            var srl = new DasSerializer();

            var boot = new GdiProvider();

            return(new TestLauncher(boot, boot.RenderKit,
                                    srl.TypeInferrer));

            //var viewProvider = new ViewProvider();
            //return new TestLauncher(viewProvider, viewProvider, viewProvider.RenderKit,
            //    viewProvider.TypeInferrer);
        }
Beispiel #2
0
        public void Execute(GeneratorExecutionContext context)
        {
            //var syntaxTrees = context.AdditionalFiles;
            var serializer = new DasSerializer();
            var styler     = new DefaultStyleInflater(serializer.TypeInferrer,
                                                      new StyleVariableAccessor(BaselineThemeProvider.Instance.ColorPalette));

            var allMyFiles = context.AdditionalFiles;

            foreach (var fileName in allMyFiles)
            {
                var txt    = File.ReadAllText(fileName.Path);
                var sheeit = styler.InflateXml(txt);
                context.AddSource("helloWorldGenerator", SourceText.From(txt, Encoding.UTF8));
            }
        }
Beispiel #3
0
        private ISvgImage GetEmbeddedImage(String name)
        {
            var srl  = new DasSerializer();
            var bldr = new SvgPathBuilder(_imageProvider, srl);

            var asm = GetType().GetTypeInfo().Assembly;

            //var bobsy = asm.GetManifestResourceNames();

            using (var stream = asm.GetManifestResourceStream(name))
            {
                if (stream == null)
                {
                    throw new InvalidOperationException("Missing Resource: " + name);
                }

                var res = srl.FromXml <SvgDocument>(stream);
                var bob = bldr.Parse(res);
                //var bob = SvgPathBuilder.Parse(res.Path.D);
                return(bob);
                //return _imageProvider.GetImage(stream) ??
                //       throw new InvalidOperationException("Missing Resource: " + name);
            }
        }
Beispiel #4
0
        public void DeserializeSvgXml()
        {
            var settings = DasSettings.CloneDefault();

            settings.IsPropertyNamesCaseSensitive = false;

            var srl = new DasSerializer(settings);

            var xml = GetFileContents("cog.svg");

            //var fullName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory,
            //    "Files",
            //    "cog.svg");

            //var fi = new FileInfo(fullName);

            var res = srl.FromXml <SvgDocument>(xml);

            var bldr = new SvgPathBuilder(new TestImageProvider(), srl);

            //var bob = SvgPathBuilder.Parse(res.Path.D);
            var bob = bldr.Parse(res);

            var gpath = new GdiGraphicsPath();

            gpath.Path.FillMode = FillMode.Winding;
            bob.AddToPath(gpath);

            //using (var bmp = new Bitmap(200, 200))
            using (var bmp = new Bitmap(48, 48))
            {
                var path = gpath.Path;

                //var pBounds = path.GetBounds();
                var scaleX = bmp.Width / (Single)res.Width;
                var scaleY = bmp.Height / (Single)res.Height;

                Matrix m = new Matrix();
                m.Scale(scaleX, scaleY, MatrixOrder.Append);
                //m.Translate(offsetX, offsetY, MatrixOrder.Append);
                path.Transform(m);

                //using (var g = Graphics.FromImage(bmp))
                using (var g = bmp.GetSmoothGraphics())
                {
                    g.SmoothingMode     = SmoothingMode.HighQuality;
                    g.InterpolationMode = InterpolationMode.HighQualityBicubic;
                    g.PixelOffsetMode   = PixelOffsetMode.HighQuality;

                    g.Clear(Color.AliceBlue);
                    g.FillPath(Brushes.Black, gpath.Path);

                    //gpath.Path.Transform();
                    g.DrawPath(Pens.Black, gpath.Path);
                }

                bmp.Save("abcdefg.png");
            }


            Assert.NotNull(res.Path);
        }