コード例 #1
0
ファイル: ConsoleStatusDisplay.cs プロジェクト: saiboat/XMPMS
        /// <summary>
        /// Handle a console command
        /// </summary>
        /// <param name="command"></param>
        public void Command(string[] command)
        {
            if (command.Length > 0)
            {
                switch (command[0].ToLower())
                {
                case "mode":
                    if (command.Length > 1)
                    {
                        Match modeMatch = Regex.Match(command[1], @"^(?<w>[0-9]+),(?<h>[0-9]+)$");

                        if (modeMatch.Success)
                        {
                            consoleWidth  = Math.Min(Math.Max(int.Parse(modeMatch.Groups["w"].Value), 80), 160);
                            consoleHeight = Math.Min(Math.Max(int.Parse(modeMatch.Groups["h"].Value), 25), 200);
                            SetupConsole();

                            MasterServer.Settings.ConsoleWidth  = consoleWidth;
                            MasterServer.Settings.ConsoleHeight = consoleHeight;
                            MasterServer.Settings.Save();
                        }
                    }
                    else
                    {
                        MasterServer.LogMessage("mode <width>,<height>");
                    }
                    break;

                case "quit":
                case "exit":
                    MasterServer.BeginStop();
                    break;

                case "restart":
                    MasterServer.BeginRestart();
                    break;

                case "?":
                case "help":
                    MasterServer.LogMessage("restart       Restart the master server");
                    MasterServer.LogMessage("mode          Console mode commands");
                    break;
                }
            }
        }