private void Btn_Edit_Click(object sender, RoutedEventArgs e) { if (this.Inventory.SelectedItem is InventoryItem ii) { CreateIItemWindow ciiw = new CreateIItemWindow(); ciiw.SetDataContext(ii.Copy()); if (ciiw.ShowDialog() ?? false) { this.Items[this.Items.IndexOf(ii)] = (InventoryItem)ciiw.DataContext; float weightDiff = (((InventoryItem)ciiw.DataContext).Weight * ((InventoryItem)ciiw.DataContext).Amount * ((InventoryItem)ciiw.DataContext).ItemWeightLogicMul) - (ii.Weight * ii.Amount * ii.ItemWeightLogicMul); AppState.Current.State.Inventory.WeightCurrent += weightDiff; } } }
private void Btn_Add_Click(object sender, RoutedEventArgs e) { CreateIItemWindow ciiw = new CreateIItemWindow(); ciiw.SetDataContext(new InventoryItem() { ImageList = this.Images }); if (ciiw.ShowDialog() ?? false) { ((InventoryItem)ciiw.DataContext).ContainerID = this.OwnerItem.ObjectID; this.Items.Add((InventoryItem)ciiw.DataContext); AppState.Current.State.Inventory.WeightCurrent += ((InventoryItem)ciiw.DataContext).Weight * ((InventoryItem)ciiw.DataContext).Amount * ((InventoryItem)ciiw.DataContext).ItemWeightLogicMul; } }