private void SaveRuleToList(string text) { if (text == null) { return; } Rule rule = new Rule(); Graph leftSide = gViewerLeft.Graph; Graph rightSide = gViewerRight.Graph; rule.SetRule(text, leftSide, rightSide); try { rule.IsValid(); } catch (Exception e) { ShowMessage(e.Message); return; } //Overwrite rule Rule listRule = _rules.Find(r => r.Name == text); if (listRule != null) { _rules.Remove(listRule); } _rules.Add(rule.CloneRule()); SetRuleFocus(rule); RefreshListBox(lBRules, _rules); }
private void SetBlankRule() { Rule r = new Rule(); r.SetRule("", new Graph(), new Graph()); SetViewerRule(r); }
public void InterpreteScript() { _parser.ParseFile(); CheckConfig(_parser.Config); if (_parser.FixedProduction) { CheckProduction( _parser.Rules.Select(r => r.Name).ToList(), _parser.Production); } List <Rule> rules = _parser.Rules.ConvertAll((input => { Rule r = new Rule(); r.SetRule(input.Name, input.LeftSide, input.RightSide); return(r); })); foreach (var rule in rules) { try { rule.IsValid(); } catch (Exception e) { throw; } } _graphEditor.SetRuleList(rules); foreach (Node node in _parser.StartGraph.Nodes) { node.Label.Text = node.NodeSymbol; } _graphEditor.SetProductionGraph(_parser.StartGraph); if (_parser.FixedProduction) { foreach (string productionName in _parser.Production) { if (_graphEditor.ApplyRule( rules.FirstOrDefault(r => r.Name == productionName))) { continue; } _graphEditor.ShowMessage("Rules provided in specified order cannot be applied"); break; } } else { _graphEditor.MinNodes = MinimumNodes; _graphEditor.MatchMode = MatchMode; if (_graphEditor.MinNodes > 0) { _graphEditor.GenerateRanomGraph(); } } _graphEditor.RefreshProductionView(); }