private void DeleteGenre_OnClick(object sender, RoutedEventArgs e) { //Check Genre file for the name of the genre to remove string genreGuid = ((Button)sender).Tag.ToString(); var genretext = File.ReadAllLines("./Resources/GenreList.txt", Encoding.UTF8); for (int i = 0; i < genretext.Length; i++) { if (genretext[i].Contains($"{genreGuid}")) { try { Console.WriteLine(genretext[i]); string[] column = genretext[i].Split('|'); DeletedGenre = column[0]; } catch (Exception ex) { Console.WriteLine(ex.ToString()); } } } //Check gameslist, and remove that genre from any listings if (!File.Exists("./Resources/GamesList.txt")) { } else { var gametext = File.ReadAllLines("./Resources/GamesList.txt", Encoding.UTF8); for (int i2 = 0; i2 < gametext.Length; i2++) { if (gametext[i2].Contains(DeletedGenre)) { try { Console.WriteLine(gametext[i2]); string[] column = gametext[i2].Split('|'); string genretoedit = column[1]; genretoedit = genretoedit.Replace(DeletedGenre + ";", ""); string gametoeditguid = column[7]; string newGenre = genretoedit.Trim(); string NewGameInfo = column[0] + "|" + newGenre + "|" + column[2] + "|" + column[3] + "|" + column[4] + "|" + column[5] + "|" + column[6] + "|" + Guid.NewGuid(); Console.WriteLine(NewGameInfo); ModifyFile.RemoveGameFromFile(gametoeditguid); TextWriter tw = new StreamWriter(@"./Resources/GamesList.txt", true); tw.WriteLine(NewGameInfo); tw.Close(); } catch (Exception ex2) { Console.WriteLine(ex2.ToString()); } } } } ModifyFile.RemoveGenreFromFile(((Button)sender).Tag.ToString()); MainWindow.RefreshGames(); }
private void DeleteGame_OnClick(object sender, RoutedEventArgs e) { ModifyFile.RemoveGameFromFile(((Button)sender).Tag); try { ModifyFile.DeleteGameImages(((Button)sender).CommandParameter.ToString()); } catch (Exception exc) { Trace.WriteLine("Failed to delete images for game: " + exc); } string removeguid = ((Button)sender).Tag.ToString(); foreach (var item in ListViewModel.ListViewOC.ToList()) { if (removeguid == item.Guid) { Trace.WriteLine(DateTime.Now + ": Removed Game: " + item.Title); ListViewModel.ListViewOC.Remove(item); } } }
private void EditGame_OnClick(object sender, RoutedEventArgs e) { ModifyFile.EditGameInfile(((Button)sender).Tag); }
private void DeleteGame_OnClick(object sender, RoutedEventArgs e) { ModifyFile.RemoveGameFromFile(((Button)sender).Tag); MainWindow.RefreshGames(); }
private void EditGame_OnClick(object sender, RoutedEventArgs e) { ModifyFile.EditGameInfile(((Button)sender).Tag); MainWindow.RefreshGames(); }
private void DeleteGame_OnClick(object sender, RoutedEventArgs e) { ModifyFile.RemoveGameFromFile(((Button)sender).Tag); ModifyFile.DeleteGameImages(((Button)sender).CommandParameter.ToString()); MainWindow.RefreshGames(); }
private void EditGame_OnClick(object sender, RoutedEventArgs e) { //Need to change shortcut name in this bit string ngl = EditLink.Text; if (!ngl.Contains("http") && (ngl != "")) { UriBuilder uriBuilder = new UriBuilder { Scheme = "http", Host = EditLink.Text }; Uri uri = uriBuilder.Uri; EditLink.Text = uri.ToString(); } if (System.IO.File.Exists("./Resources/GamesList.txt")) { string[] allgames = System.IO.File.ReadAllLines("./Resources/GamesList.txt"); string[] columns = new string[0]; int numofgames = 0; foreach (var item in allgames) { columns = allgames[numofgames].Split('|'); string gametitle = columns[0]; gametitle = columns[0]; gametitle = gametitle.Trim().ToLower(); alltitles += " | " + gametitle + " | "; numofgames++; } try { if (!alltitles.Contains(NewTitle + " |")) { RenameFiles(OldTitle, NewTitle); try { TextWriter tsw = new StreamWriter(@"./Resources/GamesList.txt", true); tsw.WriteLine(EditTitle.Text + "|" + EditGenre.Text + "|" + EditPath.Text + "|" + EditLink.Text + "|" + EditIcon.Text + "|" + EditPoster.Text + "|" + EditBanner.Text + "|" + Guid.NewGuid()); tsw.Close(); } catch (Exception ex) { Trace.WriteLine(DateTime.Now + ": EditGame: " + ex.Message); } clearFields(); ClearGenreBoxes(); alltitles = null; OldTitle = null; ModifyFile.RemoveGameFromFile(guid); ((MainWindow)Application.Current.MainWindow)?.RefreshGames(); ((MainWindow)Application.Current.MainWindow).isDialogOpen = false; EditGameDialog.IsOpen = false; } else { try { TextWriter tsw = new StreamWriter(@"./Resources/GamesList.txt", true); tsw.WriteLine(EditTitle.Text + "|" + EditGenre.Text + "|" + EditPath.Text + "|" + EditLink.Text + "|" + EditIcon.Text + "|" + EditPoster.Text + "|" + EditBanner.Text + "|" + Guid.NewGuid()); tsw.Close(); } catch (Exception ex) { Trace.WriteLine(DateTime.Now + ": EditGame: " + ex.Message); } clearFields(); ClearGenreBoxes(); alltitles = null; OldTitle = null; ModifyFile.RemoveGameFromFile(guid); ((MainWindow)Application.Current.MainWindow)?.RefreshGames(); ((MainWindow)Application.Current.MainWindow).isDialogOpen = false; EditGameDialog.IsOpen = false; } } catch (Exception ex) { Trace.WriteLine(DateTime.Now + ": EditGame2: " + ex); } } }
private void EditGame_OnClick(object sender, RoutedEventArgs e) { //This part repairs the link so it launches properly string ngl = EditLink.Text; if (!ngl.Contains("http") && (ngl != "")) { UriBuilder uriBuilder = new UriBuilder(); uriBuilder.Scheme = "http"; uriBuilder.Host = EditLink.Text; Uri uri = uriBuilder.Uri; EditLink.Text = uri.ToString(); } if (System.IO.File.Exists("./Resources/GamesList.txt")) { string[] allgames = System.IO.File.ReadAllLines("./Resources/GamesList.txt"); string[] columns = new string[0]; int numofgames = 0; foreach (var item in allgames) { columns = allgames[numofgames].Split('|'); string gametitle = columns[0]; gametitle = columns[0]; gametitle = gametitle.Trim().ToLower(); alltitles += " | " + gametitle + " | "; numofgames++; } if (alltitles.Contains(" | " + NewTitle.Trim().ToLower() + " | ")) { MessageBox.Show("A game with this title already exists. If you need to fix capitalisation, add a character, save, then edit again (Sorry)"); EditTitle.Text = OldTitle; } else { RenameFiles(OldTitle, NewTitle); try { TextWriter tsw = new StreamWriter(@"./Resources/GamesList.txt", true); tsw.WriteLine(EditTitle.Text + "|" + EditGenre.Text + "|" + EditPath.Text + "|" + EditLink.Text + "|" + EditIcon.Text + "|" + EditPoster.Text + "|" + EditBanner.Text + "|" + Guid.NewGuid()); tsw.Close(); } catch (Exception ex) { Console.WriteLine("Exception: " + ex.Message); } clearFields(); ClearGenreBoxes(); alltitles = null; OldTitle = null; ModifyFile.RemoveGameFromFile(guid); ((MainWindow)Application.Current.MainWindow)?.RefreshGames(); EditGameDialog.IsOpen = false; } } }