private void Window_Closing(object sender, CancelEventArgs e) { Utilities.Log("this.Window_Closing() called"); if (GetBattlefield3Process() != null) { Utilities.Log("GetBattlefield3Process() != null"); this.Battlelog.ExecuteJavascript(JSDialog.ShowJavascriptDialog(new OKDialog("Battlefield 3 is still running", "Quit Battlefield 3 before closing Battlelogium"))); e.Cancel = true; return; } // Shutdown WebCore try { Utilities.Log("WebCore.Shutdown()"); WebCore.Shutdown(); } catch (Exception ex) { Utilities.Log("Exception occured when WebCore shutdown"); Utilities.Log(ex.ToString()); } Timer cleanupOriginTimer = new Timer(config.WaitTimeToKillOrigin); cleanupOriginTimer.AutoReset = false; cleanupOriginTimer.Elapsed += delegate { Dispatcher.Invoke(new Action(delegate { if (config.HandleOrigin) { Utilities.Log("managedOrigin.KillOriginProcess()"); managedOrigin.KillOriginProcess(); } Utilities.Log("Utilities.KillProcess(sonarhost)"); Utilities.KillProcess("sonarhost", false, false); if (this.retainOrigin) { Utilities.Log("retainOrigin = True"); //We do not want this instance of Origin to be a child process, otherwise Steam will think we're still in Battlefield 3 Utilities.Log("ManagedOrigin.CreateUnmanagedInstance"); ManagedOrigin.CreateUnmanagedInstance(); } Utilities.Log("!---End Log---!"); Utilities.Log("Press Enter to Exit. Remember to submit battlelogium.log"); Utilities.FreeConsole(); })); }; Utilities.Log("Waiting " + config.WaitTimeToKillOrigin * 1000 + " milliseconds to kill Origin"); notifyIcon.Text = "Battlelogium is waiting for Origin and ESN Sonar to close"; cleanupOriginTimer.Start(); this.Hide(); System.Threading.Thread.Sleep(config.WaitTimeToKillOrigin * 1000 + 5000); notifyIcon.Visible = false; }
private void NewGroupForm_Load(object sender, EventArgs e) { ; cancelButton.Location = new Point(Width - 101, Height - 33); okButton.Location = new Point(Width - 201, Height - 33); chromiumWebBrowser1.ConsoleMessage += ChromiumWebBrowser1_ConsoleMessage; chromiumWebBrowser1.JavascriptObjectRepository.ObjectsBoundInJavascript += JavascriptObjectRepository_ObjectsBoundInJavascript; var d = new JSDialog(); chromiumWebBrowser1.JsDialogHandler = d; isload = false; }
private void BindJavascriptEvents(JSObject jsObject) { Utilities.Log("BattlelogiumMain.BindJavascriptEvents Called"); jsObject.Bind("quitConfirm", false, new JavascriptMethodEventHandler(delegate { Utilities.Log("Javascript QuitButton pressed"); this.Battlelog.ExecuteJavascript(JSDialog.ShowJavascriptDialog(new QuitConfirmDialog("Are you sure you want to quit?", "Do you want to quit?"))); })); Utilities.Log("Bound wrapper.quitConfirm()"); jsObject.Bind("minimize", false, new JavascriptMethodEventHandler(delegate { Utilities.Log("Javascript Minimize pressed"); this.WindowState = WindowState.Minimized; })); Utilities.Log("Bound wrapper.minimize()"); jsObject.Bind("quitWrapper", false, new JavascriptMethodEventHandler(delegate { Utilities.Log("Quit requested from Javascript call"); this.Close(); })); Utilities.Log("Bound wrapper.quitWrapper()"); jsObject.Bind("clearCache", false, new JavascriptMethodEventHandler(delegate { Utilities.Log("Javascript ClearCache pressed"); this.Battlelog.WebSession.ClearCache(); this.Battlelog.WebSession.ClearCookies(); this.Battlelog.Reload(true); })); Utilities.Log("Bound wrapper.clearCache()"); jsObject.Bind("editSettings", false, new JavascriptMethodEventHandler(delegate { Utilities.Log("Javascript EditSettings pressed"); using (var configEditor = new BattlelogiumConfigEditor(config)) { var result = configEditor.ShowDialog(); if (result == System.Windows.Forms.DialogResult.OK) { this.Battlelog.ExecuteJavascript(JSDialog.ShowJavascriptDialog(new QuitConfirmDialog("Settings will be saved on restart", "Do you wish to quit Battlelogium now?"), false)); } } })); Utilities.Log("Bound wrapper.editSettings()"); }