private void discardButton_Click(object sender, RoutedEventArgs e) { if (MessageBoxUtils.ShowChoiceDialog("Are you sure you want to discard your changes?", "Discard Changes", "Discard Changes", "Cancel")) { this.DialogResult = false; this.Close(); } }
private static void AddSteam() { WindowsPrincipal pricipal = new WindowsPrincipal(WindowsIdentity.GetCurrent()); bool hasAdministrativeRight = pricipal.IsInRole(WindowsBuiltInRole.Administrator); if (!hasAdministrativeRight) { // relaunch the application with admin rights string fileName = Assembly.GetExecutingAssembly().Location; ProcessStartInfo processInfo = new ProcessStartInfo(); processInfo.Arguments = "addsteam"; processInfo.Verb = "runas"; processInfo.FileName = fileName; try { Process.Start(processInfo); } catch (Win32Exception) { // This will be thrown if the user cancels the prompt } return; } string quote = "\""; string space = " "; // Process.Start("taskkill", "/im steam.exe /f").WaitForExit(); if (ProcessTools.IsProcessRunning("steam")) { MessageBox.Show("Please close Steam before continuing"); } if (ProcessTools.IsProcessRunning("steam")) { bool result = MessageBoxUtils.ShowChoiceDialog("Force close Steam? (Not recommended, close Steam manually if possible)", "Close Steam before adding shortcuts to Steam", "Force Close Steam", "I will close Steam manually"); switch (result) { case true: ProcessTools.KillProcess("steam", true, false); break; case false: ProcessTools.KillProcess("steam", true, true); //CloseMainWindow shouldn't close steam, use as a lazy shortcut to process.Wait() break; } } Process.Start("steam_shortcut_manager_cli.exe", "all" + space + quote + "Medal of Honor Warfighter" + quote + space + quote + Path.GetFullPath("Battlelogium.UI.MOHW.exe") + quote).WaitForExit(); Process.Start("steam_shortcut_manager_cli.exe", "all" + space + quote + "Battlefield 3" + quote + space + quote + Path.GetFullPath("Battlelogium.UI.BF3.exe") + quote).WaitForExit(); Process.Start("steam_shortcut_manager_cli.exe", "all" + space + quote + "Battlefield 4" + quote + space + quote + Path.GetFullPath("Battlelogium.UI.BF4.exe") + quote).WaitForExit(); Process.Start("steam_shortcut_manager_cli.exe", "all" + space + quote + "Battlefield Hardline Beta" + quote + space + quote + Path.GetFullPath("Battlelogium.UI.BFH.exe") + quote).WaitForExit(); }
public async Task Initialize() { this.mainWindow.Icon = BitmapFrame.Create(new Uri(@"pack://application:,,/images/bg_icon.ico")); //Set runtime icon to Battlelogium badged ico switch (this.config.FullscreenMode) { case true: this.mainWindow.SetFullScreen(); break; case false: this.mainWindow.SetWindowed(); break; } if (config.CheckUpdates) { await this.CheckUpdate(); } bool isBattlelogAvailable = await BattlelogBase.CheckBattlelogConnectionAsync(); if (!isBattlelogAvailable) { bool offlineMode = MessageBoxUtils.ShowChoiceDialog("Battlelog is unavailable. Would you like to start Offline Campaign?", "Battlelog unavailable", "Start Campaign", "Exit Battlelogium"); switch (offlineMode) { case true: this.StartOfflineMode(); return; case false: this.mainWindow.Close(); return; } } this.battlelog.InitializeWebview(); this.battlelog.javascriptObject.InitJavascriptObject(this); this.mainWindow.MainControl.VersionNumber = "Battlelogium " + Assembly.GetEntryAssembly().GetName().Version.ToString(); this.mainWindow.MainControl.MainGrid.Children.Add(battlelog.battlelogWebview); this.mainWindow.Title = "Battlelogium - " + battlelog.battlefieldName; this.mainWindow.Closed += (s, e) => { if (config.ManageOrigin) { this.managedOrigin.KillOrigin(config.WaitTimeToKillOrigin * 1000); } }; this.mainWindow.PreviewKeyDown += mainWindow_PreviewKeyDown; this.mainWindow.PreviewMouseDown += (s, e) => { if (e.ChangedButton == MouseButton.Middle) { e.Handled = true; } }; //Disable opening link in new window with middle click this.battlelog.battlelogWebview.PropertyChanged += battlelogWebview_IsLoading; this.mainWindow.StateChanged += (s, e) => { try { this.battlelog.battlelogWebview.ExecuteScript("windowbutton.updateMaximizeButton()"); }catch { } }; if (config.ManageOrigin) { #if !NO_ORIGIN //ugly ifdefs are ugly. this.managedOrigin.StartOrigin(); #endif } if (config.DisableHardwareAccel) { RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly; } this.IsInitialized = true; }