private void editColorsButton_Click(object sender, EventArgs e) { var wrapper = this.selectedGraph.graphWrapper as ColouredPetriGraphWrapper; var f = new ColorsEditForm(wrapper.ColorsDescription, wrapper.VariablesDescription, wrapper.FunctionsDescription); f.ShowDialog(); if (f.Succesful) { wrapper.ColorsDescription = new List<Tuple<string, string, string>>(f.ColorsDescriptions); wrapper.VariablesDescription = new List<Tuple<string, string>>(f.VarsDescriptions); wrapper.FunctionsDescription = new List<string>(f.FunctionsDescriptions); var cGraph = wrapper.Graph as ColouredPetriGraph; cGraph.Colors.ClearColors(); cGraph.Colors.ClearFunctions(); Function.ResetMathFunctions(); foreach (var color in f.Colors) { cGraph.Colors.AddColorSet(color); } foreach (var var in f.Colors.ColorVariables) { cGraph.Colors.AddVariable(var.Name, var.ColorSet.Name); } foreach (var func in f.Colors.FunctionsDescription) { cGraph.Colors.AddFunction(func); } this.Refresh(); } }
private void colorsEditButton_Click(object sender, EventArgs e) { var f = new ColorsEditForm(this.wrapper.ColorsDescription, this.wrapper.VariablesDescription, this.wrapper.FunctionsDescription); f.ShowDialog(); if (f.Succesful) { this._isModified = true; this.wrapper.ColorsDescription = new List<Tuple<string, string, string>>(f.ColorsDescriptions); this.wrapper.VariablesDescription = new List<Tuple<string, string>>(f.VarsDescriptions); this.wrapper.FunctionsDescription = new List<string>(f.FunctionsDescriptions); var cGraph = this.wrapper.Graph as ColouredPetriGraph; cGraph.Colors.ClearColors(); cGraph.Colors.ClearFunctions(); Function.ResetMathFunctions(); foreach (var color in f.Colors) { cGraph.Colors.AddColorSet(color); } foreach (var var in f.Colors.ColorVariables) { cGraph.Colors.AddVariable(var.Name, var.ColorSet.Name); } foreach (var func in f.Colors.FunctionsDescription) { cGraph.Colors.AddFunction(func); } } }