private async void btEdit_Click(object sender, EventArgs e) { var(res, form) = LabelEditorForm.GoEdit(data); if (res == DialogResult.OK) { await _controller.UpdateLabel(form.Result); RaiseOnDataDirty(); } }
private async void btEdit_Click(object sender, EventArgs e) { var name = checkedListBoxRules.SelectedItem?.ToString(); if (name == null) { MessageBox.Show("Select item first!"); return; } var item = _state.Labels.First(t => t.Name == name);//_state.Rules.FirstOrDefault(t => t.Name == name); //check? var f = new RuleEditorForm(item); if (f.ShowDialog() == DialogResult.OK) { var label = f.Result; await _controller.UpdateLabel(label); FillTheList(); //var newName = f.Result.Name; //if (newName == name) //{ // //name not changed // //only replace // //_state.Rules[name] = f.Result; // _state.Labels.Remove(item); // _state.Labels.Add(f.Result); // return; //} //if (_state.Rules.ContainsKey(newName)) //{ // MessageBox.Show("Item with such name already exist, info is lost"); //} //else //{ // _state.Rules.Remove(name); // _state.Rules[newName] = f.Result; // var index = checkedListBoxRules.Items.IndexOf(name); // checkedListBoxRules.Items.Remove(name); // checkedListBoxRules.Items.Insert(index, newName); //} } }