public MainWindow() { InitializeComponent(); #region "zooming" var group = new TransformGroup(); var xform = new ScaleTransform(); group.Children.Add(xform); var tt = new TranslateTransform(); group.Children.Add(tt); ImgGraph.RenderTransform = group; ImgGraph.MouseWheel += image_MouseWheel; ImgGraph.MouseLeftButtonDown += image_MouseLeftButtonDown; ImgGraph.MouseLeftButtonUp += image_MouseLeftButtonUp; ImgGraph.MouseMove += image_MouseMove; #endregion #region "Initializing GraphViz.NET" var getStartProcessQuery = new GetStartProcessQuery(); var getProcessStartInfoQuery = new GetProcessStartInfoQuery(); var registerLayoutPluginCommand = new RegisterLayoutPluginCommand(getProcessStartInfoQuery, getStartProcessQuery); var wrapper = new GraphGeneration(getStartProcessQuery, getProcessStartInfoQuery, registerLayoutPluginCommand); _wrapperForGraph = wrapper; #endregion }
public Image toDigraphImage() { var getStartProcessQuery = new GetStartProcessQuery(); var getProcessStartInfoQuery = new GetProcessStartInfoQuery(); var registerLayoutPluginCommand = new RegisterLayoutPluginCommand(getProcessStartInfoQuery, getStartProcessQuery); var wrapper = new GraphGeneration(getStartProcessQuery, getProcessStartInfoQuery, registerLayoutPluginCommand); StringBuilder sb = new StringBuilder("digraph{"); for (int n1 = 0; n1 < NodesCount; n1++) { for (int n2 = 0; n2 < NodesCount; n2++) { if (AdjMatrix[n1, n2] != Double.PositiveInfinity) { sb.AppendLine(String.Format("n{0}->n{1}", n1, n2)); } } } sb.AppendLine("}"); byte[] output = wrapper.GenerateGraph(sb.ToString(), Enums.GraphReturnType.Png); using (MemoryStream ms = new MemoryStream(output)) { return(Image.FromStream(ms)); } }
public void GenerateGraphReturnsByteArrayWithLengthGreaterOrEqualZero() { // Arrange _registerLayoutPluginCommandMock.Setup(m => m.Invoke("SomeLocation", Enums.RenderingEngine.Dot)); _getProcessStartInfoQuery.Setup(m => m.Invoke(It.IsAny <IProcessStartInfoWrapper>())).Returns( new ProcessStartInfo { FileName = "cmd", RedirectStandardInput = true, RedirectStandardOutput = true, RedirectStandardError = true, UseShellExecute = false, CreateNoWindow = true }); var wrapper = new GraphGeneration( _getStartProcessQuery, _getProcessStartInfoQuery.Object, _registerLayoutPluginCommandMock.Object); // Act byte[] output = wrapper.GenerateGraph("digraph{a -> b; b -> c; c -> a;}", Enums.GraphReturnType.Png); // Assert Assert.That(output.Length, Is.GreaterThanOrEqualTo(0)); }
static void Main(string[] args) { 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("digraph G {a -> b; b -> c; c -> a;}", Enums.GraphReturnType.Png); /* * ArqTable ar = new ArqTable(); * ar.lerArquivo("Table.txt"); * string[,] table = new string[ar.contLine(), ar.contColum()]; * ar.matriz(table); * PredictiveAnalysis analysis = new PredictiveAnalysis("(i)*(i)$"); * analysis.inicioAnalise(table); * Console.WriteLine("\n"); * Console.WriteLine("\\\\\\\\\\---------- TABELA --------\\\\\\\\\\"); * for (int i=0; i < ar.contLine(); i++) * { * for(int j=0; j < ar.contColum(); j++) * { * Console.Write(table[i, j] + " \t"); * } * Console.WriteLine(); * }*/ Console.ReadLine(); }
public void GenerateGraphReturnsByteArrayWithLengthGreaterOrEqualZero() { // Arrange _registerLayoutPluginCommandMock.Setup(m => m.Invoke("SomeLocation", Enums.RenderingEngine.Dot)); _getProcessStartInfoQuery.Setup(m => m.Invoke(It.IsAny<IProcessStartInfoWrapper>())).Returns( new ProcessStartInfo { FileName = "cmd", RedirectStandardInput = true, RedirectStandardOutput = true, RedirectStandardError = true, UseShellExecute = false, CreateNoWindow = true }); var wrapper = new GraphGeneration( _getStartProcessQuery, _getProcessStartInfoQuery.Object, _registerLayoutPluginCommandMock.Object); // Act byte[] output = wrapper.GenerateGraph("digraph{a -> b; b -> c; c -> a;}", Enums.GraphReturnType.Png); // Assert Assert.That(output.Length, Is.GreaterThanOrEqualTo(0)); }
/// <summary> /// generate an image from .gv strings /// </summary> /// <param name="diagraph"></param> /// <param name="imgFile"></param> private static void generateGraphImage(string diagraph, string imgFile) { var getStartProcessQuery = new GetStartProcessQuery(); var getProcessStartInfoQuerty = new GetProcessStartInfoQuery(); var registerLayoutPluginCommand = new RegisterLayoutPluginCommand(getProcessStartInfoQuerty, getStartProcessQuery); var wrapper = new GraphGeneration( getStartProcessQuery, getProcessStartInfoQuerty, registerLayoutPluginCommand); // wrapper.RenderingEngine = Enums.RenderingEngine.Fdp; //wrapper.RenderingEngine = Enums.RenderingEngine.Sfdp; wrapper.RenderingEngine = Enums.RenderingEngine.Dot; byte[] output = wrapper.GenerateGraph(diagraph, Enums.GraphReturnType.Png); // byte[] to Image System.Drawing.Image img = byteArrayToImage(output); // save the image img.Save(imgFile, System.Drawing.Imaging.ImageFormat.Png); img.Dispose(); }
public void GenerateCFG(TACode code) { try { var cfg = new ControlFlowGraph(code); string graph = BuildDotGraph(cfg); File.WriteAllText(@"cfg_graph.txt", graph); var processQuery = new GetStartProcessQuery(); var processStartInfoQuery = new GetProcessStartInfoQuery(); var registerLayout = new RegisterLayoutPluginCommand(processStartInfoQuery, processQuery); var wrapper = new GraphGeneration(processQuery, processStartInfoQuery, registerLayout) { RenderingEngine = Enums.RenderingEngine.Dot }; byte[] output = wrapper.GenerateGraph(graph, Enums.GraphReturnType.Png); using (var stream = new MemoryStream(output)) { var image = Image.FromStream(stream); GenerationCompleted(null, image); } CfgGenerated(null, cfg); } catch (Exception ex) { GenerationErrored(null, ex); } }
public void GenerateGraph_Called_ReturnsByteArrayWithLengthGreaterThanZero() { var _getProcessStartInfoQueryMock = Substitute.For <IGetProcessStartInfoQuery>(); var _registerLayoutPluginCommandMock = Substitute.For <IRegisterLayoutPluginCommand>(); _registerLayoutPluginCommandMock.Invoke(Arg.Any <string>(), Arg.Any <Enums.RenderingEngine>()); _getProcessStartInfoQueryMock.Invoke(Arg.Any <IProcessStartInfoWrapper>()).Returns( new ProcessStartInfo { FileName = "cmd", RedirectStandardInput = true, RedirectStandardOutput = true, RedirectStandardError = true, UseShellExecute = false, CreateNoWindow = true }); var wrapper = new GraphGeneration( _getStartProcessQuery, _getProcessStartInfoQueryMock, _registerLayoutPluginCommandMock); _wrapper.RenderingEngine = Enums.RenderingEngine.Dot; // Act byte[] output = wrapper.GenerateGraph("digraph{a -> b; b -> c; c -> a;}", Enums.GraphReturnType.Png); // Assert output.Length.Should().BePositive($"because Rendering Engine is {Enums.RenderingEngine.Dot.ToString()}"); }
/// Constructs an element at the specified offset. /// May return null if no element should be constructed. protected override InlineObjectElement ConstructMainElement(int offset) { Match m = FindMatch(offset); // check whether there's a match exactly at offset if (m.Success && m.Index == 0) { GraphGeneration wrapper = GetGraphGeneration(); UIElement uiElement; if (wrapper.IsGraphvizInstalled) { string rankdir = m.Groups[2].Value.Trim(); string dotGraph = GraphvizDotGenerator.MakeGraphvizDot(Document, offset, rankdir); BitmapImage bitmap = LoadBitmap(dotGraph); if (bitmap != null) { string scale = m.Groups[1].Value; uiElement = CreateImageControl(offset, scale, bitmap); } else { uiElement = CreateErrorMesageTextBlock("Invalid Graphviz"); } } else { uiElement = CreateErrorMesageTextBlock("Graphviz is not installed"); } // Pass the length of the match to the 'documentLength' parameter of InlineObjectElement. return(new InlineObjectElement(m.Length, uiElement)); } return(null); }
void InitialiseDotWrapper() { var getStartProcessQuery = new GetStartProcessQuery(); var getProcessStartInfoQuery = new GetProcessStartInfoQuery(); var registerLayoutPluginCommand = new RegisterLayoutPluginCommand(getProcessStartInfoQuery, getStartProcessQuery); wrapper = new GraphGeneration(getStartProcessQuery, getProcessStartInfoQuery, registerLayoutPluginCommand); }
public GraphBuilder() { var getStartProcessQuery = new GetStartProcessQuery(); var getProcessStartInfoQuery = new GetProcessStartInfoQuery(); var registerLayoutPluginCommand = new RegisterLayoutPluginCommand(getProcessStartInfoQuery, getStartProcessQuery); _wrapper = new GraphGeneration(getStartProcessQuery, getProcessStartInfoQuery, registerLayoutPluginCommand); }
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; }
public static void Save(string graphText, string outFile) { var outFileInfo = new FileInfo(outFile); // These three instances can be injected via the IGetStartProcessQuery, // IGetProcessStartInfoQuery and // IRegisterLayoutPluginCommand interfaces var getStartProcessQuery = new GetStartProcessQuery(); var getProcessStartInfoQuery = new GetProcessStartInfoQuery(); var registerLayoutPluginCommand = new RegisterLayoutPluginCommand(getProcessStartInfoQuery, getStartProcessQuery); // GraphGeneration can be injected via the IGraphGeneration interface var wrapper = new GraphGeneration( getStartProcessQuery, getProcessStartInfoQuery, registerLayoutPluginCommand); Enums.GraphReturnType saveType; switch (outFileInfo.Extension) { case ".pdf": saveType = Enums.GraphReturnType.Pdf; break; case ".jpg": saveType = Enums.GraphReturnType.Jpg; break; case ".png": saveType = Enums.GraphReturnType.Png; break; default: throw new Exception($"Unknown extension: {outFileInfo.Extension}"); } var currentDirectory = Directory.GetCurrentDirectory(); byte[] output; try { Directory.SetCurrentDirectory(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)); output = wrapper.GenerateGraph(graphText, saveType); } finally { Directory.SetCurrentDirectory(currentDirectory); } File.WriteAllBytes(outFile, output); Console.WriteLine(); Console.WriteLine($"{output.Length} bytes written to {outFile}."); }
static void Main(string[] args) { 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("", Enums.GraphReturnType.Svg); File.WriteAllBytes("Foo.svg", output.ToArray()); }
public BitmapImage LoadImage(GraphGeneration graphGeneration) { if (!HasLoaded) { m_BitmapImage = MakeBitmapImage(graphGeneration); HasLoaded = true; } return(m_BitmapImage); }
public IActionResult PathToRoot(string id, long token, int nodeid, bool raw) { if (staticState.TryGetValue(token, out var state)) { if (state.State is MultiThreadedSolverState multiResult) { var node = nodeid == null ? multiResult.Root : nodeid > 0 ? multiResult.Root.FirstOrDefault(x => x.SolverNodeId == nodeid) ?? multiResult.RootReverse.FirstOrDefault(x => x.SolverNodeId == nodeid) : multiResult.RootReverse; var path = node.PathToRoot(); var expanded = new List <SolverNode>(); foreach (var p in path) { expanded.Add(p); if (p.HasChildren) { foreach (var kid in p.Children) { if (!path.Contains(kid)) { expanded.Add(kid); } } } } var render = new GraphVisRender(); var sb = new StringBuilder(); using (var ss = new StringWriter(sb)) { render.Render(expanded, ss); } var getStartProcessQuery = new GetStartProcessQuery(); var getProcessStartInfoQuery = new GetProcessStartInfoQuery(); var registerLayoutPluginCommand = new RegisterLayoutPluginCommand(getProcessStartInfoQuery, getStartProcessQuery); var wrapper = new GraphGeneration(getStartProcessQuery, getProcessStartInfoQuery, registerLayoutPluginCommand); var b = wrapper.GenerateGraph(sb.ToString(), Enums.GraphReturnType.Svg); if (raw) { } return(new FileContentResult(b, "image/svg+xml")); } } return(RedirectToAction("Home", new { id, txt = "NotFound" })); }
/// <summary> /// Generate dot string that represents graph and write to file. /// </summary> /// <param name="codeGraph"></param> /// <param name="outputFileName"></param> public static void GenerateDotGraph(CodeGraph codeGraph, string outputFileName) { Console.WriteLine($"Writing code graph to {outputFileName}"); GraphGeneration wrapper = GetGraphvizWrapper(); string graphDotString = ConvertGraphToDotString(codeGraph); byte[] output = wrapper.GenerateGraph(graphDotString, Enums.GraphReturnType.Png); WriteGraphToImageFile(output, outputFileName); }
private static GraphGeneration GetWrapper() { var getStartProcessQuery = new GetStartProcessQuery(); var getProcessStartInfoQuery = new GetProcessStartInfoQuery(); var registerLayoutPluginCommand = new RegisterLayoutPluginCommand(getProcessStartInfoQuery, getStartProcessQuery); var wrapper = new GraphGeneration(getStartProcessQuery, getProcessStartInfoQuery, registerLayoutPluginCommand); return(wrapper); }
/// <summary> /// Erzeugt einen NetzplanGenerator. /// </summary> public PrecedenceDiagramGenerator() { var getStartProcessQuery = new GetStartProcessQuery(); var getProcessStartInfoQuery = new GetProcessStartInfoQuery(); var registerLayoutPluginCommand = new RegisterLayoutPluginCommand( getProcessStartInfoQuery, getStartProcessQuery); wrapper = new GraphGeneration( getStartProcessQuery, getProcessStartInfoQuery, registerLayoutPluginCommand); }
private void button1_Click(object sender, EventArgs e) { Ember apa = new Ember("Apa"); Ember anya = new Ember("Anya"); Ember gy1 = new Ember("Gy1"); Ember gy2 = new Ember("Gy2"); Ember u1 = new Ember("U"); Ember uu1 = new Ember("uu1"); Ember uu2 = new Ember("uu2"); Ember uu3 = new Ember("uu3"); apa.parja = anya; anya.parja = apa; apa.gyermeke.Add(gy1); apa.gyermeke.Add(gy2); anya.gyermeke.Add(gy1); anya.gyermeke.Add(gy2); gy1.gyermeke.Add(u1); u1.gyermeke.Add(uu1); u1.gyermeke.Add(uu2); u1.gyermeke.Add(uu3); string s = gyujto(apa); // var getStartProcessQuery = new GetStartProcessQuery(); var getProcessStartInfoQuery = new GetProcessStartInfoQuery(); var registerLayoutPluginCommand = new RegisterLayoutPluginCommand(getProcessStartInfoQuery, getStartProcessQuery); // GraphGeneration can be injected via the IGraphGeneration interface var wrapper = new GraphGeneration(getStartProcessQuery, getProcessStartInfoQuery, registerLayoutPluginCommand); byte[] output = wrapper.GenerateGraph("digraph{" + s + "}", Enums.GraphReturnType.Png); using (MemoryStream ms = new MemoryStream(output)) { Image i = Image.FromStream(ms); pictureBox1.Image = i; } }
/// <summary> /// Guarda el resultado de compilar con dot el string srcCode en name /// </summary> /// <param name="filepath"></param> /// <param name="srcCode"></param> public static Image SavePng(string filepath, string srcCode) { var getStartProcessQuery = new GetStartProcessQuery(); var getProcessStartInfoQuery = new GetProcessStartInfoQuery(); var registerLayoutPluginCommand = new RegisterLayoutPluginCommand(getProcessStartInfoQuery, getStartProcessQuery); // GraphGeneration can be injected via the IGraphGeneration interface var wrapper = new GraphGeneration(getStartProcessQuery, getProcessStartInfoQuery, registerLayoutPluginCommand); var indexOfDot = filepath.LastIndexOf('.'); if (indexOfDot < 0 || indexOfDot + 1 >= filepath.Length) { return(null); } var stringFormat = filepath.Substring(indexOfDot + 1); Enums.GraphReturnType returnType; switch (stringFormat) { case "jpg": returnType = Enums.GraphReturnType.Jpg; break; case "jpeg": returnType = Enums.GraphReturnType.Jpg; break; case "png": returnType = Enums.GraphReturnType.Png; break; default: return(null); } var imgBytes = wrapper.GenerateGraph(srcCode, returnType); if (imgBytes.Length < 1)//Error al compilar el graphviz { return(null); } var ms = new MemoryStream(imgBytes, 0, imgBytes.Length); var img = Image.FromStream(ms, true); img.Save(filepath); return(img); }
public byte[] GetByteGraph() { 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(GraphStringBuilder(ProcessRepo.Processes), Enums.GraphReturnType.Png); return(output); }
static void GenerateGraphFile(string data, string filename) { GetStartProcessQuery getStartProcessQuery = new GetStartProcessQuery(); GetProcessStartInfoQuery getProcessStartInfoQuery = new GetProcessStartInfoQuery(); RegisterLayoutPluginCommand registerLayoutPluginCommand = new RegisterLayoutPluginCommand(getProcessStartInfoQuery, getStartProcessQuery); GraphGeneration wrapper = new GraphGeneration(getStartProcessQuery, getProcessStartInfoQuery, registerLayoutPluginCommand); byte[] output = wrapper.GenerateGraph(data, Enums.GraphReturnType.Jpg); System.IO.File.WriteAllBytes("Images/" + filename + ".jpg", output); }
public byte[] VisualiseGraph <T>(Graph <T> graph) { var getStartProcessQuery = new GetStartProcessQuery(); var getProcessStartInfoQuery = new GetProcessStartInfoQuery(); var registerLayoutPluginCommand = new RegisterLayoutPluginCommand(getProcessStartInfoQuery, getStartProcessQuery); // GraphGeneration can be injected via the IGraphGeneration interface var wrapper = new GraphGeneration(getStartProcessQuery, getProcessStartInfoQuery, registerLayoutPluginCommand); return(wrapper.GenerateGraph(GenerateGraphVizString(graph), Enums.GraphReturnType.Png)); }
public static Bitmap ToImage(string str) { 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(str /*"digraph{a -> b; b -> c; c -> a;}"*/, Enums.GraphReturnType.Png); return(ByteToImage(output)); }
/// <summary> /// Set up graphviz wrapper to generate graphviz graph with. /// </summary> /// <returns></returns> private static GraphGeneration GetGraphvizWrapper() { var getStartProcessQuery = new GetStartProcessQuery(); var getProcessStartInfoQuery = new GetProcessStartInfoQuery(); var registerLayoutPluginCommand = new RegisterLayoutPluginCommand(getProcessStartInfoQuery, getStartProcessQuery); // GraphGeneration can be injected via the IGraphGeneration interface var wrapper = new GraphGeneration(getStartProcessQuery, getProcessStartInfoQuery, registerLayoutPluginCommand); return(wrapper); }
private void VisualizeGraph(string dot) { 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); graphView.Image = (Bitmap)((new ImageConverter()).ConvertFrom(output)); }
static void GenerateGraphFile(string data, string filename) { 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(data, Enums.GraphReturnType.Jpg); System.IO.File.WriteAllBytes(filename + ".jpg", output); System.Diagnostics.Process.Start($"{filename}.jpg"); }
public IActionResult Test() { var getStartProcessQuery = new GetStartProcessQuery(); var getProcessStartInfoQuery = new GetProcessStartInfoQuery(); var registerLayoutPluginCommand = new RegisterLayoutPluginCommand(getProcessStartInfoQuery, getStartProcessQuery); // GraphGeneration can be injected via the IGraphGeneration interface var wrapper = new GraphGeneration(getStartProcessQuery, getProcessStartInfoQuery, registerLayoutPluginCommand); var b = wrapper.GenerateGraph("digraph{a -> b; b -> c; c -> a;}", Enums.GraphReturnType.Svg); return(new FileContentResult(b, "image/svg+xml")); }
public static void BuildGraph(TreeNode root, string filename) { GetStartProcessQuery getStartProcessQuery = new GetStartProcessQuery(); GetProcessStartInfoQuery getProcessStartInfoQuery = new GetProcessStartInfoQuery(); RegisterLayoutPluginCommand registerLayoutPluginCommand = new RegisterLayoutPluginCommand(getProcessStartInfoQuery, getStartProcessQuery); GraphGeneration wrapper = new GraphGeneration(getStartProcessQuery, getProcessStartInfoQuery, registerLayoutPluginCommand); var graphStr = BuildGraphString(root); //Console.WriteLine(graphStr); byte[] output = wrapper.GenerateGraph(graphStr, Enums.GraphReturnType.Png); File.WriteAllText($"{filename}.txt", graphStr); using (Image image = Image.FromStream(new MemoryStream(output))) { image.Save($"{filename}.png", ImageFormat.Png); } }
public void AllowsPlainTextOutputType() { // Arrange var getProcessStartInfoQuery = new GetProcessStartInfoQuery(); var registerLayoutPluginCommand = new RegisterLayoutPluginCommand(getProcessStartInfoQuery, _getStartProcessQuery); var wrapper = new GraphGeneration( _getStartProcessQuery, getProcessStartInfoQuery, registerLayoutPluginCommand); // Act byte[] output = wrapper.GenerateGraph("digraph{a -> b; b -> c; c -> a;}", Enums.GraphReturnType.Plain); var graphPortion = System.Text.Encoding.Default.GetString(output).Split(new string[] { "\r\n" }, System.StringSplitOptions.None); Assert.AreEqual("graph 1 1.125 2.5", graphPortion[0]); }
private void button2_Click(object sender, EventArgs e) { //Melakukan pembangkitan gambar untuk hasil solusi sequence dari topological sort //Menggunakan library graphviz //Gambar akan ditampilkan pada picturebox1 var getStartProcessQuery = new GetStartProcessQuery(); var getProcessStartInfoQuery = new GetProcessStartInfoQuery(); var registerLayoutPluginCommand = new RegisterLayoutPluginCommand(getProcessStartInfoQuery, getStartProcessQuery); // GraphGeneration can be injected via the IGraphGeneration interface //Deklarasi wrapper var wrapper = new GraphGeneration(getStartProcessQuery, getProcessStartInfoQuery, registerLayoutPluginCommand); // Membuat query ke graphviz string request = "digraph G{{rank = same;"; for (int i = 0; i < resultGraph.getSize(); i++) { request = request + pemetaanIndex[solution[i]] + ";"; } for (int i = 0; i < resultGraph.getSize(); i++) { for (int j = 0; j < resultGraph.getSize(); j++) { if (resultGraph.isAdjacent(i, j)) { request = request + pemetaanIndex[i] + "->" + pemetaanIndex[j] + ";"; } } } request = request + "}}"; // Membangkitkan gambar lau disimpan dalam byte byte[] output = wrapper.GenerateGraph(request, Enums.GraphReturnType.Jpg); //Drawing ke object Image Image gambar = System.Drawing.Image.FromStream(new MemoryStream(output)); //Tampilkan gambar; pictureBox1.Image = gambar; }
public void DoesNotCrashWithLargeInput() { // Arrange var getProcessStartInfoQuerty = new GetProcessStartInfoQuery(); var registerLayoutPluginCommand = new RegisterLayoutPluginCommand(getProcessStartInfoQuerty, _getStartProcessQuery); var wrapper = new GraphGeneration( _getStartProcessQuery, getProcessStartInfoQuerty, registerLayoutPluginCommand); // Act var diagraph = "digraph G {subgraph cluster_T1 { label = \"WORK ORDER\"; S1 [label = \"ACCEPTED\"]; S2 [label = \"DENIED\"]; S5 [label = \"SCHEDULED\"]; S44 [label = \"COMPLETE\"]; S47 [label = \"DELIVERED\"]; S48 [label = \"CANCELLED\"]; } subgraph cluster_T2 { label = \"MILL/DIG CHECK OUT\"; S3 [label = \"PROGRAMMING\"]; S4 [label = \"CUTTER PATH\"]; } subgraph cluster_T24 { label = \"OFFLOAD INTERNAL\"; S83 [label = \"IN PROCESS\"]; S84 [label = \"FINISHED\"]; } subgraph cluster_T23 { label = \"OFFLOAD EXTERNAL\"; S45 [label = \"IN PROCESS\"]; S46 [label = \"FINISHED\"]; S82 [label = \"QUOTE PENDING\"]; } subgraph cluster_T1 { label = \"WORK ORDER\"; S49 [label = \"WAITING 5-AXIS\"]; S50 [label = \"WAITING DATA CHANGE\"]; } subgraph cluster_T8 { label = \"MILL 1\"; S15 [label = \"IN PROCESS\"]; S16 [label = \"FINISHED\"]; } subgraph cluster_T9 { label = \"MILL 2\"; S17 [label = \"IN PROCESS\"]; S18 [label = \"FINISHED\"]; } subgraph cluster_T10 { label = \"MILL 3\"; S20 [label = \"IN PROCESS\"]; S21 [label = \"FINISHED\"]; } subgraph cluster_T11 { label = \"MILL 4\"; S22 [label = \"IN PROCESS\"]; S23 [label = \"FINISHED\"]; } subgraph cluster_T12 { label = \"MILL 5\"; S24 [label = \"IN PROCESS\"]; S25 [label = \"FINISHED\"]; } subgraph cluster_T13 { label = \"MILL 6\"; S26 [label = \"IN PROCESS\"]; S27 [label = \"FINISHED\"]; } subgraph cluster_T14 { label = \"MILL 7\"; S28 [label = \"IN PROCESS\"]; S29 [label = \"FINISHED\"]; } subgraph cluster_T15 { label = \"MILL 8\"; S30 [label = \"IN PROCESS\"]; S31 [label = \"FINISHED\"]; } subgraph cluster_T16 { label = \"HAAS\"; S32 [label = \"IN PROCESS\"]; S33 [label = \"FINISHED\"]; } subgraph cluster_T17 { label = \"FADAL 1\"; S34 [label = \"IN PROCESS\"]; S35 [label = \"FINISHED\"]; } subgraph cluster_T18 { label = \"FADAL 2\"; S36 [label = \"IN PROCESS\"]; S37 [label = \"FINISHED\"]; } subgraph cluster_T19 { label = \"DUPLICATOR\"; S38 [label = \"IN PROCESS\"]; S39 [label = \"FINISHED\"]; } subgraph cluster_T20 { label = \"TWIN RED\"; S40 [label = \"IN PROCESS\"]; S41 [label = \"FINISHED\"]; } subgraph cluster_T21 { label = \"TWIN BLUE\"; S42 [label = \"IN PROCESS\"]; S43 [label = \"FINISHED\"]; } S1->S3;S47->S44;S3->S4;S4->S5;S83->S84;S84->S47;S45->S46;S46->S47;S82->S45;S15->S16;S16->S47;S17->S18;S18->S47;S20->S21;S21->S47;S22->S23;S23->S47;S24->S25;S25->S47;S26->S27;S27->S47;S28->S29;S29->S47;S30->S31;S31->S47;S32->S33;S33->S47;S34->S35;S35->S47;S36->S37;S37->S47;S38->S39;S39->S47;S40->S41;S41->S47;S42->S43;S43->S47;}"; byte[] output = wrapper.GenerateGraph(diagraph, Enums.GraphReturnType.Png); }