private void CancelBtn_Click(object sender, RoutedEventArgs e) { if (isFromAdd) { AddGame.Close(); } else { EditGame.Close(); } }
private void NextBtn_Click(object sender, RoutedEventArgs e) { try { if (isFromAdd) { Definitions.Games.Add(new() { Name = AddGame.GameName, // Set value Version = AddGame.GameVersion, // Set value Description = DescriptionTextBox.Text, // Set value FileLocation = AddGame.GameLocation, // Set value IconFileLocation = AddGame.GameIconLocation, // Set value IsFavorite = false, // Set value RAWGID = RAWGID, // Set value LastTimePlayed = 0, // Set value TotalTimePlayed = 0, // Set value ProcessName = "", // Set value Platforms = (Platforms.Count == 0) ? new List <SDK.RAWG.Platform> { Definitions.DefaultPlatform } : Platforms, // Get platforms Stores = Stores, AlwaysCheckIfRunning = false, IsUWP = AddGame.IsUWP, IsSteam = AddGame.IsSteam }); GameSaver.Save(Definitions.Games); // Save Global.ReloadAllPages(); // Refresh UI AddGame.Close(); } else { GameCard.GameInfo.RAWGID = RAWGID; // Set GameCard.GameInfo.Description = DescriptionTextBox.Text; // Set GameCard.GameInfo.Platforms = Platforms; // Set GameCard.GameInfo.Stores = Stores; // Set Definitions.Games[Definitions.Games.IndexOf(old)] = GameCard.GameInfo; // Update GameSaver.Save(Definitions.Games); // Save Global.ReloadAllPages(); // Refresh UI EditGame.Close(); } } catch (Exception ex) { MessageBox.Show(ex.Message, Properties.Resources.MainWindowTitle, MessageBoxButton.OK, MessageBoxImage.Error); } }
private void ConvertSteamBtn_Click(object sender, RoutedEventArgs e) { if (ConvertSteamPanel.Visibility == Visibility.Collapsed) { ConvertSteamBtn.Content = Properties.Resources.ConvertToSteam; // Set new text of the button ConvertSteamPanel.Visibility = Visibility.Visible; // Show the panel } else { if (string.IsNullOrEmpty(SteamAppIdTextBox.Text)) { MessageBox.Show(Properties.Resources.GameNeedsName, Properties.Resources.MainWindowTitle, MessageBoxButton.OK, MessageBoxImage.Exclamation); // Show message return; } // Ask a confirmation to the user if (MessageBox.Show(Properties.Resources.ConvertToSteamMsg, Properties.Resources.MainWindowTitle, MessageBoxButton.YesNoCancel, MessageBoxImage.Warning) == MessageBoxResult.Yes) { GameCard.GameInfo.IsSteam = true; // Convert to steam game GameCard.GameInfo.FileLocation = $"steam://rungameid/{SteamAppIdTextBox.Text}"; GameCard.GameInfo.ProcessName = !string.IsNullOrEmpty(GameProcessTextBox.Text) ? GameProcessTextBox.Text : GameCard.GameInfo.ProcessName; // Save other changes GameCard.GameInfo.RAWGID = RAWGID; // Set GameCard.GameInfo.Description = DescriptionTextBox.Text; // Set GameCard.GameInfo.Platforms = Platforms; // Set GameCard.GameInfo.Stores = Stores; // Set Definitions.Games[Definitions.Games.IndexOf(old)] = GameCard.GameInfo; // Update GameSaver.Save(Definitions.Games); // Save Global.ReloadAllPages(); // Refresh UI EditGame.Close(); } } }