Beispiel #1
0
        private void Console_OnConsoleInput(object sender, ConsoleControl.ConsoleEventArgs args)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(args.Content))
                {
                    goto ret;
                }
                string[] cmd = CommandLineToArgs(args.Content);
                if (cmd.Length < 0)
                {
                    goto ret;
                }
                string command = cmd[0];
                cmd = Enumerable.Skip(cmd, 1).ToArray();
                MethodInfo mi = null;
                if (command == "help")
                {
                    ConsoleWriteLines(new List <string> {
                        string.Format("HaShell [Version {0}]", ServerDataSource.LocalVersion),
                        "",
                        "\thelp - show this help",
                        "\tclients - print all clients",
                        "\tkick [--ban] <ip> - disconnect client, optionally banning it",
                        "\tunban <ip> - unban client",
                        "\tbanlist - print banlist",
                        "\tsource [add|remove|reload|addext|removeext|list] <path|ext>",
                        "\ttail [n] - print last n lines from the log, default 10",
                        "\tflush [path] - force DataSource flush, optionally into a specific path",
                        "\tload [path] - load DataSource, optionally from a specific path",
                        "\tbackup [path] - backup playlists and songs in cross-version format",
                        "\trestore [path] - restore playlists and songs from cross-version format",
                        "\texit - exit server"
                    });
                    goto ret;
                }
                try
                {
                    mi = GetType().GetMethod("command_" + command);
                }
                catch { }
                if (mi == null)
                {
                    ConsoleWriteLine(string.Format("Couldn't find command {0}, try `help`", command));
                    goto ret;
                }
                mi.Invoke(this, new object[] { cmd });
            }
            catch (Exception e)
            {
                if (e is TargetInvocationException)
                {
                    e = e.InnerException;
                }
                ConsoleWriteLine("Unhandled exception occurred: " + e.Message + "\r\n" + e.StackTrace);
            }

ret:
            ConsoleWrite("# ");
        }
Beispiel #2
0
 private void console_OnConsoleOutput(object sender, ConsoleControl.ConsoleEventArgs args)
 {
     /*if (!termino)
      * {
      *  if (console.IsProcessRunning)
      *      return;
      *
      *  console.WriteOutput("End process\n", System.Drawing.Color.Red);
      *
      *  termino = true;
      * }*/
 }
Beispiel #3
0
 private void consoleControl1_OnConsoleOutput(object sender, ConsoleControl.ConsoleEventArgs args)
 {
     ((ConsoleControl.ConsoleControl)sender).InternalRichTextBox.ScrollToCaret();
 }
        /// <summary>
        /// Handles the OnConsoleOutput event of the ConsoleOutput control.
        /// Uses the Win32 API to send a <c>WmVscroll</c> message to the console control
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="args">The <see cref="ConsoleControl.ConsoleEventArgs"/> instance containing the event data.</param>
        private void ConsoleOutput_OnConsoleOutput(object sender, ConsoleControl.ConsoleEventArgs args)
        {
            var console = ConsoleOutput.InternalRichTextBox;

            SendMessage(console.Handle, WmVscroll, SbBottom, 0x0);
        }