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);
        }
Exemple #2
0
 public static IEnumerable <Block <Vector4> > CodeToLengths(string code) =>
 InverseKinematicsComputer.ComputeLengths(
     CoordinateComputer.ComputePoints(
         CrcParser.ParseCommands(code)
         )
     );
Exemple #3
0
 public static IEnumerable <Block <Vector3> > CodeToPoints(string code)
 {
     return(CoordinateComputer.ComputePoints(CrcParser.ParseCommands(code)));
 }
Exemple #4
0
 /// <summary>
 /// Constructs code processing conveyor and executes it
 /// </summary>
 public static IEnumerable <Block <Angles> > CodeToAngles(string code) =>
 InverseKinematicsComputer.ComputeAngles(
     CoordinateComputer.ComputePoints(
         CrcParser.ParseCommands(code)
         )
     );