Exemplo n.º 1
0
        private void DeleteItemButton_Click(object sender, RoutedEventArgs e)
        {
            Button button = (Button)sender;
            UserInventoryItemViewModel item = (UserInventoryItemViewModel)button.DataContext;

            this.items.Remove(item);
        }
Exemplo n.º 2
0
        private void EditItemButton_Click(object sender, RoutedEventArgs e)
        {
            Button button = (Button)sender;
            UserInventoryItemViewModel item = (UserInventoryItemViewModel)button.DataContext;

            this.ItemNameTextBox.Text       = item.Name;
            this.ItemMaxAmountTextBox.Text  = item.HasMaxAmount ? item.MaxAmount.ToString() : string.Empty;
            this.ItemBuyAmountTextBox.Text  = item.BuyAmountString;
            this.ItemSellAmountTextBox.Text = item.SellAmountString;
            this.AddItemButton.Content      = "Update";
        }
Exemplo n.º 3
0
        private async void AddItemButton_Click(object sender, RoutedEventArgs e)
        {
            await this.RunAsyncOperation(async() =>
            {
                if (string.IsNullOrEmpty(this.ItemNameTextBox.Text))
                {
                    await MessageBoxHelper.ShowMessageDialog("You must specify a name for the item");
                    return;
                }

                int maxAmount = -1;
                if (!string.IsNullOrEmpty(this.ItemMaxAmountTextBox.Text) && (!int.TryParse(this.ItemMaxAmountTextBox.Text, out maxAmount) || maxAmount <= 0))
                {
                    await MessageBoxHelper.ShowMessageDialog("The item max amount must be either blank or a number greater than 0");
                    return;
                }

                int buyAmount = -1;
                if (!string.IsNullOrEmpty(this.ItemBuyAmountTextBox.Text) && (!int.TryParse(this.ItemBuyAmountTextBox.Text, out buyAmount) || buyAmount < 0))
                {
                    await MessageBoxHelper.ShowMessageDialog("The item buy amount must be either blank or a number greater than 0");
                    return;
                }

                int sellAmount = -1;
                if (!string.IsNullOrEmpty(this.ItemSellAmountTextBox.Text) && (!int.TryParse(this.ItemSellAmountTextBox.Text, out sellAmount) || sellAmount < 0))
                {
                    await MessageBoxHelper.ShowMessageDialog("The item sell amount must be either blank or a number greater than 0");
                    return;
                }

                UserInventoryItemViewModel existingItem = this.items.FirstOrDefault(i => i.Name.Equals(this.ItemNameTextBox.Text, StringComparison.CurrentCultureIgnoreCase));
                if (existingItem != null)
                {
                    this.items.Remove(existingItem);
                }

                UserInventoryItemViewModel item = new UserInventoryItemViewModel(this.ItemNameTextBox.Text, maxAmount: maxAmount, buyAmount: buyAmount, sellAmount: sellAmount);
                this.items.Add(item);

                this.ItemNameTextBox.Text       = string.Empty;
                this.ItemMaxAmountTextBox.Text  = string.Empty;
                this.ItemBuyAmountTextBox.Text  = string.Empty;
                this.ItemSellAmountTextBox.Text = string.Empty;
                this.AddItemButton.Content      = "Add Item";
            });
        }
Exemplo n.º 4
0
 public UserCurrencyIndividualEditorControl(UserInventoryItemViewModel inventoryItem, UserInventoryDataViewModel inventoryData)
     : this()
 {
     this.inventoryItem = inventoryItem;
     this.inventoryData = inventoryData;
 }
Exemplo n.º 5
0
 public InventoryRequirementViewModel(UserInventoryViewModel inventory, UserInventoryItemViewModel item, int amount)
 {
     this.InventoryID = inventory.ID;
     this.ItemName    = item.Name;
     this.Amount      = amount;
 }