private async void GraphCode(UndertaleCode code) { if (code.DuplicateEntry) { GraphView.Source = null; CurrentGraphed = code; return; } LoaderDialog dialog = new LoaderDialog("Generating graph", "Generating graph, please wait..."); dialog.Owner = Window.GetWindow(this); Task t = Task.Run(() => { ImageSource image = null; try { code.UpdateAddresses(); var blocks = Decompiler.DecompileFlowGraph(code); string dot = Decompiler.ExportFlowGraph(blocks); try { var getStartProcessQuery = new GetStartProcessQuery(); var getProcessStartInfoQuery = new GetProcessStartInfoQuery(); var registerLayoutPluginCommand = new RegisterLayoutPluginCommand(getProcessStartInfoQuery, getStartProcessQuery); var wrapper = new GraphGeneration(getStartProcessQuery, getProcessStartInfoQuery, registerLayoutPluginCommand); byte[] output = wrapper.GenerateGraph(dot, Enums.GraphReturnType.Png); // TODO: Use SVG instead image = new ImageSourceConverter().ConvertFrom(output) as ImageSource; } catch (Exception e) { Debug.WriteLine(e.ToString()); if (MessageBox.Show("Unable to execute GraphViz: " + e.Message + "\nMake sure you have downloaded it and set the path in settings.\nDo you want to open the download page now?", "Graph generation failed", MessageBoxButton.YesNo, MessageBoxImage.Error) == MessageBoxResult.Yes) { Process.Start("https://graphviz.gitlab.io/_pages/Download/Download_windows.html"); } } } catch (Exception e) { Debug.WriteLine(e.ToString()); MessageBox.Show(e.Message, "Graph generation failed", MessageBoxButton.OK, MessageBoxImage.Error); } Dispatcher.Invoke(() => { GraphView.Source = image; CurrentGraphed = code; dialog.Hide(); }); }); dialog.ShowDialog(); await t; }