private void addVariable_Click(object sender, EventArgs e) { var addVariableForm = new EditVariableForm(); addVariableForm.OnSaveVariable += (variableName, variableLingName, variableIsResult, terms) => { if (_variables.Any(x => x.Name == variableName)) { return(false); } _variables.Add(new FuzzyVariable(variableName, variableLingName, terms, variableIsResult)); return(true); }; addVariableForm.ShowDialog(); RefreshVariablesListView(); }
private void editVariable_Click(object sender, EventArgs e) { var variableViewItem = variablesListView.SelectedItems[0]; var variable = _variables[variableViewItem.Index]; var editVariableForm = new EditVariableForm(variable); editVariableForm.OnSaveVariable += (variableName, variableLingName, variableIsResult, terms) => { if (terms.Count == 0) { return(false); } foreach (var term in terms) { var localTerm = variable.Terms.FirstOrDefault(x => x.Name == term.Name); if (!localTerm.AccessoryFunc.IsEqual(term.AccessoryFunc)) { localTerm.AccessoryFunc = term.AccessoryFunc.CopyFunc(); } } if (variable.Name != variableName) { variable.Name = variableName; } if (variable.LingName != variableLingName) { variable.LingName = variableLingName; } if (variable.IsResult != variableIsResult) { variable.IsResult = variableIsResult; } return(true); }; editVariableForm.ShowDialog(); RefreshVariablesListView(); }