private void ButtonOpen_Click(object sender, RoutedEventArgs e) { try { if (treeView1.SelectedItem == null) { return; } GraphViewModel gvm = (GraphViewModel)treeView1.SelectedItem; MetaEditAPI.MetaEditAPI port = Launcher.Port; MEAPI.AllowSetForegroundWindow(); port.open(gvm.getGraph().ToMEOop()); } catch (Exception err) { DialogProvider.ShowMessageDialog("API error: " + err.Message, "API error"); this.correctErrorSituation(); } }
///<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; } }
/// <summary> /// Runs the named generator /// </summary> /// <param name="port">Connection to MetaEdit+ API server.</param> /// <param name="generator">Name of the generator</param> /// <returns>Was the generation successful (unknown=true, e.g. for 4.5)</returns> public bool RunGenerator(MetaEditAPI.MetaEditAPI port, String generator) { bool success = true; MEAPI.AllowSetForegroundWindow(); try { if (Settings.GetSettings().Version.IsEqualOrGreaterThan("5.0")) { success = port.forGraphRun(this.ToMEOop(), generator); } else { MetaEditAPI.MENull meNull = new MetaEditAPI.MENull(); port.forName(meNull, this.Name, this.TypeName, generator); } } catch (Exception e) { DialogProvider.ShowMessageDialog("API error: " + e.Message, "API error"); success = false; } return(success); }