Пример #1
0
        private void BuildAllowedChildSymbolsTree()
        {
            if (Symbol == null)
            {
                symbolicExpressionTreeChart.Tree = null;
                return;
            }

            var tree = new SymbolicExpressionTree(new SymbolicExpressionTreeNode(Symbol));

            if (Grammar.GetMaximumSubtreeCount(Symbol) > 0)
            {
                for (int i = 0; i < Grammar.GetMaximumSubtreeCount(Symbol); i++)
                {
                    var node         = new DummySymbol("Subtree " + i).CreateTreeNode();
                    var groupSymbols = grammar.GetAllowedChildSymbols(Symbol, i).OfType <GroupSymbol>().ToList();
                    foreach (var childSymbol in Grammar.GetAllowedChildSymbols(Symbol, i))
                    {
                        if (!groupSymbols.Any(g => g != childSymbol && g.Flatten().Contains(childSymbol)))
                        {
                            node.AddSubtree(new SymbolicExpressionTreeNode(childSymbol));
                        }
                    }
                    tree.Root.AddSubtree(node);
                }
            }
            symbolicExpressionTreeChart.Tree           = tree;
            symbolicExpressionTreeChart.SuspendRepaint = true;
            foreach (var subtreeNode in tree.Root.Subtrees)
            {
                foreach (var allowedChildNode in subtreeNode.Subtrees)
                {
                    var visualLine = symbolicExpressionTreeChart.GetVisualSymbolicExpressionTreeNodeConnection(subtreeNode, allowedChildNode);
                    visualLine.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
                }
            }

            for (int i = Grammar.GetMinimumSubtreeCount(symbol); i < Grammar.GetMaximumSubtreeCount(symbol); i++)
            {
                var subtreeNode    = tree.Root.GetSubtree(i);
                var visualTreeNode = symbolicExpressionTreeChart.GetVisualSymbolicExpressionTreeNode(subtreeNode);
                visualTreeNode.TextColor = Color.Gray;
                visualTreeNode.LineColor = Color.LightGray;

                var visualLine = symbolicExpressionTreeChart.GetVisualSymbolicExpressionTreeNodeConnection(tree.Root, subtreeNode);
                visualLine.LineColor = Color.LightGray;

                foreach (var allowedChildNode in subtreeNode.Subtrees)
                {
                    visualTreeNode           = symbolicExpressionTreeChart.GetVisualSymbolicExpressionTreeNode(allowedChildNode);
                    visualTreeNode.TextColor = Color.Gray;
                    visualTreeNode.LineColor = Color.LightGray;

                    visualLine           = symbolicExpressionTreeChart.GetVisualSymbolicExpressionTreeNodeConnection(subtreeNode, allowedChildNode);
                    visualLine.LineColor = Color.LightGray;
                }
            }
            symbolicExpressionTreeChart.SuspendRepaint = false;
            UpdateSelectedSymbolicExpressionTreeNodes();
        }
Пример #2
0
 public DummySymbol(DummySymbol original, Cloner cloner) : base(original, cloner)
 {
 }
    private void BuildAllowedChildSymbolsTree() {
      if (Symbol == null) {
        symbolicExpressionTreeChart.Tree = null;
        return;
      }

      var tree = new SymbolicExpressionTree(new SymbolicExpressionTreeNode(Symbol));
      if (Grammar.GetMaximumSubtreeCount(Symbol) > 0) {
        for (int i = 0; i < Grammar.GetMaximumSubtreeCount(Symbol); i++) {
          var node = new DummySymbol("Subtree " + i).CreateTreeNode();
          var groupSymbols = grammar.GetAllowedChildSymbols(Symbol, i).OfType<GroupSymbol>().ToList();
          foreach (var childSymbol in Grammar.GetAllowedChildSymbols(Symbol, i)) {
            if (!groupSymbols.Any(g => g != childSymbol && g.Flatten().Contains(childSymbol)))
              node.AddSubtree(new SymbolicExpressionTreeNode(childSymbol));
          }
          tree.Root.AddSubtree(node);
        }
      }
      symbolicExpressionTreeChart.Tree = tree;
      symbolicExpressionTreeChart.SuspendRepaint = true;
      foreach (var subtreeNode in tree.Root.Subtrees) {
        foreach (var allowedChildNode in subtreeNode.Subtrees) {
          var visualLine = symbolicExpressionTreeChart.GetVisualSymbolicExpressionTreeNodeConnection(subtreeNode, allowedChildNode);
          visualLine.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
        }
      }

      for (int i = Grammar.GetMinimumSubtreeCount(symbol); i < Grammar.GetMaximumSubtreeCount(symbol); i++) {
        var subtreeNode = tree.Root.GetSubtree(i);
        var visualTreeNode = symbolicExpressionTreeChart.GetVisualSymbolicExpressionTreeNode(subtreeNode);
        visualTreeNode.TextColor = Color.Gray;
        visualTreeNode.LineColor = Color.LightGray;

        var visualLine = symbolicExpressionTreeChart.GetVisualSymbolicExpressionTreeNodeConnection(tree.Root, subtreeNode);
        visualLine.LineColor = Color.LightGray;

        foreach (var allowedChildNode in subtreeNode.Subtrees) {
          visualTreeNode = symbolicExpressionTreeChart.GetVisualSymbolicExpressionTreeNode(allowedChildNode);
          visualTreeNode.TextColor = Color.Gray;
          visualTreeNode.LineColor = Color.LightGray;

          visualLine = symbolicExpressionTreeChart.GetVisualSymbolicExpressionTreeNodeConnection(subtreeNode, allowedChildNode);
          visualLine.LineColor = Color.LightGray;
        }
      }
      symbolicExpressionTreeChart.SuspendRepaint = false;
      UpdateSelectedSymbolicExpressionTreeNodes();
    }
 public DummySymbol(DummySymbol original, Cloner cloner) : base(original, cloner) { }