예제 #1
0
 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 }");
 }
예제 #2
0
 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;
 }
예제 #3
0
 public Node(Node parent)
 {
     this.m_parent = parent;
     this.m_tree = parent.m_tree;
     Initialize(this.m_tree);
 }
예제 #4
0
 public void SetBranchTree(SyntaxTree tree)
 {
     m_tree = tree;
     foreach (Connector connector in m_children)
         connector.Child.SetBranchTree(tree);
 }
예제 #5
0
        public Node(SyntaxTree tree)
        {
            this.m_tree = tree;
            this.m_parent = null;

            Initialize(tree);
        }
예제 #6
0
 public static SyntaxTree GetDefaultTree()
 {
     SyntaxTree ret = new SyntaxTree();//!!
     //ret.Root.SetLabelRtfAndText(Dummy.TextAndColorToRtf("S",ret.m_options.labelfont),"S");
     return ret;
 }
예제 #7
0
        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();
            }
        }
예제 #8
0
 internal void SetCurrentTree(SyntaxTree t, bool clearUndo)
 {
     if (clearUndo)
         undo.Clear();
     m_syntax = t;
     m_mousemode = MouseMode.None;
     ReleaseRequestForElem();
     ReleaseGDIResources();
     UpdateEverything(false);
 }
예제 #9
0
 public void SetCurrentTree(SyntaxTree t)
 {
     SetCurrentTree(t, true);
 }