public ConsoleView(ViewModel dataContext) { DataContext = dataContext; //Check if the programm has been started inside a console bool hasConsole = ConsoleHelper.AttachConsole(-1); if (!hasConsole) { //If not, create a new one ConsoleHelper.AllocConsole(); } Console.WriteLine(); PrintLine(); Console.WriteLine("CCC Dedicated Server"); PrintLine(); dataContext.StartCommand.Execute(this); Console.WriteLine("Server started at: "); Console.WriteLine("Port: " + dataContext.Port); Console.WriteLine("LocalIP: " + dataContext.LocalAddress); Console.WriteLine("PublicIP: " + dataContext.PublicAddress); PrintLine(); dataContext.Clients.CollectionChanged += OnNewClient; //dataContext.StopCommand.Execute(this); //Console.WriteLine("Server stopped"); //Console.ReadKey(true); //while (true){ } Debug.WriteLine("Started"); Console.ReadLine(); }
private static void Main(string[] args) { Application.EnableVisualStyles(); ConsoleHelper.AllocConsole(); ConsoleHelper.HideConsoleWindow(); Application.Run(new MainForm(args)); }
private void Application_Startup(object sender, StartupEventArgs e) { string languageCode = "en"; var profileConfigPath = Path.Combine(Directory.GetCurrentDirectory(), "config"); var configFile = Path.Combine(profileConfigPath, "config.json"); var translationsDir = Path.Combine(profileConfigPath, "Translations"); var subPath = ""; var validateJSON = false; // TODO Need to re-enable validation for GUI. if (File.Exists(configFile)) { try { var config = GlobalSettings.Load(subPath, validateJSON); languageCode = config.ConsoleConfig.TranslationLanguageCode; } catch (Exception ex) { MessageBox.Show(ex.Message, "Config Error", MessageBoxButton.OK, MessageBoxImage.Error); Shutdown(); } } if (!Directory.Exists(translationsDir)) { Directory.CreateDirectory(translationsDir); } var uiTranslation = new UITranslation(languageCode); TinyIoCContainer.Current.Register(uiTranslation); MainWindow = new MainClientWindow(); ConsoleHelper.AllocConsole(); UILogger logger = new UILogger() { LogToUI = ((MainClientWindow)MainWindow).LogToConsoleTab }; Logger.AddLogger(logger, string.Empty); Task.Run(() => { NecroBot.CLI.Program.RunBotWithParameters(OnBotStartedEventHandler, new string[] { }); }); if (Settings.Default.ConsoleToggled == true) { ConsoleHelper.ShowConsoleWindow(); } if (Settings.Default.ConsoleToggled == false) { ConsoleHelper.HideConsoleWindow(); } MainWindow.Show(); }
protected override void OnStartup(StartupEventArgs e) { ConsoleHelper.AllocConsole(); Console.WriteLine("Start"); System.Threading.Thread.Sleep(1000); Console.WriteLine("Stop"); ConsoleHelper.FreeConsole(); Shutdown(0); }
static void Main(string[] args) { // Check for required DLL. if (!File.Exists("WhiteNet.dll")) { MessageBox.Show("Missing WhiteNet.dll"); return; } // Check Arguments. bool gui = false; foreach (string argument in args) { switch (argument) { case "-gui": gui = true; break; default: break; } } // Create Viewmodel. ViewModel viewmodel = new ViewModel(); // Create view. if (gui) { Application a = new Application(); View view = new View(); view.DataContext = viewmodel; a.Run(view); } else { // Check if the programm has been started inside a console. bool hasConsole = ConsoleHelper.AttachConsole(-1); if (!hasConsole) { // If not, create a new one. ConsoleHelper.AllocConsole(); } ConsoleView view = new ConsoleView(viewmodel); // Free Console after the programm ends. ConsoleHelper.FreeConsole(); } Environment.Exit(0); }
static void Main() { // Get command line arguments string[] args = Environment.GetCommandLineArgs(); // Parse command line arguments try { var p = new OptionSet() .Add("AutoInject:", "Automatically poll for PS4 Remote Play and inject whenever possible", v => m_Settings.AutoInject = v == null ? true : Convert.ToBoolean(v)) .Add("BypassInjection:", "Bypass the injection for debugging purposes", v => m_Settings.BypassInjection = v == null ? true : Convert.ToBoolean(v)) .Add("EmulateController:", "Run with controller emulation (use without a controller)", v => m_Settings.EmulateController = v == null ? true : Convert.ToBoolean(v)) .Add("ShowConsole:", "Open debugging console on launch", v => m_Settings.ShowConsole = v == null ? true : Convert.ToBoolean(v)) .Add("StartupFile=", "Absolute or relative path to the file to load on launch (can be xml or dll)", v => m_Settings.StartupFile = v); p.Add("SettingsFile=", "Absolute or relative path to the settings file (will take priority)", v => m_Settings = Settings.Load(v)); p.Add("h|?|help", "Displays this help message", v => { p.WriteOptionDescriptions(Console.Out); Environment.Exit(0); }); var extras = p.Parse(args); } catch (OptionException ex) { Console.WriteLine(ex.Message); Console.WriteLine("Try `PS4Macro --help` for usage."); } // Display console for debugging if enabled if (Settings.ShowConsole) { ConsoleHelper.AllocConsole(); ConsoleHelper.SetOut(); } // Add the event handler for handling UI thread exceptions to the event. Application.ThreadException += new ThreadExceptionEventHandler(OnThreadException); // Set the unhandled exception mode to force all Windows Forms errors // to go through the handler. Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); // Add the event handler for handling non-UI thread exceptions to the event. AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(OnUnhandledException); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Forms.MainForm()); }
public App() { var isDebugStr = ConfigurationManager.AppSettings["IsDebug"]; bool isDebug; bool.TryParse(isDebugStr, out isDebug); if (isDebug) { ConsoleHelper.AllocConsole(); } LogUtil.Init(typeof(App)); this.Startup += OnStartup; this.DispatcherUnhandledException += OnDispatcherUnhandledException; }
private void Application_Startup(object sender, StartupEventArgs e) { // base.OnStartup(e); MainWindow = new MainClientWindow(); ConsoleHelper.AllocConsole(); UILogger logger = new UILogger(); logger.LogToUI = ((MainClientWindow)MainWindow).LogToConsoleTab; Logger.AddLogger(logger, string.Empty); Task.Run(() => { NecroBot.CLI.Program.RunBotWithParameters(OnBotStartedEventHandler, new string[] { }); }); ConsoleHelper.HideConsoleWindow(); MainWindow.Show(); }
private void Application_Startup(object sender, StartupEventArgs e) { string languageCode = "en"; if (File.Exists("config\\config.json")) { var config = GlobalSettings.Load("config", false); languageCode = config.ConsoleConfig.TranslationLanguageCode; } if (!System.IO.Directory.Exists(@"config\Translations")) { System.IO.Directory.CreateDirectory(@"config\Translations"); } var uiTranslation = new UITranslation(languageCode); TinyIoCContainer.Current.Register <UITranslation>(uiTranslation); MainWindow = new MainClientWindow(); ConsoleHelper.AllocConsole(); UILogger logger = new UILogger(); logger.LogToUI = ((MainClientWindow)MainWindow).LogToConsoleTab; Logger.AddLogger(logger, string.Empty); Task.Run(() => { NecroBot.CLI.Program.RunBotWithParameters(OnBotStartedEventHandler, new string[] { }); }); ConsoleHelper.HideConsoleWindow(); MainWindow.Show(); }