/// <summary> /// Handles the Click event of the btnAdd control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> void btnAdd_Click(object sender, EventArgs e) { // Validate if (!_selectedItem.HasValue) { MessageBox.Show("You must select an item to add first."); return; } if (RequireDistinct) { if (lstItems.Items.Cast <CharacterTemplateEquippedItem>().Any(x => _selectedItem.HasValue && x.ID == _selectedItem.Value)) { MessageBox.Show("That item is already in the list."); _selectedItem = null; return; } } // Add var newItem = new CharacterTemplateEquippedItem(_selectedItem.Value, ItemChance.FromPercent(1.0f)); lstItems.Items.Add(newItem); if (RequireDistinct) { _selectedItem = null; txtItem.Text = string.Empty; } // Select the new item lstItems.SelectedItem = newItem; }
/// <summary> /// Initializes a new instance of the <see cref="CharacterTemplateInventoryItem"/> struct. /// </summary> /// <param name="id">The <see cref="ItemTemplateID"/>.</param> /// <param name="chance">The chance of the item being in the inventory.</param> /// <param name="min">The minimum amount of items to be created.</param> /// <param name="max">The maximum amount of items to be created.</param> public CharacterTemplateInventoryItem(ItemTemplateID id, ItemChance chance, ushort min, ushort max) { _id = id; _chance = chance; _min = min; _max = max; }
/// <summary> /// Initializes a new instance of the <see cref="CharacterTemplateEquippedTable"/> class. /// </summary> /// <param name="chance">The initial value for the corresponding property.</param> /// <param name="characterTemplateID">The initial value for the corresponding property.</param> /// <param name="iD">The initial value for the corresponding property.</param> /// <param name="itemTemplateID">The initial value for the corresponding property.</param> public CharacterTemplateEquippedTable(ItemChance @chance, CharacterTemplateID @characterTemplateID, Int32 @iD, ItemTemplateID @itemTemplateID) { Chance = @chance; CharacterTemplateID = @characterTemplateID; ID = @iD; ItemTemplateID = @itemTemplateID; }
/// <summary> /// Initializes a new instance of the <see cref="CharacterTemplateInventoryTable"/> class. /// </summary> /// <param name="chance">The initial value for the corresponding property.</param> /// <param name="characterTemplateID">The initial value for the corresponding property.</param> /// <param name="iD">The initial value for the corresponding property.</param> /// <param name="itemTemplateID">The initial value for the corresponding property.</param> /// <param name="max">The initial value for the corresponding property.</param> /// <param name="min">The initial value for the corresponding property.</param> public CharacterTemplateInventoryTable(ItemChance @chance, CharacterTemplateID @characterTemplateID, Int32 @iD, ItemTemplateID @itemTemplateID, Byte @max, Byte @min) { Chance = @chance; CharacterTemplateID = @characterTemplateID; ID = @iD; ItemTemplateID = @itemTemplateID; Max = @max; Min = @min; }
public CharacterTemplateInventoryItem(IItemTemplateTable itemTemplate, byte min, byte max, ItemChance chance) { if (min > max) { var tmp = min; min = max; max = tmp; Debug.Fail("min was less than max. Swapped to fix the problem, but could indicate a problem elsewhere."); } ItemTemplate = itemTemplate; Min = min; Max = max; Chance = chance; }
/// <summary> /// Handles the Leave event of the txtAmount control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> void txtChance_Leave(object sender, EventArgs e) { if (lstItems.SelectedItem == null) { return; } // Get the selected item if (!(lstItems.SelectedItem is CharacterTemplateEquippedItem)) { Debug.Fail("Was expecting type " + typeof(CharacterTemplateEquippedItem)); return; } var sel = (CharacterTemplateEquippedItem)lstItems.SelectedItem; // Parse the new amount float chancePct; if (!float.TryParse(txtChance.Text, out chancePct)) { return; } ItemChance newItemChance = ItemChance.FromPercent(chancePct / 100f); // Check that the amount changed if (sel.Chance == newItemChance) { return; } // Set the new amount sel.Chance = newItemChance; // Force the text to refresh lstItems.Items[lstItems.SelectedIndex] = sel; }
/// <summary> /// Initializes a new instance of the <see cref="CharacterTemplateEquippedItem"/> struct. /// </summary> /// <param name="id">The <see cref="ItemTemplateID"/>.</param> /// <param name="chance">The chance of the item being equipped.</param> public CharacterTemplateEquippedItem(ItemTemplateID id, ItemChance chance) { _id = id; _chance = chance; }
public CharacterTemplateEquipmentItem(IItemTemplateTable itemTemplate, ItemChance chance) { ItemTemplate = itemTemplate; Chance = chance; }