Exemplo n.º 1
0
        internal void ParseScript(string file)
        {
            this.treeViewOutline.BeginUpdate();

            this._model = new TreeModel();
            this._outline = ScriptOutline.CreateFromScript(file);

            if (this._outline != null)
            {
                BookmarkNode rootNode = new BookmarkNode(this._outline.Class, BookmarkNode.Categories.Class, null);

                this._model.Nodes.Add(rootNode);

                try
                {
                    BookmarkNode replicationNode = new BookmarkNode("Replication", BookmarkNode.Categories.Replication, this._outline.Replication);
                    rootNode.Nodes.Add(replicationNode);

                    BookmarkNode defaultPropertiesNode = new BookmarkNode("Default Properties", BookmarkNode.Categories.DefaultProperties, this._outline.DefaultProperties);
                    rootNode.Nodes.Add(defaultPropertiesNode);

                    BookmarkNode varsNode = new BookmarkNode("Variables", BookmarkNode.Categories.Group, null);
                    rootNode.Nodes.Add(varsNode);

                    foreach (ScriptOutline.VarDesc scriptVar in this._outline.Variables)
                    {
                        BookmarkNode varNode = new BookmarkNode(scriptVar.Identifier, BookmarkNode.Categories.Variable, scriptVar);
                        varsNode.Nodes.Add(varNode);
                    }

                    BookmarkNode stateNode = null;
                    Dictionary<string, BookmarkNode> states = new Dictionary<string, BookmarkNode>();
                    BookmarkNode functionsNode = new BookmarkNode("Functions", BookmarkNode.Categories.Group, null);
                    rootNode.Nodes.Add(functionsNode);

                    states.Clear();
                    stateNode = new BookmarkNode("\tGlobal", BookmarkNode.Categories.State, null);
                    states["\tGlobal"] = stateNode;
                    functionsNode.Nodes.Add(stateNode);

                    foreach (ScriptOutline.StateDesc scriptState in this._outline.States)
                    {
                        stateNode = new BookmarkNode(scriptState.Identifier, BookmarkNode.Categories.State, scriptState);
                        states[scriptState.Identifier] = stateNode;
                        functionsNode.Nodes.Add(stateNode);
                    }

                    foreach (ScriptOutline.FunctionDesc scriptFunction in this._outline.Functions)
                    {
                        BookmarkNode functionNode = new BookmarkNode(scriptFunction.Identifier, BookmarkNode.Categories.Function, scriptFunction);

                        if (states.TryGetValue(scriptFunction.State, out stateNode))
                        {
                            stateNode.Nodes.Add(functionNode);
                        }
                    }

                    BookmarkNode eventsNode = new BookmarkNode("Events", BookmarkNode.Categories.Group, null);
                    rootNode.Nodes.Add(eventsNode);

                    states.Clear();
                    stateNode = new BookmarkNode("\tGlobal", BookmarkNode.Categories.State, null);
                    states["\tGlobal"] = stateNode;
                    eventsNode.Nodes.Add(stateNode);

                    foreach (ScriptOutline.StateDesc scriptState in this._outline.States)
                    {
                        stateNode = new BookmarkNode(scriptState.Identifier, BookmarkNode.Categories.State, scriptState);
                        states[scriptState.Identifier] = stateNode;
                        eventsNode.Nodes.Add(stateNode);
                    }

                    foreach (ScriptOutline.EventDesc scriptEvent in this._outline.Events)
                    {
                        BookmarkNode eventNode = new BookmarkNode(scriptEvent.Identifier, BookmarkNode.Categories.Event, scriptEvent);

                        if (states.TryGetValue(scriptEvent.State, out stateNode))
                        {
                            stateNode.Nodes.Add(eventNode);
                        }
                    }
                }
                catch (Exception e)
                {
                    ExceptionMessageBox msgBox = new ExceptionMessageBox(e);
                    msgBox.ShowDialog();
                }
            }

            this.treeViewOutline.Model = _model;
            this.treeViewOutline.EndUpdate();

            foreach (TreeNodeAdv node in this.treeViewOutline.Root.Children)
            {
                node.Expand();
            }
        }
Exemplo n.º 2
0
 public BookmarkNode(string text, Categories category, ScriptOutline.ScriptDesc description)
     : base(text)
 {
     this._category = category;
     this._description = description;
 }