///<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()); }
///<summary> /// Runs MetaEdit+ dialog. ///</summary> public void Run() { MetaEditAPI.MetaEditAPI port = Launcher.Port; Object o; switch (this.dialogType) { case CREATE_NEW_GRAPH: // Opens "Create Graph" dialog in MetaEdit+ MetaEditAPI.METype m = null; if (selectedGraph == null) { m = new MetaEditAPI.METype(); m.name = ("Graph"); } else { m = selectedGraph.GetMEType(); } MEAPI.AllowSetForegroundWindow(); o = port.createGraphDialog(m); if (o is MEAny) { // update graph view in UI process } break; case EDIT_GRAPH_PROPERTIES: // Opens "Properties" dialog for the selected graph in MetaEdit+ if (selectedGraph != null) { MEAPI.AllowSetForegroundWindow(); if (port.propertyDialog(this.selectedGraph.ToMEOop())) { // update graph view in UI process } } break; } }