private static void TableListing(object sender, EventArgs e) { ThreadHelper.JoinableTaskFactory.RunAsync(async() => { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); try { var output = new StringOutput(); int exitCode; using (var pr = new ProcessRunner()) { exitCode = pr.CaptureProcess("ptd.exe", "", ProbeEnvironment.CurrentAppSettings.TempDir, output); } if (exitCode != 0) { Shell.ShowError(string.Format("PTD returned exit code {0}.", exitCode)); } else { var tempFileName = TempManager.GetNewTempFileName("ptd", ".txt"); File.WriteAllText(tempFileName, output.Text); Shell.OpenDocument(tempFileName); } } catch (Exception ex) { Shell.ShowError(ex); } }); }
private static void FecFileToVisualC(object sender, EventArgs e) { ThreadHelper.JoinableTaskFactory.RunAsync(async() => { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); try { var activeDoc = Shell.DTE.ActiveDocument; if (activeDoc == null) { Shell.ShowError("No file is open."); return; } string baseFileName = ProbeEnvironment.CurrentAppSettings.FindBaseFile(activeDoc.FullName); if (string.IsNullOrEmpty(baseFileName)) { Shell.ShowError("Base file could not be found."); return; } using (var pr = new ProcessRunner()) { var args = string.Concat("\"", baseFileName, "\""); var output = new StringOutput(); var exitCode = pr.CaptureProcess("fec.exe", args, Path.GetDirectoryName(baseFileName), output); if (exitCode != 0) { Shell.ShowError(string.Format("FEC returned exit code {0}\r\n\r\n{1}", exitCode, output.Text)); return; } } var cFileName = Path.Combine(Path.GetDirectoryName(baseFileName), string.Concat(Path.GetFileNameWithoutExtension(baseFileName), ".c")); if (!File.Exists(cFileName)) { Shell.ShowError("Unable to find .c file produced by FEC."); return; } Shell.OpenDocument(cFileName); } catch (Exception ex) { Shell.ShowError(ex); } }); }