public TerminalMain() { new TerminalConfiguration(Application.ExecutablePath); Notification = new SysTrayNotifyIcon { Visible = true }; if (TerminalConfiguration.TransparentConsole) { ConsoleUtil.TransparentConsole(); } if (TerminalConfiguration.ConsoleCenterOnScreen) { ConsoleUtil.CenterConsoleWindow(TerminalConfiguration.ConsoleWidth, TerminalConfiguration.ConsoleHeight); } else { ConsoleUtil.PositionConsoleWindow(TerminalConfiguration.ConsoleLeft, TerminalConfiguration.ConsoleTop, TerminalConfiguration.ConsoleWidth, TerminalConfiguration.ConsoleHeight); } try { Console.WindowWidth = TerminalConfiguration.ConsoleWidth; Console.WindowHeight = TerminalConfiguration.ConsoleHeight; Console.BufferWidth = TerminalConfiguration.ConsoleWidth; Console.BufferHeight = Int16.MaxValue - 1; } catch (ArgumentOutOfRangeException) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("({0}) <Terminal> Failed to initialize properly. Check Config.xml settings.", DateTime.Now.ToString("hh:mm")); Console.ResetColor(); } finally { Console.WriteLine("({0}) <Terminal> Initialized...", DateTime.Now.ToString("hh:mm")); } var connection = new IRCInterface { Nicks = new[] { IRCInterface.DefaultNick, IRCInterface.AlternateNick1, IRCInterface.AlternateNick2 }, UserName = IRCInterface.DefaultUserName, Info = IRCInterface.DefaultInfo }; if (IRCInterface.IRCInterfaceEnabled) { connection.BeginConnect(IRCInterface.DefaultServer, IRCInterface.DefaultPort); } else { Console.WriteLine("({0}) <IRC Interface> Disabled", DateTime.Now.ToString("hh:mm")); } var webinterface = new WebInterface(); if (TerminalConfiguration.AutoStartAuthServer) { try { AuthServer = new ProcessRunner(TerminalConfiguration.AuthServerPath); } catch (FileNotFoundException) { Console.WriteLine("({0}) <Terminal> Failed to start AuthServer. Check Config.xml settings.", DateTime.Now.ToString("hh:mm")); } finally { ProcessOutputEventHandler AuthServerOutputHandler = delegate(object o, ProcessOutputEventArgs ex) { if (ex.Data.Contains("[Error]")) { Console.ForegroundColor = ConsoleColor.Red; } else if (ex.Data.Contains("[Warn]")) { Console.ForegroundColor = ConsoleColor.Yellow; } else if (ex.Data.Contains("[Debug]")) { Console.ForegroundColor = ConsoleColor.Gray; } else if (ex.Data.Contains("Unhandled Exception")) { Console.ForegroundColor = ConsoleColor.DarkRed; } else { Console.ForegroundColor = ConsoleColor.White; } Console.WriteLine("({0}) <AuthServer> {1}", DateTime.Now.ToString("hh:mm"), ex.Data); }; try { AuthServer.OutputReceived += AuthServerOutputHandler; AuthServer.Start(); } catch (NullReferenceException) { Console.WriteLine("({0}) <Terminal> Failed to start AuthServer. Check Config.xml settings.", DateTime.Now.ToString("hh:mm")); } } } if (TerminalConfiguration.AutoStartRealmServer) { try { RealmServer = new ProcessRunner(TerminalConfiguration.RealmServerPath); } catch (FileNotFoundException) { Console.WriteLine("({0}) <Terminal> Failed to start RealmServer. Check Config.xml settings.", DateTime.Now.ToString("hh:mm")); } finally { ProcessOutputEventHandler RealmServerOutputHandler = delegate(object o, ProcessOutputEventArgs ex) { if (ex.Data.Contains("[Error]")) { Console.ForegroundColor = ConsoleColor.Red; } else if (ex.Data.Contains("[Warn]")) { Console.ForegroundColor = ConsoleColor.Yellow; } else if (ex.Data.Contains("[Debug]")) { Console.ForegroundColor = ConsoleColor.Gray; } else if (ex.Data.Contains("Unhandled Exception")) { Console.ForegroundColor = ConsoleColor.DarkRed; } else { Console.ForegroundColor = ConsoleColor.White; } Console.WriteLine("({0}) <RealmServer> {1}", DateTime.Now.ToString("hh:mm"), ex.Data); }; try { RealmServer.OutputReceived += RealmServerOutputHandler; RealmServer.Start(); } catch (NullReferenceException) { Console.WriteLine("({0}) <Terminal> Failed to start RealmServer. Check Config.xml settings.", DateTime.Now.ToString("hh:mm")); } } } }
public TerminalMain() { new TerminalConfiguration(Application.ExecutablePath); Notification = new SysTrayNotifyIcon { Visible = true }; if (TerminalConfiguration.TransparentConsole) { ConsoleUtil.TransparentConsole(); } if (TerminalConfiguration.ConsoleCenterOnScreen) { ConsoleUtil.CenterConsoleWindow(TerminalConfiguration.ConsoleWidth, TerminalConfiguration.ConsoleHeight); } else { ConsoleUtil.PositionConsoleWindow(TerminalConfiguration.ConsoleLeft, TerminalConfiguration.ConsoleTop, TerminalConfiguration.ConsoleWidth, TerminalConfiguration.ConsoleHeight); } try { Console.WindowWidth = TerminalConfiguration.ConsoleWidth; Console.WindowHeight = TerminalConfiguration.ConsoleHeight; Console.BufferWidth = TerminalConfiguration.ConsoleWidth; Console.BufferHeight = Int16.MaxValue - 1; } catch (ArgumentOutOfRangeException) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("({0}) <Terminal> Failed to initialize properly. Check Config.xml settings.", DateTime.Now.ToString("hh:mm")); Console.ResetColor(); } finally { Console.WriteLine("({0}) <Terminal> Initialized...", DateTime.Now.ToString("hh:mm")); } var connection = new IRCInterface { Nicks = new[] { IRCInterface.DefaultNick, IRCInterface.AlternateNick1, IRCInterface.AlternateNick2 }, UserName = IRCInterface.DefaultUserName, Info = IRCInterface.DefaultInfo }; if (IRCInterface.IRCInterfaceEnabled) { connection.BeginConnect(IRCInterface.DefaultServer, IRCInterface.DefaultPort); } else { Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("({0}) <IRC Interface> Disabled", DateTime.Now.ToString("hh:mm")); } var webinterface = new WebInterface(); if (TerminalConfiguration.AutoStartAuthServer) { try { AuthServer = new ProcessRunner(TerminalConfiguration.AuthServerPath); } catch (FileNotFoundException) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("({0}) <Terminal> Failed to start AuthServer. Check Config.xml settings.", DateTime.Now.ToString("hh:mm")); } finally { ProcessOutputEventHandler AuthServerOutputHandler = delegate(object o, ProcessOutputEventArgs ex) { if (ex.Data.Contains("[Error]")) { Console.ForegroundColor = ConsoleColor.Red; } else if (ex.Data.Contains("[Warn]")) { Console.ForegroundColor = ConsoleColor.Yellow; } else if (ex.Data.Contains("[Debug]")) { Console.ForegroundColor = ConsoleColor.Gray; } else if (ex.Data.Contains("Unhandled Exception")) { Console.ForegroundColor = ConsoleColor.DarkRed; } else { Console.ForegroundColor = ConsoleColor.White; } Console.WriteLine("({0}) <AuthServer> {1}", DateTime.Now.ToString("hh:mm"), ex.Data); }; try { AuthServer.OutputReceived += AuthServerOutputHandler; AuthServer.Start(); } catch (NullReferenceException) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("({0}) <Terminal> Failed to start AuthServer. Check Config.xml settings.", DateTime.Now.ToString("hh:mm")); } } } if (TerminalConfiguration.AutoStartRealmServer) { try { RealmServer = new ProcessRunner(TerminalConfiguration.RealmServerPath); } catch (FileNotFoundException) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("({0}) <Terminal> Failed to start RealmServer. Check Config.xml settings.", DateTime.Now.ToString("hh:mm")); } finally { ProcessOutputEventHandler RealmServerOutputHandler = delegate(object o, ProcessOutputEventArgs ex) { if (ex.Data.Contains("[Error]")) { Console.ForegroundColor = ConsoleColor.Red; } else if (ex.Data.Contains("[Warn]")) { Console.ForegroundColor = ConsoleColor.Yellow; } else if (ex.Data.Contains("[Debug]")) { Console.ForegroundColor = ConsoleColor.Gray; } else if (ex.Data.Contains("Unhandled Exception")) { Console.ForegroundColor = ConsoleColor.DarkRed; } else { Console.ForegroundColor = ConsoleColor.White; } Console.WriteLine("({0}) <RealmServer> {1}", DateTime.Now.ToString("hh:mm"), ex.Data); }; try { RealmServer.OutputReceived += RealmServerOutputHandler; RealmServer.Start(); } catch (NullReferenceException) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("({0}) <Terminal> Failed to start RealmServer. Check Config.xml settings.", DateTime.Now.ToString("hh:mm")); } } } }