Exemplo n.º 1
0
        public CommandRef DetectCommand(string line)
        {
            CommandRef        result  = new CommandRef(Commands.NONE, "", "");
            List <CommandRef> results = new List <CommandRef>();

            try
            {
                for (int k = 0; k < CommandList.Count; k++)
                {
                    for (int v = 0; v < CommandList.ElementAt(k).Value.Length; v++)
                    {
                        if (line.Contains(CommandList.ElementAt(k).Value[v]))
                        {
                            results.Add(new CommandRef(CommandList.ElementAt(k).Key, CommandList.ElementAt(k).Value[v], line));
                        }
                    }
                }

                int highestLength = 0;

                for (int i = 0; i < results.Count; i++)
                {
                    if (results[i].Reference.Length > highestLength)
                    {
                        highestLength = results[i].Reference.Length;
                        result        = results[i];
                    }
                    else if (results[i].Reference.Length == highestLength)
                    {
                        if (results[i].Line.IndexOf(results[i].Reference) < result.Line.IndexOf(result.Reference))
                        {
                            result = results[i];
                        }
                    }
                }

                if (Statements.IsNull(result.Command))
                {
                    result = HasCoordinates(line);
                }

                if (result.Command == Commands.LINE || result.Command == Commands.ARC)
                {
                    ModularCommand = result.Reference;
                }
                if (result.Command == Commands.ARC)
                {
                    ModularArcCommand = result.Reference;
                }
            }
            catch (Exception e)
            {
                ErrorHandler.AddMessage(e);
            }

            return(result);
        }
Exemplo n.º 2
0
        public string[] GetReferencesFromList(Commands cmd)
        {
            string[] result = { };

            try
            {
                result = CommandList.ElementAt((int)cmd - 1).Value;
            }
            catch (Exception e)
            {
                ErrorHandler.AddMessage(e);
            }

            return(result);
        }