private void Btn_Add_Click(object sender, RoutedEventArgs e) { CreateIItemWindow ciiw = new CreateIItemWindow(); ciiw.SetDataContext(new InventoryItem() { ImageList = this.Images }); if (ciiw.ShowDialog() ?? false) { this.Items.Add((InventoryItem)ciiw.DataContext); AppState.Current.State.Inventory.WeightCurrent += ((InventoryItem)ciiw.DataContext).Weight * ((InventoryItem)ciiw.DataContext).Amount * ((InventoryItem)ciiw.DataContext).ItemWeightLogicMul; } }
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; } } }
public void Execute(object parameter) { ItemTemplate it = (ItemTemplate)parameter; InventoryItem ii = new InventoryItem(it) { ImageList = AppState.Current.TInventory.Images }; CreateIItemWindow cciw = new CreateIItemWindow(); cciw.SetDataContext(ii); if (cciw.ShowDialog() ?? false) { AppState.Current.TInventory.Items.Add((InventoryItem)cciw.DataContext); } }