/// <summary> /// Updates an item in the workshop /// </summary> public void UpdateItem() { if (workshopItemsListBox.SelectedIndex > 0) { // get updated item ItemInformationForm form = new ItemInformationForm(records[workshopItemsListBox.SelectedIndex - 1]); form.ShowDialog(); Record record = form.Record; // update item and GUI workshopItemsListBox.Items[workshopItemsListBox.SelectedIndex] = record; records[workshopItemsListBox.SelectedIndex - 1] = record; } }
/// <summary> /// Inserts a new Record to the workshop /// </summary> public void InsertItem() { // get record information from ItemInformationForm ItemInformationForm form = new ItemInformationForm(); form.ShowDialog(); Record record = form.Record; if (record != null) { // add to list and update GUI workshopItemsListBox.Items.Add(record); records.Add(record); numberOfItemsLabel.Text = $"There are {workshopItemsListBox.Items.Count - 1} items in this workshop"; } }