public bool MakeGamesConfiguration(TranslationsHelpers translator, Settings settings, Game game) { string body; string title; CustomMessageBox cmb; if (game != null && settings.DosboxDefaultConfFilePath != String.Empty) { if (File.Exists(settings.DosboxDefaultConfFilePath)) { body = "'" + game.Directory + "/" + Path.GetFileName(settings.DosboxDefaultConfFilePath) + "' " + translator.GetTranslatedMessage(settings.Language, 64, "already exists, do you want to overwrite it ?"); title = translator.GetTranslatedMessage(settings.Language, 8, "Attention"); cmb = new CustomMessageBox(body, title, MessageBoxDialogButtons.YesNo, MessageBoxDialogIcon.Question, false, false); if ((!File.Exists(game.Directory + "/" + Path.GetFileName(settings.DosboxDefaultConfFilePath))) || (cmb.ShowDialog() == DialogResult.Yes)) { if (Directory.Exists(game.Directory)) { File.Copy(settings.DosboxDefaultConfFilePath, game.Directory + "/" + Path.GetFileName(settings.DosboxDefaultConfFilePath), true); game.DBConfigPath = game.Directory + "/" + Path.GetFileName(settings.DosboxDefaultConfFilePath); body = translator.GetTranslatedMessage(settings.Language, 65, "The configuration file has been created correctly."); title = translator.GetTranslatedMessage(settings.Language, 66, "Success"); cmb = new CustomMessageBox(body, title, MessageBoxDialogButtons.Ok, MessageBoxDialogIcon.Information, false, false); cmb.ShowDialog(); cmb.Dispose(); return(true); } else { body = translator.GetTranslatedMessage(settings.Language, 67, "The path to the selected game seems missing, please check and eventually modify the game folder location to continue."); title = translator.GetTranslatedMessage(settings.Language, 28, "Error"); cmb = new CustomMessageBox(body, title, MessageBoxDialogButtons.Ok, MessageBoxDialogIcon.Error, false, false); cmb.ShowDialog(); cmb.Dispose(); return(false); } } else { return(false); } } else { body = translator.GetTranslatedMessage(settings.Language, 68, "The path to the given DosBox configuration file seems missing, please check and eventually modify the DosBox configuration file location to continue."); title = translator.GetTranslatedMessage(settings.Language, 28, "Error"); cmb = new CustomMessageBox(body, title, MessageBoxDialogButtons.Ok, MessageBoxDialogIcon.Error, false, false); cmb.ShowDialog(); cmb.Dispose(); return(false); } } return(false); }
private void btnGetGameData_Click(object sender, EventArgs e) { if (_selectedGame != null) { if (_game == null || _game.GameURI != _selectedGame.Uri) { _game = _scraper.RetrieveGameData(_selectedGame.Uri); if (_game == null) { return; } //Retrieving first available screenshot if (_game.Screenshots != null && _game.Screenshots.Count > 0) { _scraper.DownloadFileCompleted += _scraper_DownloadFileCompleted; _scraper.DownloadMedia(_game.Screenshots[0], Application.StartupPath + "\\tmp.img"); } } else if (_game != null) { CustomMessageBox cmb = new CustomMessageBox(_manager.Translator.GetTranslatedMessage(_manager.AppSettings.Language, 77, "Download Completed!!!"), _manager.Translator.GetTranslatedMessage(_manager.AppSettings.Language, 59, "Information"), MessageBoxDialogButtons.Ok, MessageBoxDialogIcon.Information, false, false); cmb.ShowDialog(); cmb.Dispose(); } } }
public bool MoveGameToCategory(int GameID, int CategoryID) { try { if (_Connection.State != System.Data.ConnectionState.Open) { //I raise an error as there is no connection to the database throw new Exception("There is no connection to the database"); } String sql = String.Format("UPDATE Games SET category_id = {1} WHERE id = {0}", GameID, CategoryID); SQLiteCommand command = new SQLiteCommand(sql, _Connection); command.ExecuteNonQuery(); return(true); } catch (Exception e) { CustomMessageBox cmb = new CustomMessageBox("An error raised trying to move the selected game to the new category:\n" + e.Message, "Error", MessageBoxDialogButtons.Ok, MessageBoxDialogIcon.Error, false, false); cmb.ShowDialog(); cmb.Dispose(); return(false); } }
public MainForm(AppManager manager) { _flgLoading = true; InitializeComponent(); _manager = manager; if (_manager == null) { CustomMessageBox cmb = new CustomMessageBox("The application manager has not been loaded for some reason.\nThe application can't work and will be closed.", "FATAL", MessageBoxDialogButtons.Ok, MessageBoxDialogIcon.Fatal, false, false); cmb.ShowDialog(); cmb.Dispose(); this.Close(); } InitializeStyle(); InitializeGUIEventsHandlers(); categoriesTabs.Manager = _manager; SetupUI(); _SelectedCategory = -1; _SelectedGame = -1; EnableMenus(false); if (_manager.AppSettings.ReloadLatestDB && (_manager.RecentDBs != null && _manager.RecentDBs.Count > 0)) OpenRecentDatabase(_manager.RecentDBs.First().Value.DBPath, false); _flgLoading = false; }
public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton) { CustomMessageBox customMessageBox = new CustomMessageBox(text, caption, buttons, icon, defaultButton); DialogResult dialogResult = customMessageBox.ShowDialog(owner); customMessageBox.Dispose(); return(dialogResult); }
public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, string promptText, IList <string> voidTypeNames, ref string inputValue) { CustomMessageBox customMessageBox = new CustomMessageBox(text, caption, buttons, icon, defaultButton, promptText, voidTypeNames, inputValue); DialogResult dialogResult = customMessageBox.ShowDialog(owner); inputValue = (customMessageBox.comboVoidTypeNames.Text.Trim() + " " + customMessageBox.textRemarks.Text.Trim()).Trim(); customMessageBox.Dispose(); return(dialogResult); }
public void SaveSettings(Settings AppSettings) { if (AppSettings == null) { throw new Exception("No application settings provided!"); } try { if (_Connection.State != System.Data.ConnectionState.Open) { //I raise an error as there is no connection to the database throw new Exception("There is no connection to the database"); } StringBuilder sql = new StringBuilder(); sql.AppendLine("UPDATE Settings SET "); sql.AppendLine(string.Format("app_width = {0}, ", AppSettings.AppWidth)); sql.AppendLine(string.Format("app_height = {0}, ", AppSettings.AppHeight)); sql.AppendLine(string.Format("portable_mode = {0}, ", BoolToInt(AppSettings.PortableMode))); sql.AppendLine(string.Format("dosbox_path = '{0}', ", AppSettings.DosboxPath.Replace("'", "''"))); sql.AppendLine(string.Format("dosbox_default_conf_file_path = '{0}', ", AppSettings.DosboxDefaultConfFilePath.Replace("'", "''"))); sql.AppendLine(string.Format("dosbox_default_lang_file_path = '{0}', ", AppSettings.DosboxDefaultLangFilePath.Replace("'", "''"))); sql.AppendLine(string.Format("cds_default_dir = '{0}', ", AppSettings.CDsDefaultDir.Replace("'", "''"))); sql.AppendLine(string.Format("games_default_dir = '{0}', ", AppSettings.GamesDefaultDir.Replace("'", "''"))); sql.AppendLine(string.Format("games_no_console = {0}, ", BoolToInt(AppSettings.GamesNoConsole))); sql.AppendLine(string.Format("games_in_full_screen = {0}, ", BoolToInt(AppSettings.GamesInFullScreen))); sql.AppendLine(string.Format("games_quit_on_exit = {0}, ", BoolToInt(AppSettings.GamesQuitOnExit))); sql.AppendLine(string.Format("games_additional_commands = '{0}', ", AppSettings.GamesAdditionalCommands.Replace("'", "''"))); sql.AppendLine(string.Format("box_rendered = {0}, ", BoolToInt(AppSettings.BoxRendered))); sql.AppendLine(string.Format("app_fullscreen = {0}, ", BoolToInt(AppSettings.AppFullscreen))); sql.AppendLine(string.Format("menu_bar_visible = {0}, ", BoolToInt(AppSettings.MenuBarVisible))); sql.AppendLine(string.Format("toolbar_visible = {0}, ", BoolToInt(AppSettings.ToolbarVisible))); sql.AppendLine(string.Format("status_bar_visible = {0}, ", BoolToInt(AppSettings.StatusBarVisible))); sql.AppendLine(string.Format("config_editor_path = '{0}', ", AppSettings.ConfigEditorPath.Replace("'", "''"))); sql.AppendLine(string.Format("config_editor_additional_parameters = '{0}', ", AppSettings.ConfigEditorAdditionalParameters.Replace("'", "''"))); sql.AppendLine(string.Format("category_delete_prompt = {0}, ", BoolToInt(AppSettings.CategoryDeletePrompt))); sql.AppendLine(string.Format("game_delete_prompt = {0}, ", BoolToInt(AppSettings.GameDeletePrompt))); sql.AppendLine(string.Format("remember_window_size = {0}, ", BoolToInt(AppSettings.RememberWindowSize))); sql.AppendLine(string.Format("reload_latest_db = {0}, ", BoolToInt(AppSettings.ReloadLatestDB))); sql.AppendLine(string.Format("language = {0}, ", ((AppSettings.Language == Settings.Languages.English) ? 0 : 1))); sql.AppendLine(string.Format("reduce_to_tray_on_play = {0};", BoolToInt(AppSettings.ReduceToTrayOnPlay))); SQLiteCommand command = new SQLiteCommand(sql.ToString(), _Connection); command.ExecuteNonQuery(); } catch (Exception e) { CustomMessageBox cmb = new CustomMessageBox("An issues raised trying to save the application settings:\n" + e.Message, "Error", MessageBoxDialogButtons.Ok, MessageBoxDialogIcon.Error, false, false); cmb.ShowDialog(); cmb.Dispose(); } }
public List <MyAbandonGameFound> SearchGames(string GameName) { try { //Preparing URL and result holder string queryResult = string.Empty; string queryUri = string.Format(baseSearchUri, GameName); //Performing web request to retrieve the page. request = (HttpWebRequest)WebRequest.Create(queryUri); response = (HttpWebResponse)request.GetResponse(); if (response.StatusCode == HttpStatusCode.OK) { Stream receiveStream = response.GetResponseStream(); StreamReader readStream = null; readStream = new StreamReader(receiveStream, Encoding.UTF8); queryResult = WebUtility.HtmlDecode(readStream.ReadToEnd()); response.Close(); readStream.Close(); } //Scraping the response to extract the founded games List <MyAbandonGameFound> result = ParseSearchResult(queryResult); return(result); } catch (Exception e) { CustomMessageBox cmb = new CustomMessageBox(e.Message, _manager.Translator.GetTranslatedMessage(_manager.AppSettings.Language, 28, "Error"), MessageBoxDialogButtons.Ok, MessageBoxDialogIcon.Error, false, false); cmb.ShowDialog(); cmb.Dispose(); return(null); } }
void _scraper_DownloadFileCompleted(object sender, string DestinationFile) { try { if (File.Exists(Application.StartupPath + "\\tmp.img")) { _gameScreenshot = Application.StartupPath + "\\tmp.img"; CustomMessageBox cmb = new CustomMessageBox(_manager.Translator.GetTranslatedMessage(_manager.AppSettings.Language, 77, "Download Completed!!!"), _manager.Translator.GetTranslatedMessage(_manager.AppSettings.Language, 59, "Information"), MessageBoxDialogButtons.Ok, MessageBoxDialogIcon.Information, false, false); cmb.ShowDialog(); cmb.Dispose(); } else { _gameScreenshot = string.Empty; } } catch (Exception) { _gameScreenshot = string.Empty; } }
void _scraper_DownloadFileCompleted(object sender, string DestinationFile) { try { if (File.Exists(Application.StartupPath + "\\tmp.img")) { _gameScreenshot = Application.StartupPath + "\\tmp.img"; CustomMessageBox cmb = new CustomMessageBox(_manager.Translator.GetTranslatedMessage(_manager.AppSettings.Language, 77, "Download Completed!!!"), _manager.Translator.GetTranslatedMessage(_manager.AppSettings.Language, 59, "Information"), MessageBoxDialogButtons.Ok, MessageBoxDialogIcon.Information, false, false); cmb.ShowDialog(); cmb.Dispose(); } else _gameScreenshot = string.Empty ; } catch (Exception) { _gameScreenshot = string.Empty; } }
private void btnGetGameData_Click(object sender, EventArgs e) { if(_selectedGame != null){ if (_game == null || _game.GameURI != _selectedGame.Uri) { _game = _scraper.RetrieveGameData(_selectedGame.Uri); if (_game == null) return; //Retrieving first available screenshot if (_game.Screenshots != null && _game.Screenshots.Count > 0) { _scraper.DownloadFileCompleted += _scraper_DownloadFileCompleted; _scraper.DownloadMedia(_game.Screenshots[0], Application.StartupPath + "\\tmp.img"); } } else if( _game != null ) { CustomMessageBox cmb = new CustomMessageBox(_manager.Translator.GetTranslatedMessage(_manager.AppSettings.Language, 77, "Download Completed!!!"), _manager.Translator.GetTranslatedMessage(_manager.AppSettings.Language, 59, "Information"), MessageBoxDialogButtons.Ok, MessageBoxDialogIcon.Information, false, false); cmb.ShowDialog(); cmb.Dispose(); } } }
public bool RemoveGame(int GameID) { try { if (_Connection.State != System.Data.ConnectionState.Open) //I raise an error as there is no connection to the database throw new Exception("There is no connection to the database"); String sql = String.Format("DELETE FROM Games WHERE id = {0}", GameID); SQLiteCommand command = new SQLiteCommand(sql, _Connection); command.ExecuteNonQuery(); return true; } catch (Exception e) { CustomMessageBox cmb = new CustomMessageBox("An error raised trying to remove the selected game:\n" + e.Message, "Error",MessageBoxDialogButtons.Ok,MessageBoxDialogIcon.Error,false,false); cmb.ShowDialog(); cmb.Dispose(); return false; } }
private void RunGame(int GameID) { if (GameID == -1) return; Game gamesFromId = _manager.DB.GetGameFromID(GameID); string str = _manager.DosBoxHelper.BuildArgs(false, gamesFromId, _manager.AppSettings); if (str == null) { CustomMessageBox customMessageBox = new CustomMessageBox(_manager.Translator.GetTranslatedMessage(_manager.AppSettings.Language, 22, "DOSBox cannot be run (was it removed?)!"), _manager.Translator.GetTranslatedMessage(_manager.AppSettings.Language, 23, "Run Game"), MessageBoxDialogButtons.Ok, MessageBoxDialogIcon.Error, false, false); customMessageBox.ShowDialog(); customMessageBox.Dispose(); } else { if (_manager.AppSettings.ReduceToTrayOnPlay) { notifyIcon.Visible = true; notifyIcon.BalloonTipText = _manager.Translator.GetTranslatedMessage(_manager.AppSettings.Language, 73, "DOSBox Manager is still running and will raise back once closing the game."); notifyIcon.BalloonTipTitle = "DOSBox Manager"; notifyIcon.BalloonTipIcon = ToolTipIcon.Info; notifyIcon.ShowBalloonTip(500); Hide(); } Process process = new Process(); process.StartInfo.WorkingDirectory = gamesFromId.Directory != string.Empty ? gamesFromId.Directory : _manager.FileHelper.ExtractFilePath(gamesFromId.DOSExePath); process.StartInfo.FileName = _manager.AppSettings.DosboxPath; process.StartInfo.Arguments = str; process.Start(); process.WaitForExit(); if (_manager.AppSettings.ReduceToTrayOnPlay) { notifyIcon.Visible = false; Show(); } } }
private void DeleteCategory(int CategoryID) { Category category = _manager.DB.GetCategory(CategoryID); string Body = string.Format(_manager.Translator.GetTranslatedMessage(_manager.AppSettings.Language, 19, "You are about to remove the {0} category."), (object)category.Name) + "\n" + _manager.Translator.GetTranslatedMessage(_manager.AppSettings.Language, 20, "This will also remove all the games of the category.") + "\n" + _manager.Translator.GetTranslatedMessage(_manager.AppSettings.Language, 21, "Are you sure you want to continue?"); string translatedMessage = _manager.Translator.GetTranslatedMessage(_manager.AppSettings.Language, 8, "Attention"); if (_manager.AppSettings.CategoryDeletePrompt) { CustomMessageBox customMessageBox = new CustomMessageBox(Body, translatedMessage, MessageBoxDialogButtons.YesNo, MessageBoxDialogIcon.Warning, true, true); customMessageBox.ShowDialog(); if (customMessageBox.Result == MessageBoxDialogResult.Yes && _manager.DB.RemoveCategory(category.ID)) { RefreshCategories(); UpdateStatusBar(); } if (!customMessageBox.AskAgain) { _manager.AppSettings.CategoryDeletePrompt = false; _manager.SettingsDB.SaveSettings(_manager.AppSettings); } customMessageBox.Dispose(); } else if (_manager.DB.RemoveCategory(category.ID)) { RefreshCategories(); UpdateStatusBar(); } }
private MyAbandonGameInfo ParseGamePage(string queryResult) { MyAbandonGameInfo result = null; if (queryResult != string.Empty) { htmlDoc.LoadHtml(queryResult); if (htmlDoc.ParseErrors != null && htmlDoc.ParseErrors.Count() > 0) { // Handle any parse errors as required string errorMessage = string.Empty; foreach (HtmlParseError error in htmlDoc.ParseErrors) { errorMessage += error.Reason + "\n"; } CustomMessageBox cmb = new CustomMessageBox(errorMessage, _manager.Translator.GetTranslatedMessage(_manager.AppSettings.Language, 28, "Error"), MessageBoxDialogButtons.Ok, MessageBoxDialogIcon.Error, false, false); cmb.ShowDialog(); cmb.Dispose(); } else { if (htmlDoc.DocumentNode != null) { HtmlNode bodyNode = htmlDoc.DocumentNode.SelectSingleNode("//body//div[@class='box']"); if (bodyNode != null) { result = new MyAbandonGameInfo(); //Game Name HtmlNode nameNode = bodyNode.SelectSingleNode("//h2[@itemprop='name']"); if (nameNode != null) { result.Title = nameNode.InnerText.Trim(); } //Game Data HtmlNode gameDataNode = bodyNode.SelectSingleNode("//div[@class='gameData']/dl"); if (gameDataNode != null) { foreach(HtmlNode itemNode in gameDataNode.ChildNodes) { if (itemNode.Name.ToLower() == "dt") { if (itemNode.InnerText.Trim().ToLower() == "year") flags.SetFlags(true, false, false, false, false, false, false, false, false); if (itemNode.InnerText.Trim().ToLower() == "platform") flags.SetFlags(false, true, false, false, false, false, false, false, false); if (itemNode.InnerText.Trim().ToLower() == "released in") flags.SetFlags(false, false, true, false, false, false, false, false, false); if (itemNode.InnerText.Trim().ToLower() == "genre") flags.SetFlags(false, false, false, true, false, false, false, false, false); if (itemNode.InnerText.Trim().ToLower() == "theme") flags.SetFlags(false, false, false, false, true, false, false, false, false); if (itemNode.InnerText.Trim().ToLower() == "publisher") flags.SetFlags(false, false, false, false, false, true, false, false, false); if (itemNode.InnerText.Trim().ToLower() == "developer") flags.SetFlags(false, false, false, false, false, false, true, false, false); if (itemNode.InnerText.Trim().ToLower() == "perspectives") flags.SetFlags(false, false, false, false, false, false, false, true, false); if (itemNode.InnerText.Trim().ToLower() == "dosbox support") flags.SetFlags(false, false, false, false, false, false, false, false, true); } if(itemNode.Name.ToLower() == "dd") { if(flags.IsYear) result.Year= WebUtility.HtmlDecode(itemNode.InnerText.Trim()); if (flags.IsPlatform) result.Platform = WebUtility.HtmlDecode(itemNode.InnerText.Trim()); if (flags.IsReleasedIn) result.ReleasedIn = WebUtility.HtmlDecode(itemNode.InnerText.Trim()); if(flags.IsGenre) result.Genre = WebUtility.HtmlDecode(itemNode.InnerText.Trim()); if (flags.IsTheme) { string themeString = WebUtility.HtmlDecode(itemNode.InnerText.Trim()); if (themeString != string.Empty) result.Themes = themeString.Replace(", ",",").Split(',').ToList(); } if (flags.IsPublisher) result.Publisher = WebUtility.HtmlDecode(itemNode.InnerText.Trim()); if (flags.IsDeveloper) result.Developer = WebUtility.HtmlDecode(itemNode.InnerText.Trim()); if (flags.IsPerspectives) { string perspectiveString = WebUtility.HtmlDecode(itemNode.InnerText.Trim()); if (perspectiveString != string.Empty) result.Perspectives = perspectiveString.Replace(", ", ",").Split(',', ' ').ToList(); } if (flags.IsDosBox) result.DosBoxVersion = WebUtility.HtmlDecode(itemNode.InnerText.Trim()); } } } //Game Vote HtmlNode voteNode = bodyNode.SelectSingleNode("//span[@itemprop='ratingValue']"); if (voteNode != null) result.Vote = voteNode.InnerText; //Game Descritpion //First I check if exists the proper node HtmlNode descriptionNode = bodyNode.SelectSingleNode("//div[@class='gameDescription dscr']"); if (descriptionNode != null) { result.Description = WebUtility.HtmlDecode(descriptionNode.InnerText); } else { //As it seems missing I try the other one descriptionNode = bodyNode.SelectSingleNode("//div[@class='box']/h3[@class='cBoth']"); if (descriptionNode != null) { HtmlNode descNone = descriptionNode.ParentNode.SelectSingleNode("p"); if (descNone != null) result.Description = WebUtility.HtmlDecode(descNone.InnerText); } } //Game Screenshots HtmlNodeCollection screenshotsNodes = bodyNode.SelectNodes("//body//div[@class='thumb']/a[@class='lb']/img"); if (screenshotsNodes != null) { foreach (HtmlNode screen in screenshotsNodes) { if(screen.Name.ToLower().Trim() == "img") { if (result.Screenshots == null) result.Screenshots = new List<string>(); result.Screenshots.Add(GetMediaURI(screen.Attributes["src"].Value)); } } } //Game Download & Size HtmlNode downloadNode = bodyNode.SelectSingleNode("//a[@class='button download']"); if (downloadNode != null) { result.DownloadLink = downloadNode.Attributes["href"].Value; HtmlNode downloadSize = downloadNode.SelectSingleNode("//a[@class='button download']/span"); if (downloadSize != null) { result.DownloadSize = downloadSize.InnerText.Trim(); } } } } } } return result; }
private void OpenGameDialog(Game game, bool isEditing) { GameDialog gameDialog = new GameDialog(_manager, game, isEditing); if (gameDialog.ShowDialog() != DialogResult.OK) return; game = gameDialog.GameData; if (game == null) return; //First I check if there are new categories to be added Dictionary<String, Category> cats = gameDialog.Cats; foreach (Category cat in cats.Values) { if (cat.ID == -1) { int catID = _manager.DB.AddCategory(cat.Name, string.Empty); if (catID > 0) { game.CategoryID = catID; } } } //I check the game cover path. If it is the temporary path used when loading screenshots from MyAbandonware // then I copy it inside the game path and I remove the temporary one. if (game.ImagePath == Application.StartupPath + "\\tmp.img") { string newCoverPath = string.Empty; if (game.Directory != string.Empty) { newCoverPath = game.Directory + string.Format("\\{0}.jpg",GetHDFineFileName(game.Title)); } else if (game.DOSExePath != string.Empty) { newCoverPath = _manager.FileHelper.ExtractFilePath(game.DOSExePath) + string.Format("\\{0}.jpg", GetHDFineFileName(game.Title)); } if (newCoverPath != string.Empty) { newCoverPath = GetOverwriteSafeFileName(newCoverPath, 0); File.Copy(game.ImagePath, newCoverPath, true); } game.ImagePath = newCoverPath; } //Now I save the game if (_manager.DB.SaveGame(game)) { RefreshCategories(); UpdateStatusBar(); LoadCategoryGames(_SelectedCategory); } else { CustomMessageBox customMessageBox = new CustomMessageBox(_manager.Translator.GetTranslatedMessage(_manager.AppSettings.Language, 24, "An issue raised while saving the game."), _manager.Translator.GetTranslatedMessage(_manager.AppSettings.Language, 28, "Error"), MessageBoxDialogButtons.Ok, MessageBoxDialogIcon.Error, false, false); customMessageBox.ShowDialog(); customMessageBox.Dispose(); } }
public void SaveSettings(Settings AppSettings) { if (AppSettings == null) throw new Exception("No application settings provided!"); try { if (_Connection.State != System.Data.ConnectionState.Open) //I raise an error as there is no connection to the database throw new Exception("There is no connection to the database"); StringBuilder sql = new StringBuilder(); sql.AppendLine("UPDATE Settings SET "); sql.AppendLine(string.Format("app_width = {0}, ", AppSettings.AppWidth)); sql.AppendLine(string.Format("app_height = {0}, ", AppSettings.AppHeight)); sql.AppendLine(string.Format("portable_mode = {0}, ", BoolToInt(AppSettings.PortableMode))); sql.AppendLine(string.Format("dosbox_path = '{0}', ", AppSettings.DosboxPath.Replace("'", "''"))); sql.AppendLine(string.Format("dosbox_default_conf_file_path = '{0}', ", AppSettings.DosboxDefaultConfFilePath.Replace("'", "''"))); sql.AppendLine(string.Format("dosbox_default_lang_file_path = '{0}', ", AppSettings.DosboxDefaultLangFilePath.Replace("'", "''"))); sql.AppendLine(string.Format("cds_default_dir = '{0}', ", AppSettings.CDsDefaultDir.Replace("'", "''"))); sql.AppendLine(string.Format("games_default_dir = '{0}', ", AppSettings.GamesDefaultDir.Replace("'", "''"))); sql.AppendLine(string.Format("games_no_console = {0}, ", BoolToInt(AppSettings.GamesNoConsole))); sql.AppendLine(string.Format("games_in_full_screen = {0}, ", BoolToInt(AppSettings.GamesInFullScreen))); sql.AppendLine(string.Format("games_quit_on_exit = {0}, ", BoolToInt(AppSettings.GamesQuitOnExit))); sql.AppendLine(string.Format("games_additional_commands = '{0}', ", AppSettings.GamesAdditionalCommands.Replace("'", "''"))); sql.AppendLine(string.Format("box_rendered = {0}, ", BoolToInt(AppSettings.BoxRendered))); sql.AppendLine(string.Format("app_fullscreen = {0}, ", BoolToInt(AppSettings.AppFullscreen))); sql.AppendLine(string.Format("menu_bar_visible = {0}, ", BoolToInt(AppSettings.MenuBarVisible))); sql.AppendLine(string.Format("toolbar_visible = {0}, ", BoolToInt(AppSettings.ToolbarVisible))); sql.AppendLine(string.Format("status_bar_visible = {0}, ", BoolToInt(AppSettings.StatusBarVisible))); sql.AppendLine(string.Format("config_editor_path = '{0}', ", AppSettings.ConfigEditorPath.Replace("'", "''"))); sql.AppendLine(string.Format("config_editor_additional_parameters = '{0}', ", AppSettings.ConfigEditorAdditionalParameters.Replace("'", "''"))); sql.AppendLine(string.Format("category_delete_prompt = {0}, ", BoolToInt(AppSettings.CategoryDeletePrompt))); sql.AppendLine(string.Format("game_delete_prompt = {0}, ", BoolToInt(AppSettings.GameDeletePrompt))); sql.AppendLine(string.Format("remember_window_size = {0}, ", BoolToInt(AppSettings.RememberWindowSize))); sql.AppendLine(string.Format("reload_latest_db = {0}, ", BoolToInt(AppSettings.ReloadLatestDB))); sql.AppendLine(string.Format("language = {0}, ", ((AppSettings.Language == Settings.Languages.English) ? 0 : 1))); sql.AppendLine(string.Format("reduce_to_tray_on_play = {0};", BoolToInt(AppSettings.ReduceToTrayOnPlay))); SQLiteCommand command = new SQLiteCommand(sql.ToString(), _Connection); command.ExecuteNonQuery(); } catch (Exception e) { CustomMessageBox cmb = new CustomMessageBox("An issues raised trying to save the application settings:\n" + e.Message, "Error", MessageBoxDialogButtons.Ok, MessageBoxDialogIcon.Error, false, false); cmb.ShowDialog(); cmb.Dispose(); } }
private MyAbandonGameInfo ParseGamePage(string queryResult) { MyAbandonGameInfo result = null; if (queryResult != string.Empty) { htmlDoc.LoadHtml(queryResult); if (htmlDoc.ParseErrors != null && htmlDoc.ParseErrors.Count() > 0) { // Handle any parse errors as required string errorMessage = string.Empty; foreach (HtmlParseError error in htmlDoc.ParseErrors) { errorMessage += error.Reason + "\n"; } CustomMessageBox cmb = new CustomMessageBox(errorMessage, _manager.Translator.GetTranslatedMessage(_manager.AppSettings.Language, 28, "Error"), MessageBoxDialogButtons.Ok, MessageBoxDialogIcon.Error, false, false); cmb.ShowDialog(); cmb.Dispose(); } else { if (htmlDoc.DocumentNode != null) { HtmlNode bodyNode = htmlDoc.DocumentNode.SelectSingleNode("//body//div[@class='box']"); if (bodyNode != null) { result = new MyAbandonGameInfo(); //Game Name HtmlNode nameNode = bodyNode.SelectSingleNode("//h2[@itemprop='name']"); if (nameNode != null) { result.Title = nameNode.InnerText.Trim(); } //Game Data HtmlNode gameDataNode = bodyNode.SelectSingleNode("//div[@class='gameData']/dl"); if (gameDataNode != null) { foreach (HtmlNode itemNode in gameDataNode.ChildNodes) { if (itemNode.Name.ToLower() == "dt") { if (itemNode.InnerText.Trim().ToLower() == "year") { flags.SetFlags(true, false, false, false, false, false, false, false, false); } if (itemNode.InnerText.Trim().ToLower() == "platform") { flags.SetFlags(false, true, false, false, false, false, false, false, false); } if (itemNode.InnerText.Trim().ToLower() == "released in") { flags.SetFlags(false, false, true, false, false, false, false, false, false); } if (itemNode.InnerText.Trim().ToLower() == "genre") { flags.SetFlags(false, false, false, true, false, false, false, false, false); } if (itemNode.InnerText.Trim().ToLower() == "theme") { flags.SetFlags(false, false, false, false, true, false, false, false, false); } if (itemNode.InnerText.Trim().ToLower() == "publisher") { flags.SetFlags(false, false, false, false, false, true, false, false, false); } if (itemNode.InnerText.Trim().ToLower() == "developer") { flags.SetFlags(false, false, false, false, false, false, true, false, false); } if (itemNode.InnerText.Trim().ToLower() == "perspectives") { flags.SetFlags(false, false, false, false, false, false, false, true, false); } if (itemNode.InnerText.Trim().ToLower() == "dosbox support") { flags.SetFlags(false, false, false, false, false, false, false, false, true); } } if (itemNode.Name.ToLower() == "dd") { if (flags.IsYear) { result.Year = WebUtility.HtmlDecode(itemNode.InnerText.Trim()); } if (flags.IsPlatform) { result.Platform = WebUtility.HtmlDecode(itemNode.InnerText.Trim()); } if (flags.IsReleasedIn) { result.ReleasedIn = WebUtility.HtmlDecode(itemNode.InnerText.Trim()); } if (flags.IsGenre) { result.Genre = WebUtility.HtmlDecode(itemNode.InnerText.Trim()); } if (flags.IsTheme) { string themeString = WebUtility.HtmlDecode(itemNode.InnerText.Trim()); if (themeString != string.Empty) { result.Themes = themeString.Replace(", ", ",").Split(',').ToList(); } } if (flags.IsPublisher) { result.Publisher = WebUtility.HtmlDecode(itemNode.InnerText.Trim()); } if (flags.IsDeveloper) { result.Developer = WebUtility.HtmlDecode(itemNode.InnerText.Trim()); } if (flags.IsPerspectives) { string perspectiveString = WebUtility.HtmlDecode(itemNode.InnerText.Trim()); if (perspectiveString != string.Empty) { result.Perspectives = perspectiveString.Replace(", ", ",").Split(',', ' ').ToList(); } } if (flags.IsDosBox) { result.DosBoxVersion = WebUtility.HtmlDecode(itemNode.InnerText.Trim()); } } } } //Game Vote HtmlNode voteNode = bodyNode.SelectSingleNode("//span[@itemprop='ratingValue']"); if (voteNode != null) { result.Vote = voteNode.InnerText; } //Game Descritpion //First I check if exists the proper node HtmlNode descriptionNode = bodyNode.SelectSingleNode("//div[@class='gameDescription dscr']"); if (descriptionNode != null) { result.Description = WebUtility.HtmlDecode(descriptionNode.InnerText); } else { //As it seems missing I try the other one descriptionNode = bodyNode.SelectSingleNode("//div[@class='box']/h3[@class='cBoth']"); if (descriptionNode != null) { HtmlNode descNone = descriptionNode.ParentNode.SelectSingleNode("p"); if (descNone != null) { result.Description = WebUtility.HtmlDecode(descNone.InnerText); } } } //Game Screenshots HtmlNodeCollection screenshotsNodes = bodyNode.SelectNodes("//body//div[@class='thumb']/a[@class='lb']/img"); if (screenshotsNodes != null) { foreach (HtmlNode screen in screenshotsNodes) { if (screen.Name.ToLower().Trim() == "img") { if (result.Screenshots == null) { result.Screenshots = new List <string>(); } result.Screenshots.Add(GetMediaURI(screen.Attributes["src"].Value)); } } } //Game Download & Size HtmlNode downloadNode = bodyNode.SelectSingleNode("//a[@class='button download']"); if (downloadNode != null) { result.DownloadLink = downloadNode.Attributes["href"].Value; HtmlNode downloadSize = downloadNode.SelectSingleNode("//a[@class='button download']/span"); if (downloadSize != null) { result.DownloadSize = downloadSize.InnerText.Trim(); } } } } } } return(result); }
private void LoadFoundedGames(SearchEventArgs args) { RemoveGamesPanelHandlers(); List<Game> games = _manager.DB.SearchGames(args.Title, args.Year, args.Developer, args.CategoryID); Dictionary<String, Category> allCategories = _manager.DB.GetAllCategories(); if (catGames != null) catGames.Dispose(); if (games != null) { catGames = new CategoryGames(_manager, games, allCategories); catGames.BoxChangedSelection += new CategoryGames.BoxChangedSelectionDelegate(CategoryGame_BoxChangedSelection); catGames.BoxDoubleClick += new CategoryGames.BoxDoubleClickDelegate(CategoryGame_BoxDoubleClick); catGames.BoxEditClick += new CategoryGames.BoxEditClickDelegate(CategoryGame_BoxEditClick); catGames.BoxDeleteClick += new CategoryGames.BoxDeleteClickDelegate(CategoryGame_BoxDeleteClick); catGames.BoxRunClick += new CategoryGames.BoxRunClickDelegate(CategoryGame_BoxRunClick); catGames.BoxMoveToCategory += new CategoryGames.BoxMoveToCategoryDelegate(CategoryGame_BoxMoveToCategory); } else catGames = (CategoryGames)null; _SelectedGame = -1; pnlGames.Controls.Clear(); pnlGames.Controls.Add((Control)catGames); if (games == null) { EnableGamesCommands(true, false); CustomMessageBox customMessageBox = new CustomMessageBox("No games found which satisfy the specified search parameters.", "Warning", MessageBoxDialogButtons.Ok, MessageBoxDialogIcon.Warning, false, false); customMessageBox.ShowDialog(); customMessageBox.Dispose(); } else EnableGamesCommands(true, true); }
private void EditGameConfigurationFile() { if (_SelectedGame == -1) return; if (_manager.AppSettings.ConfigEditorPath != string.Empty) { if (File.Exists(_manager.AppSettings.ConfigEditorPath)) { Process.Start(_manager.AppSettings.ConfigEditorPath, _manager.DB.GetGameFromID(_SelectedGame).DBConfigPath + " " + _manager.AppSettings.ConfigEditorAdditionalParameters); } else { CustomMessageBox customMessageBox = new CustomMessageBox(_manager.Translator.GetTranslatedMessage(_manager.AppSettings.Language, 26, "The application can't find the text editor set in the application configuration.") + "\n" + _manager.Translator.GetTranslatedMessage(_manager.AppSettings.Language, 27, "Please amend the application settings to continue."), _manager.Translator.GetTranslatedMessage(_manager.AppSettings.Language, 28, "Error"), MessageBoxDialogButtons.Ok, MessageBoxDialogIcon.Error, false, false); customMessageBox.ShowDialog(); customMessageBox.Dispose(); } } else { CustomMessageBox customMessageBox = new CustomMessageBox(_manager.Translator.GetTranslatedMessage(_manager.AppSettings.Language, 29, "The text editor has not been set in the configuration file.") + "\n" + _manager.Translator.GetTranslatedMessage(_manager.AppSettings.Language, 27, "Please amend the application settings to continue."), _manager.Translator.GetTranslatedMessage(_manager.AppSettings.Language, 30, "Warning"), MessageBoxDialogButtons.Ok, MessageBoxDialogIcon.Warning, false, false); customMessageBox.ShowDialog(); customMessageBox.Dispose(); } }
private void EditGame(int GameID) { try { Game gamesFromId = _manager.DB.GetGameFromID(GameID); if (gamesFromId == null) { CustomMessageBox customMessageBox = new CustomMessageBox(_manager.Translator.GetTranslatedMessage(_manager.AppSettings.Language, 25, "It is not possible to retrieve the information of the selected event!"), _manager.Translator.GetTranslatedMessage(_manager.AppSettings.Language, 28, "Error"), MessageBoxDialogButtons.Ok, MessageBoxDialogIcon.Error, false, false); customMessageBox.ShowDialog(); customMessageBox.Dispose(); } else OpenGameDialog(gamesFromId, true); } catch (Exception ex) { CustomMessageBox customMessageBox = new CustomMessageBox(ex.Message, _manager.Translator.GetTranslatedMessage(_manager.AppSettings.Language, 28, "Error"), MessageBoxDialogButtons.Ok, MessageBoxDialogIcon.Error, false, false); customMessageBox.ShowDialog(); customMessageBox.Dispose(); } }
private void DeleteGame(int GameID) { string Body = _manager.Translator.GetTranslatedMessage(_manager.AppSettings.Language, 31, "The text editor has not been set in the configuration file.") + "\n" + _manager.Translator.GetTranslatedMessage(_manager.AppSettings.Language, 21, "Are you sure you want to continue?"); string translatedMessage = _manager.Translator.GetTranslatedMessage(_manager.AppSettings.Language, 8, "Attention"); if (_manager.AppSettings.GameDeletePrompt) { CustomMessageBox customMessageBox = new CustomMessageBox(Body, translatedMessage, MessageBoxDialogButtons.YesNo, MessageBoxDialogIcon.Question, true, true); customMessageBox.ShowDialog(); if (customMessageBox.Result == MessageBoxDialogResult.Yes) { try { if (_manager.DB.RemoveGame(GameID)) { LoadCategoryGames(_SelectedCategory); UpdateStatusBar(); } } catch (Exception ex) { throw; } } if (!customMessageBox.AskAgain) { _manager.AppSettings.GameDeletePrompt = false; _manager.SettingsDB.SaveSettings(_manager.AppSettings); } customMessageBox.Dispose(); } else if (_manager.DB.RemoveGame(GameID)) { LoadCategoryGames(_SelectedCategory); UpdateStatusBar(); } }
public bool MakeGamesConfiguration(TranslationsHelpers translator, Settings settings, Game game) { string body; string title; CustomMessageBox cmb; if (game != null && settings.DosboxDefaultConfFilePath != String.Empty) { if(File.Exists(settings.DosboxDefaultConfFilePath)){ body = "'" + game.Directory + "/" + Path.GetFileName(settings.DosboxDefaultConfFilePath) + "' " + translator.GetTranslatedMessage(settings.Language, 64, "already exists, do you want to overwrite it ?"); title = translator.GetTranslatedMessage(settings.Language, 8, "Attention"); cmb = new CustomMessageBox(body, title, MessageBoxDialogButtons.YesNo, MessageBoxDialogIcon.Question, false, false); if ((!File.Exists(game.Directory + "/" + Path.GetFileName(settings.DosboxDefaultConfFilePath))) || (cmb.ShowDialog() == DialogResult.Yes)) { if (Directory.Exists(game.Directory)) { File.Copy(settings.DosboxDefaultConfFilePath, game.Directory + "/" + Path.GetFileName(settings.DosboxDefaultConfFilePath), true); game.DBConfigPath = game.Directory + "/" + Path.GetFileName(settings.DosboxDefaultConfFilePath); body = translator.GetTranslatedMessage(settings.Language, 65, "The configuration file has been created correctly."); title = translator.GetTranslatedMessage(settings.Language, 66, "Success"); cmb = new CustomMessageBox(body, title, MessageBoxDialogButtons.Ok, MessageBoxDialogIcon.Information, false, false); cmb.ShowDialog(); cmb.Dispose(); return true; } else { body = translator.GetTranslatedMessage(settings.Language, 67, "The path to the selected game seems missing, please check and eventually modify the game folder location to continue."); title = translator.GetTranslatedMessage(settings.Language, 28, "Error"); cmb = new CustomMessageBox(body, title, MessageBoxDialogButtons.Ok, MessageBoxDialogIcon.Error, false, false); cmb.ShowDialog(); cmb.Dispose(); return false; } } else { return false; } } else { body = translator.GetTranslatedMessage(settings.Language, 68, "The path to the given DosBox configuration file seems missing, please check and eventually modify the DosBox configuration file location to continue."); title = translator.GetTranslatedMessage(settings.Language, 28, "Error"); cmb = new CustomMessageBox(body, title, MessageBoxDialogButtons.Ok, MessageBoxDialogIcon.Error, false, false); cmb.ShowDialog(); cmb.Dispose(); return false; } } return false; }
public List<MyAbandonGameFound> SearchGames(string GameName) { try { //Preparing URL and result holder string queryResult = string.Empty; string queryUri = string.Format(baseSearchUri, GameName); //Performing web request to retrieve the page. request = (HttpWebRequest)WebRequest.Create(queryUri); response = (HttpWebResponse)request.GetResponse(); if (response.StatusCode == HttpStatusCode.OK) { Stream receiveStream = response.GetResponseStream(); StreamReader readStream = null; readStream = new StreamReader(receiveStream, Encoding.UTF8); queryResult = WebUtility.HtmlDecode(readStream.ReadToEnd()); response.Close(); readStream.Close(); } //Scraping the response to extract the founded games List<MyAbandonGameFound> result = ParseSearchResult(queryResult); return result; } catch (Exception e) { CustomMessageBox cmb = new CustomMessageBox(e.Message, _manager.Translator.GetTranslatedMessage(_manager.AppSettings.Language, 28, "Error"), MessageBoxDialogButtons.Ok, MessageBoxDialogIcon.Error, false, false); cmb.ShowDialog(); cmb.Dispose(); return null; } }
private void OpenRecentDatabase(string dbPath, bool closePreviousConnection) { if (!File.Exists(dbPath)) { CustomMessageBox customMessageBox = new CustomMessageBox(_manager.Translator.GetTranslatedMessage(_manager.AppSettings.Language, 7, "We are not able to find the selected database inside this computer.") + "\n" + _manager.Translator.GetTranslatedMessage(_manager.AppSettings.Language, 10, "Do you want to remove it from the list?"), _manager.Translator.GetTranslatedMessage(_manager.AppSettings.Language, 8, "Attention"), MessageBoxDialogButtons.YesNo, MessageBoxDialogIcon.Question, false, false); customMessageBox.ShowDialog(); if (customMessageBox.Result == MessageBoxDialogResult.Yes) { if (_manager.SettingsDB.RemoveRecentDatabase(dbPath)) { _manager.RecentDBs.Remove(dbPath); ReloadRecentDBsMenuItems(); } } customMessageBox.Dispose(); } else { if (closePreviousConnection) _manager.DB.Disconnect(); if (!_manager.DB.Connect(dbPath)) { CustomMessageBox customMessageBox = new CustomMessageBox(_manager.Translator.GetTranslatedMessage(_manager.AppSettings.Language, 6, "It has not been possible to open the database!"), _manager.Translator.GetTranslatedMessage(_manager.AppSettings.Language, 30, "Warning"), MessageBoxDialogButtons.Ok, MessageBoxDialogIcon.Warning, false, false); customMessageBox.ShowDialog(); customMessageBox.Dispose(); } else { AddDBToRecentAndSetupUI(dbPath, false); } } }
private void RecentDatabaseItemClickHandler(object sender, EventArgs e) { string text = ((ToolStripItem)sender).Text; if (_manager.DB != null && _manager.DB.ConnectionStatus == ConnectionState.Open) { CustomMessageBox customMessageBox = new CustomMessageBox(_manager.Translator.GetTranslatedMessage(_manager.AppSettings.Language, 9, "You are already connected to another database.") + "\n" + _manager.Translator.GetTranslatedMessage(_manager.AppSettings.Language, 11, "Do you want to close the previous database and open the selected one?"), _manager.Translator.GetTranslatedMessage(_manager.AppSettings.Language, 8, "Attention"), MessageBoxDialogButtons.YesNo, MessageBoxDialogIcon.Question, false, false); customMessageBox.ShowDialog(); if (customMessageBox.Result == MessageBoxDialogResult.Yes) OpenRecentDatabase(text, true); customMessageBox.Dispose(); } else OpenRecentDatabase(text, false); }
private void CreateDatabase() { if (_manager.DB == null) { CustomMessageBox customMessageBox = new CustomMessageBox(_manager.Translator.GetTranslatedMessage(_manager.AppSettings.Language, 16, "There are problems with the database connector, this feature can't be used at the moment."), _manager.Translator.GetTranslatedMessage(_manager.AppSettings.Language, 28, "Error"), MessageBoxDialogButtons.Ok, MessageBoxDialogIcon.Error, false, false); customMessageBox.ShowDialog(); customMessageBox.Dispose(); } else { if (!CheckConnection()) return; saveFileDialog.Title = _manager.Translator.GetTranslatedMessage(_manager.AppSettings.Language, 17, "Create a new DOSBox Manager database"); saveFileDialog.FileName = ""; saveFileDialog.Filter = _manager.Translator.GetTranslatedMessage(_manager.AppSettings.Language, 15, "DOSBox Manager Database (*.dbm)|*.dbm"); if (saveFileDialog.ShowDialog() == DialogResult.OK) { if (!_manager.DB.CreateDB(saveFileDialog.FileName)) { CustomMessageBox customMessageBox = new CustomMessageBox(_manager.Translator.GetTranslatedMessage(_manager.AppSettings.Language, 18, "It has not been possible to create the database!"), _manager.Translator.GetTranslatedMessage(_manager.AppSettings.Language, 28, "Error"), MessageBoxDialogButtons.Ok, MessageBoxDialogIcon.Error, false, false); customMessageBox.ShowDialog(); customMessageBox.Dispose(); } else { AddDBToRecentAndSetupUI(saveFileDialog.FileName, true); } } } }
private void OpenDatabase() { if (!CheckConnection()) return; openFileDialog.Title = _manager.Translator.GetTranslatedMessage(_manager.AppSettings.Language, 14, "Open an existing DOSBox Manager database"); openFileDialog.FileName = ""; openFileDialog.Filter = _manager.Translator.GetTranslatedMessage(_manager.AppSettings.Language, 15, "DOSBox Manager Database (*.dbm)|*.dbm"); if (openFileDialog.ShowDialog() != DialogResult.OK) return; if (!_manager.DB.Connect(openFileDialog.FileName)) { CustomMessageBox customMessageBox = new CustomMessageBox(_manager.Translator.GetTranslatedMessage(_manager.AppSettings.Language, 6, "It has not been possible to open the database!"), _manager.Translator.GetTranslatedMessage(_manager.AppSettings.Language, 30, "Warning"), MessageBoxDialogButtons.Ok, MessageBoxDialogIcon.Warning, false, false); customMessageBox.ShowDialog(); customMessageBox.Dispose(); } else { AddDBToRecentAndSetupUI(openFileDialog.FileName, true); } }
private UninstallProgressWindow() { InitializeComponent(); Text += " - Bulk Crap Uninstaller"; Opacity = 0; Icon = Resources.Icon_Logo; toolStrip1.Renderer = new ToolStripProfessionalRenderer(new StandardSystemColorTable()); // Shutdown blocking not available below Windows Vista if (Environment.OSVersion.Version >= new Version(6, 0)) { _settings.Subscribe((sender, args) => { if (args.NewValue) { SleepControls.PreventSleepOrShutdown(Handle, "Bulk uninstallation is in progress."); } else { SleepControls.AllowSleepOrShutdown(Handle); } }, settings => settings.UninstallPreventShutdown, this); } _settings.SendUpdates(this); FormClosing += (sender, args) => { if (args.CloseReason == CloseReason.WindowsShutDown && _settings.Settings.UninstallPreventShutdown) { args.Cancel = true; } }; FormClosed += (o, eventArgs) => { _settings.RemoveHandlers(this); SleepControls.AllowSleepOrShutdown(Handle); _walkAwayBox?.Dispose(); }; olvColumnName.AspectGetter = BulkUninstallTask.DisplayNameAspectGetter; olvColumnStatus.AspectGetter = BulkUninstallTask.StatusAspectGetter; olvColumnIsSilent.AspectGetter = BulkUninstallTask.IsSilentAspectGetter; olvColumnId.AspectName = nameof(BulkUninstallEntry.Id); olvColumnStatus.GroupKeyGetter = rowObject => (rowObject as BulkUninstallEntry)?.CurrentStatus; olvColumnName.GroupKeyGetter = rowObject => (rowObject as BulkUninstallEntry)?.UninstallerEntry.DisplayName.SafeNormalize().FirstOrDefault(); olvColumnId.GroupKeyGetter = rowObject => (rowObject as BulkUninstallEntry)?.Id / 10; objectListView1.PrimarySortColumn = olvColumnStatus; objectListView1.SecondarySortColumn = olvColumnId; forceUpdateTimer.Tick += (o, args) => { if (_currentTargetStatus != null && !_currentTargetStatus.Finished) { currentTargetStatus_OnCurrentTaskChanged(o, args); } else { forceUpdateTimer.Stop(); } }; // Handle sleeping after task finishes sleepTimer.Interval = 1000; sleepTimer.Tick += (sender, args) => { if (_currentTargetStatus.Finished && checkBoxFinishSleep.Checked) { _sleepTimePassed++; const int sleepDelay = 30; label1.Text = Localisable.UninstallProgressWindow_TaskDone + "\n" + string.Format(Localisable.UninstallProgressWindow_StatusPuttingToSleepInSeconds, sleepDelay - _sleepTimePassed); if (_sleepTimePassed > sleepDelay) { checkBoxFinishSleep.Checked = false; checkBoxFinishSleep.Enabled = false; SleepControls.AllowSleepOrShutdown(Handle); SleepControls.PutToSleep(); } } else { _sleepTimePassed = 0; if (_currentTargetStatus.Finished) { label1.Text = Localisable.UninstallProgressWindow_TaskDone; } } }; }