コード例 #1
0
 public static void NewLine()
 {
     Console.WriteLine();
     ConsoleWindow.WriteLine("\n");
     if (Settings.logFiles.Length == 0)
     {
         return;
     }
     try
     {
         StreamWriter file = File.AppendText(Settings.logFiles[0]);
         file.WriteLine();
         file.Close();
     }
     catch (Exception) { }
 }
コード例 #2
0
        public ConsoleWindow()
        {
            InitializeComponent();
            Application.EnableVisualStyles();
            instance                   = this;
            this.FormClosing          += OnClose;
            mainInput.ShortcutsEnabled = true;

            if (queuedMessages.Count > 0)
            {
                for (int i = 0; i < queuedMessages.Count; i++)
                {
                    mainOutput.AppendText(String.Format("{0}{1}", queuedMessages[i], Environment.NewLine));
                }
                queuedMessages.Clear();
            }
        }
コード例 #3
0
        public static void Debug(string msg)
        {
            string output = "[" + Time.GetTimestamp() + " | "
                            + "DEBUG" + "] " + msg;

            Console.WriteLine(output);
            ConsoleWindow.WriteLine(output);

            if (Settings.logFiles.Length == 0)
            {
                return;
            }
            try
            {
                StreamWriter file = File.AppendText(Settings.logFiles[0]);
                file.WriteLine(output);
                file.Close();
            }
            catch (Exception) { }
        }
コード例 #4
0
 private void OnClose(object sender, EventArgs e)
 {
     instance = null;
 }
コード例 #5
0
        public static void Handle(string cmd)
        {
            bool          handled = false;
            StringBuilder output  = new StringBuilder();

            // Formatting
            cmd = cmd.ToLower();
            // Basic commands
            switch (cmd)
            {
            case "help":
                output.AppendLine("Available types:");
                foreach (Type t in staticTypes)
                {
                    output.AppendLine("- " + t.Name);
                }
                handled = true;
                break;

            case "event.reload":
                Destiny.FullReload();
                break;

            case "exit":
                ConsoleWindow.CloseInstance();
                handled = true;
                break;
            }
            // Still not handled
            if (!handled && cmd.Substring(0, 1) == "#")
            {
                string reflectionLine = ParseReflectionCommand(cmd.Substring(1));
                if (reflectionLine != null && reflectionLine.Length > 0)
                {
                    output.AppendLine(reflectionLine);
                    handled = true;
                }
                foreach (Type t in staticTypes)
                {
                    // Show all fields and properties

                    /*if (t.Name.ToLower() == cmd.ToLower())
                     * {
                     *  output.AppendLine("Please note that the console functionality is still Work-In-Progress.");
                     *  var fields = t.GetFields(BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public);
                     *  foreach (FieldInfo field in fields)
                     *  {
                     *      output.AppendLine(field.Name + " = " + Parse(field.GetValue(null), 0));
                     *  }
                     *  var properties = t.GetProperties(BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public);
                     *  foreach (PropertyInfo property in properties)
                     *  {
                     *      output.AppendLine(property.Name + " = " + Parse(property.GetValue(null, null), 0));
                     *  }
                     *  handled = true;
                     *  break;
                     * }*/
                }
            }

            // Unknown
            if (!handled)
            {
                output.AppendLine("Unknown command");
            }
            // Remove last line break
            if (output.Length > 0)
            {
                output.Remove(output.Length - 2, 2);
            }
            // Flush to console
            ConsoleEx.Log(output.ToString(), false);
        }