private void Initialize(SyntaxTree tree) { m_children = new List<Connector>(); m_traces = new List<Trace>(); m_decoration = new Decoration(DecorationMode.None, DecorationShape.Rectangle); m_displaytype = NodeDisplayType.Normal; /*m_label = new RichText("",Dummy.TextAndColorToRtf("",m_tree.m_options.labelfont)); m_lexical = new RichText("", Dummy.TextAndColorToRtf("", m_tree.m_options.lexicalfont));*/ m_label = new RichText("", "{\\rtf }"); m_lexical = new RichText("", "{\\rtf }"); }
public static SyntaxTree FromBracketing(String text) { SyntaxTree st = new SyntaxTree(); Node current = null; StringBuilder sb = null; int mode = 0; char openBracket; char closeBracket; if (text.Length > 0 && text[0] == '(') { openBracket = '('; closeBracket = ')'; } else { openBracket = '['; closeBracket = ']'; } for (int i = 0; i < text.Length; i++) { switch (mode) { case 0: if (text[i] == openBracket) { mode = 1; if (current == null) { current = new Node(st); st.Root = current; } else { Node newnode = current.AddChild(); current = newnode; } sb = new StringBuilder(); } else throw new TreeException("Bracketing syntax error: expected open bracket"); break; case 1: if (text[i] == ' ' || text[i] == openBracket || text[i] == closeBracket) { if (sb != null) { SetNodeLabelSimple(current, sb.ToString()); sb = null; } if (text[i] == ' ') { mode = 2; sb = new StringBuilder(); } if (text[i] == closeBracket) { current = current.GetParent(); if (current == null) mode = 4; } if (text[i] == openBracket) { mode = 0; i--; } } else if (sb != null) sb.Append(text[i]); break; case 2: if (text[i] == closeBracket || text[i] == openBracket) { if (sb != null) { String n = sb.ToString().Trim(); if (n != String.Empty) SetNodeLexicalSimple(current, n); sb = null; } if (text[i] == closeBracket) { current = current.GetParent(); if (current == null) mode = 4; } if (text[i] == openBracket) { mode = 0; i--; } } else if (sb != null) sb.Append(text[i]); break; case 4: throw new TreeException("Bracketing syntax error: Unexpected garbage at end"); } } if (current != null) throw new TreeException("Bracketing sytnax error: premature termination of string"); return st; }
public Node(Node parent) { this.m_parent = parent; this.m_tree = parent.m_tree; Initialize(this.m_tree); }
public void SetBranchTree(SyntaxTree tree) { m_tree = tree; foreach (Connector connector in m_children) connector.Child.SetBranchTree(tree); }
public Node(SyntaxTree tree) { this.m_tree = tree; this.m_parent = null; Initialize(tree); }
public static SyntaxTree GetDefaultTree() { SyntaxTree ret = new SyntaxTree();//!! //ret.Root.SetLabelRtfAndText(Dummy.TextAndColorToRtf("S",ret.m_options.labelfont),"S"); return ret; }
public SyntaxTreeViewer() : base() { //SetStyle(ControlStyles.AllPaintingInWmPaint, true); //SetStyle(ControlStyles.UserPaint, true); //SetStyle(ControlStyles.OptimizedDoubleBuffer, true); InitializeComponent(); InitDummyComponent(); InitMenus(); undo = new UndoManager(this); ResizeRedraw = true; m_mousemode = MouseMode.None; zoom = 1.0f; m_syntax = new SyntaxTree(); if (m_syntax != null) { UpdateTreeData(); FireStructureChanged(); } }
internal void SetCurrentTree(SyntaxTree t, bool clearUndo) { if (clearUndo) undo.Clear(); m_syntax = t; m_mousemode = MouseMode.None; ReleaseRequestForElem(); ReleaseGDIResources(); UpdateEverything(false); }
public void SetCurrentTree(SyntaxTree t) { SetCurrentTree(t, true); }