コード例 #1
0
        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
        }
コード例 #2
0
ファイル: MainWindow.xaml.cs プロジェクト: AminAliari/fsm
        public MainWindow(int states)
        {
            InitializeComponent();

            Width  = 175 + (states - 2) * 50;
            Height = 250 + (states - 2) * 50;

            n  = states;
            dt = new DataTable();

            st = new Stopwatch();

            gspq = new GetStartProcessQuery();
            gsiq = new GetProcessStartInfoQuery();
            rlpc = new RegisterLayoutPluginCommand(gsiq, gspq);

            for (int i = 0; i < states; i++)
            {
                dt.Columns.Add(i.ToString(), typeof(string));
            }

            for (int row = 0; row < states; row++)
            {
                DataRow dr = dt.NewRow();
                for (int col = 0; col < states; col++)
                {
                    dr[col] = "-";
                }
                dt.Rows.Add(dr);
            }
            dataGrid.ItemsSource = dt.DefaultView;
        }
コード例 #3
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();
        }
コード例 #4
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();
        }
コード例 #5
0
        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);
            }
        }
コード例 #6
0
        private void Form1_Load(object sender, EventArgs e)
        {
            this.BaseGraph    = new Graph(GraphType.Undirected);
            this.CurrentGraph = this.BaseGraph.Copy();

            var getStartProcessQuery        = new GetStartProcessQuery();
            var getProcessStartInfoQuery    = new GetProcessStartInfoQuery();
            var registerLayoutPluginCommand = new RegisterLayoutPluginCommand(getProcessStartInfoQuery, getStartProcessQuery);

            // GraphGeneration can be injected via the IGraphGeneration interface

            this.Generator = new GraphGeneration(getStartProcessQuery,
                                                 getProcessStartInfoQuery,
                                                 registerLayoutPluginCommand);

            this.FormOriginalSize = new KeyValuePair <int, int>(this.ClientSize.Width, this.ClientSize.Height);

            foreach (Control control in this.Controls)
            {
                AddControlToList(control);
            }
            listView1.Columns[0].Width = (int)Math.Floor((listView1.Width - 10) * 0.33);
            listView1.Columns[1].Width = (int)Math.Floor((listView1.Width - 10) * 0.66);
            this.FontSize = this.Font.Size;
        }
コード例 #7
0
        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));
            }
        }
コード例 #8
0
        public GraphBuilder()
        {
            var getStartProcessQuery        = new GetStartProcessQuery();
            var getProcessStartInfoQuery    = new GetProcessStartInfoQuery();
            var registerLayoutPluginCommand = new RegisterLayoutPluginCommand(getProcessStartInfoQuery, getStartProcessQuery);

            _wrapper = new GraphGeneration(getStartProcessQuery, getProcessStartInfoQuery, registerLayoutPluginCommand);
        }
コード例 #9
0
ファイル: MainViewModel.cs プロジェクト: valmac/ReactGraph
        void InitialiseDotWrapper()
        {
            var getStartProcessQuery        = new GetStartProcessQuery();
            var getProcessStartInfoQuery    = new GetProcessStartInfoQuery();
            var registerLayoutPluginCommand = new RegisterLayoutPluginCommand(getProcessStartInfoQuery, getStartProcessQuery);

            wrapper = new GraphGeneration(getStartProcessQuery, getProcessStartInfoQuery, registerLayoutPluginCommand);
        }
コード例 #10
0
        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;
        }
コード例 #11
0
ファイル: FileDotEngine.cs プロジェクト: war-man/MSSQLDIARY
        public static byte[] Jpg(string dot)
        {
            var getStartProcessQuery        = new GetStartProcessQuery();
            var getProcessStartInfoQuery    = new GetProcessStartInfoQuery();
            var registerLayoutPluginCommand = new RegisterLayoutPluginCommand(getProcessStartInfoQuery, getStartProcessQuery);
            var wrapper = new GraphGenerationWrapper(getStartProcessQuery, getProcessStartInfoQuery, registerLayoutPluginCommand, "C:\\Program Files (x86)\\Graphviz2.38\\bin");

            return(wrapper.GenerateGraph(dot, Enums.GraphReturnType.Jpg));
        }
コード例 #12
0
        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}.");
        }
コード例 #13
0
ファイル: Program.cs プロジェクト: war-man/MSSQLDIARY
        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());
        }
コード例 #14
0
        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" }));
        }
コード例 #15
0
        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);
        }
コード例 #16
0
        public GraphVizWrapperTests()
        {
            _getStartProcessQuery = new GetStartProcessQuery();

            var getProcessStartInfoQuery    = new GetProcessStartInfoQuery();
            var registerLayoutPluginCommand = new RegisterLayoutPluginCommand(getProcessStartInfoQuery, _getStartProcessQuery);

            _wrapper = new GraphGeneration(
                _getStartProcessQuery,
                getProcessStartInfoQuery,
                registerLayoutPluginCommand);
        }
コード例 #17
0
        /// <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);
        }
コード例 #18
0
        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;
            }
        }
コード例 #19
0
        /// <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);
        }
コード例 #20
0
        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);
        }
コード例 #21
0
        private void Form1_Load(object sender, EventArgs e)
        {
            this.CurrentGraph = new Graph();
            BaseGraph         = new Graph();
            var getStartProcessQuery        = new GetStartProcessQuery();
            var getProcessStartInfoQuery    = new GetProcessStartInfoQuery();
            var registerLayoutPluginCommand = new RegisterLayoutPluginCommand(getProcessStartInfoQuery, getStartProcessQuery);

            // GraphGeneration can be injected via the IGraphGeneration interface

            this.Generator = new GraphGeneration(getStartProcessQuery,
                                                 getProcessStartInfoQuery,
                                                 registerLayoutPluginCommand);
        }
コード例 #22
0
        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));
        }
コード例 #23
0
        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);
        }
コード例 #24
0
        /// <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);
        }
コード例 #25
0
        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));
        }
コード例 #26
0
        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));
        }
コード例 #27
0
        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");
        }
コード例 #28
0
ファイル: HomeController.cs プロジェクト: ostertagi/SokoSolve
        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"));
        }
コード例 #29
0
        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);
            }
        }
コード例 #30
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;
        }