private void container_down(object sender, RoutedEventArgs e) { if ((this.selection is null) || (this.selection.is_category) || (!this.state.items.ContainsKey(this.selection.name))) { return; } ElementReference <ItemSpec> item_ref = this.state.items[this.selection.name]; if (item_ref.ref_count > 0) { return; } int idx = this.container_list.SelectedIndex; if ((idx < 0) || (idx >= this.containers.Count - 1)) { return; } ContainerSpec container = this.containers[idx]; this.containers[idx] = this.containers[idx + 1]; this.containers[idx + 1] = container; ItemSpecContainerRow row = this.container_rows[idx]; this.container_rows[idx] = this.container_rows[idx + 1]; this.container_rows[idx + 1] = row; this.container_list.Items.Refresh(); this.set_dirty(); }
private void container_edit(object sender, RoutedEventArgs e) { if ((this.selection is null) || (this.selection.is_category) || (!this.state.items.ContainsKey(this.selection.name))) { return; } ElementReference <ItemSpec> item_ref = this.state.items[this.selection.name]; if (item_ref.ref_count > 0) { return; } int idx = this.container_list.SelectedIndex; if ((idx < 0) || (idx >= this.containers.Count)) { return; } ContainerSpec container = this.containers[idx]; QueryPrompt[] prompts = new QueryPrompt[] { new QueryPrompt("Name:", QueryType.STRING, container.name), new QueryPrompt("Weight Factor:", QueryType.FLOAT, (double)(container.weight_factor), step: 0.125), new QueryPrompt("Weight Capacity:", QueryType.FLOAT, (double)(container.weight_capacity ?? 0)), }; object[] results = SimpleDialog.askCompound("Edit Container", prompts, this); if (results is null) { return; } string name = results[0] as string; double?weight_factor = results[1] as double?, weight_capacity = results[2] as double?; if ((name is null) || (weight_factor is null)) { return; } if (weight_capacity == 0) { weight_capacity = null; } container.name = name; container.weight_factor = (decimal)weight_factor; container.weight_capacity = (decimal?)weight_capacity; ItemSpecContainerRow row = this.container_rows[idx]; row._name = name; row._weight_factor = container.weight_factor.ToString(); row._weight_capacity = container.weight_capacity.ToString(); this.container_list.Items.Refresh(); this.fix_listview_column_widths(this.container_list); this.set_dirty(); }