コード例 #1
0
        private void ExecuteCommand(TextInput entry, string command)
        {
            if (command.Length == 0)
            {
                return;
            }
            entry.Clear();

            textBox.Write(new Vector3(1, 1, 1), "> ");
            textBox.WriteLine(new Vector3(0, 0.6f, 0.9f), command);

            try
            {
                if (command.Contains(" "))
                {
                    int    i      = command.IndexOf(" ");
                    string opcode = command.Substring(0, i);

                    if (commands.ContainsKey(opcode))
                    {
                        commands[opcode](command.Substring(i + 1));
                    }
                    else
                    {
                        textBox.WriteLine(new Vector3(1f, 0, 0), "Unknown command");
                    }
                }
                else
                {
                    if (commands.ContainsKey(command))
                    {
                        commands[command]("");
                    }
                    else
                    {
                        textBox.WriteLine(new Vector3(1f, 0, 0), "Unknown command");
                    }
                }
            }
            catch (Exception e)
            {
                textBox.WriteLine(new Vector3(1f, 0, 0), "Exception while running command.  " + e.Message);
            }
        }
コード例 #2
0
ファイル: Console.cs プロジェクト: PWidmann/OpenGL_Demo
 private void ExecuteCommand(TextInput entry, string command)
 {
     if (command.Length == 0)
     {
         return;
     }
     entry.Clear();
     this.textBox.Write(new Vector3(1f, 1f, 1f), "> ");
     this.textBox.WriteLine(new Vector3(0.0f, 0.6f, 0.9f), command);
     try
     {
         if (command.Contains(" "))
         {
             int    length = command.IndexOf(" ");
             string key    = command.Substring(0, length);
             if (this.commands.ContainsKey(key))
             {
                 this.commands[key](command.Substring(length + 1));
             }
             else
             {
                 this.textBox.WriteLine(new Vector3(1f, 0.0f, 0.0f), "Unknown command");
             }
         }
         else if (this.commands.ContainsKey(command))
         {
             this.commands[command]("");
         }
         else
         {
             this.textBox.WriteLine(new Vector3(1f, 0.0f, 0.0f), "Unknown command");
         }
     }
     catch (Exception ex)
     {
         this.textBox.WriteLine(new Vector3(1f, 0.0f, 0.0f), "Exception while running command.  " + ex.Message);
     }
 }