Exemple #1
0
        ///<summary>
        /// Initializes the graph view by getting the graphs from MetaEdit.
        ///</summary>
        ///<returns>Array of graphs.</returns>
        public static Graph [] Init()
        {
            MetaEditAPI.MetaEditAPI port = Launcher.Port;
            METype graphType             = new MetaEditAPI.METype();

            graphType.name = "Graph";
            List <Graph> graphs         = new List <Graph>();
            List <Graph> topLevelGraphs = new List <Graph>();

            MetaEditAPI.MEOop[] meOops = new MetaEditAPI.MEOop[0];
            if (!Launcher.IsApiOK())
            {
                return(topLevelGraphs.ToArray());
            }
            try {
                meOops = port.allSimilarInstances(graphType);
            } catch (Exception e) {
                DialogProvider.ShowMessageDialog("API error: " + e.Message, "API error");
            }
            foreach (MEOop m in meOops)
            {
                Graph g = Graph.MEOopToGraph(m);
                graphs.Add(g);
            }
            List <Graph> done = new List <Graph>();

            foreach (Graph g in graphs)
            {
                g.InitChildren(port, done);
            }
            foreach (Graph g in graphs)
            {
                if (!g.getIsChild())
                {
                    topLevelGraphs.Add(g);
                }
            }
            List <Graph> reachableGraphsList = ReachableGraphs(topLevelGraphs);

            graphs.Sort(delegate(Graph g1, Graph g2) { return(g1.Name.CompareTo(g2.Name)); });

            foreach (Graph g in graphs)
            {
                if (!reachableGraphsList.Contains(g))
                {
                    topLevelGraphs.Add(g);
                    BuildReachableGraphs(g, reachableGraphsList);
                }
            }
            return(topLevelGraphs.ToArray());
        }
Exemple #2
0
 private bool IsAPI()
 {
     return(Launcher.IsApiOK());
 }