Exemplo n.º 1
0
        private SvgDocument GenerateGridSvg(int strokeWidth, int size)
        {
            var gen = new SvgGenerator();

            gen.StrokeColor = "cornflowerblue";

            for (int x = 0; x <= gen.MaxX; x += size)
            {
                gen.DrawLine(new Vector2(x, gen.MinY), new Vector2(x, gen.MaxY));
            }
            for (int x = -size; x >= gen.MinX; x -= size)
            {
                gen.DrawLine(new Vector2(x, gen.MinY), new Vector2(x, gen.MaxY));
            }

            for (int y = 0; y <= gen.MaxY; y += size)
            {
                gen.DrawLine(new Vector2(gen.MinX, y), new Vector2(gen.MaxX, y));
            }
            for (int y = -size; y >= gen.MinY; y -= size)
            {
                gen.DrawLine(new Vector2(gen.MinX, y), new Vector2(gen.MaxX, y));
            }

            return(SvgDocument.FromSvg <SvgDocument>(gen.GenerateCode(strokeWidth)));
        }
Exemplo n.º 2
0
        public TrajectoryForm()
        {
            InitializeComponent();

            _generator     = new SvgGenerator();
            _svg           = SvgDocument.FromSvg <SvgDocument>(_generator.GenerateCode(RenderStrokeWidth));
            _svgRasterizer = new SvgRasterizer(RenderGridStrokeWidth, RenderGridSize);
            RenderSvg();
        }
Exemplo n.º 3
0
        private bool ExecuteCommand(string text)
        {
            _modified = true;

            Command[] commands = null;
            try
            {
                commands = CrcParser.ParseCommands(text).ToArray();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Parser Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            if (commands != null)
            {
                Debug.WriteLine($"Parsed {commands.Length} commands");

                try
                {
                    foreach (var cmd in commands)
                    {
                        _generator.ExecuteCommand(cmd);
                    }
                    _svg = SvgDocument.FromSvg <SvgDocument>(_generator.GenerateCode(RenderStrokeWidth));
                    RenderSvg();

                    if (outTextBox.Text != "")
                    {
                        outTextBox.AppendText("\r\n");
                    }

                    outTextBox.AppendText(LineEndUtil.ToWindows(text));
                    return(true);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Render Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            return(false);
        }