private void AddNewObjectButton_Click(object sender, RoutedEventArgs e) { Save(); var nextId = (GameAssets.ShopOffer.Max(x => x.Id as int?) ?? 0) + 1; _dataContext = new VendorPattern { Id = nextId }; ContentSelectionBox.SelectedIndex = -1; RefreshStaticValuesPanel(); DeleteObjectButton.Visibility = Visibility.Visible; }
private void ContentSelectionBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { var selectedValue = (e.Source as ComboBox)?.SelectedValue?.ToString(); if (selectedValue is null) { return; } var selectedId = int.Parse(selectedValue); if (_dataContext is not null) { Save(); } _dataContext = GameAssets.ShopOffer.FirstOrDefault(x => x.Id == selectedId); ContentSelectionBox.SelectedValue = _dataContext.Id.ToString(); RefreshStaticValuesPanel(); DeleteObjectButton.Visibility = Visibility.Visible; }
private void DeleteObjectButton_Click(object sender, RoutedEventArgs e) { Save(); var objectToDelete = GameAssets.ShopOffer.FirstOrDefault(x => x.Id == int.Parse((_controls["IdBox"] as TextBox).Text)); var result = MessageBox.Show($"Are you sure you want to delete pattern of Id: {objectToDelete.Id}? This action will close ContentManager, check Logs directory (for missing references after deleting).", "Are you sure?", MessageBoxButton.YesNo, MessageBoxImage.Question); if (result == MessageBoxResult.No) { return; } GameAssets.ShopOffer.Remove(objectToDelete); PopulateContentSelectionBox(); ContentSelectionBox.SelectedIndex = -1; _currentPanel.Children.Clear(); DeleteObjectButton.Visibility = Visibility.Hidden; _dataContext = null; Application.Current.MainWindow.Close(); }