Example #1
0
        private void cbWhat_SelectedIndexChanged(object sender, EventArgs e)
        {
            var ig = new SvgGraphics(Color.WhiteSmoke);

            Render(ig);
            string s = ig.WriteSVGString();

            tbSVG.Text = s;
            string tempFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "foo.svg");
            var    tw       = new StreamWriter(tempFile, false);

            tw.Write(s);
            tw.Close();

            svgCtl.Navigate(new Uri(tempFile));
            svgCtl.Refresh(WebBrowserRefreshOption.Completely);

            panel1.Invalidate();
        }
Example #2
0
        public void TestCases(string key)
        {
            TestContext.WriteLine($"=== Renderer {key}");

            var value = TestShared.Renderers[key];

            var ig = new SvgGraphics(Color.WhiteSmoke);

            value(ig);

            var svgBody = ig.WriteSVGString();

            key = key.Replace("/", "."); // Arcs/Pies is not file friendly

            var dstPath = System.IO.Path.Combine(TestContext.CurrentContext.TestDirectory, $"{TestContext.CurrentContext.Test.ID}.{key}.svg");

            System.IO.File.WriteAllText(dstPath, svgBody);

            TestContext.AddTestAttachment(dstPath, key);
        }
Example #3
0
        public Drawer(PictureBox pb)
        {
            this.pb = pb;

            Random rnd = new Random();

            drawing = new Bitmap(pb.Width, pb.Height);

            Color pencolor = new Color();

            pencolor      = Color.DarkBlue;
            pen           = new System.Drawing.Pen(pencolor, 1F);
            pen.DashCap   = System.Drawing.Drawing2D.DashCap.Round;
            pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Solid;

            graphics = Graphics.FromImage(drawing);
            graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;

            svg_graphics = new SvgGraphics(Color.WhiteSmoke);
        }
Example #4
0
        private void cbWhat_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            SvgGraphics ig;

            ig = new SvgGraphics();
            Render(ig);

            string s = ig.WriteSVGString();

            tbSVG.Text = s;

            StreamWriter tw = new StreamWriter("c:\\temp\\foo.svg", false);

            tw.Write(s);

            tw.Close();

            svgCtl.SRC = "c:\\temp\\foo.svg";

            this.panel1.Invalidate();
        }
Example #5
0
        public override void SetSVGMode(bool active, string svgFileName, int width, int height)
        {
            if (active)
            {
                fSVGWriter = new StreamWriter(new FileStream(svgFileName, FileMode.Create), Encoding.UTF8);
                fSVGGfx    = new SvgGraphics(fSVGWriter, ExtRectF.CreateBounds(0, 0, width, height));
                fSVGGfx.BeginDrawing();
            }
            else
            {
                if (fSVGWriter != null)
                {
                    fSVGGfx.EndDrawing();
                    fSVGGfx = null;

                    fSVGWriter.Flush();
                    fSVGWriter.Close();
                    fSVGWriter = null;
                }
            }
        }
Example #6
0
 private void exportToolStripButton_Click(object sender, EventArgs e)
 {
     saveFileDialog1.Title  = "Choose export path...";
     saveFileDialog1.Filter = "Scalable Vector Graphics (*.svg)|*.svg";
     if (saveFileDialog1.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
     {
         try
         {
             SvgGraphics g = new SvgGraphics();
             vec.Draw(g, new RenderingParameters()
             {
                 ClearBackground = false, IgnoreEdgeDrawing = true
             }, 1, 0, 0);
             File.WriteAllText(saveFileDialog1.FileName, g.WriteSVGString());
             MessageBox.Show(this, "Exported to SVG.", titleText, MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         catch (Exception ex)
         {
             MessageBox.Show(this, "Failed to export to file: " + ex.Message, titleText, MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
        public ActionResult Draw(string m, string f)
        {
            var str   = Encoding.UTF8.GetString(Convert.FromBase64String(m));
            var model = JsonConvert.DeserializeObject <BalustradeDrawingModel>(str);

            var balustrade = CreateBalustradeFromDrawingModel(model);

            if (f == "pdf")
            {
                var fileName = "Drawing_" + balustrade.BalustradeViews[balustrade.CurrentViewIndex].Name;

                var memStream = new MemoryStream();

                using (var doc = balustrade.CreatePdf())
                {
                    doc.Info.Title = fileName;
                    doc.Save(memStream);
                }

                Response.AddHeader("content-disposition", String.Format("inline; filename={0}.pdf; size={1}", fileName, memStream.Length));

                return(new FileStreamResult(memStream, "application/pdf"));
            }


            var svgGraphics = new SvgGraphics();

            svgGraphics.Clear(Color.White);
            balustrade.Paint(svgGraphics);

            return(Json(new
            {
                svg = svgGraphics.WriteSVGString(),
                price = balustrade.SellingPrice,
                onlineDrawingDiscount = balustrade.BalustradeSystem.OnlineDrawingDiscount,
                vatPercent = DbSession.CurrentUser()?.DefaultCompany?.VatPercent ?? 0D,
                withPosts = balustrade.RawBalustradeSections.Any(s => s.Posts.Count > 0)
            }, JsonRequestBehavior.AllowGet));
        }