Exemplo n.º 1
0
        public void SaveGraphToFile(StateMachineGraphData data, int width, int height, string filename)
        {
            Graph gleeGraph = CreateGraph(data);

            var renderer = new GraphRenderer(gleeGraph);

            renderer.CalculateLayout();

            var bitmap = new Bitmap(width, height, PixelFormat.Format32bppArgb);

            renderer.Render(bitmap);

            Trace.WriteLine("Saving graph to " + filename);

            bitmap.Save(filename, ImageFormat.Png);
        }
Exemplo n.º 2
0
        public Graph CreateGraph(StateMachineGraphData data)
        {
            var graph = new AdjacencyGraph <Vertex, Edge <Vertex> >();

            data.Vertices.Each(x => graph.AddVertex(x));
            data.Edges.Each(x => graph.AddEdge(new Edge <Vertex>(x.From, x.To)));

            GleeGraphPopulator <Vertex, Edge <Vertex> > glee = graph.CreateGleePopulator();

            glee.NodeAdded += NodeStyler;
            glee.EdgeAdded += EdgeStyler;
            glee.Compute();

            Graph gleeGraph = glee.GleeGraph;

            return(gleeGraph);
        }
Exemplo n.º 3
0
        public override void GetData(object target, Stream outgoingData)
        {
            if (target == null)
            {
                return;
            }

            Type targetType = target.GetType();

            if (!typeof(StateMachine).IsAssignableFrom(targetType))
            {
                return;
            }

            Type machineType = targetType.GetDeclaredGenericArguments().First();

            var args = new[] { target };

            StateMachineGraphData data =
                this.FastInvoke <StateMachineVisualizerObjectSource, StateMachineGraphData>(new[] { machineType },
                                                                                            "CreateStateMachineGraph", args);

            base.GetData(data, outgoingData);
        }
Exemplo n.º 4
0
        public static void TestShowVisualizer(StateMachineGraphData data)
        {
            var visualizerHost = new VisualizerDevelopmentHost(data, typeof(StateMachineDebugVisualizer));

            visualizerHost.ShowVisualizer();
        }