Exemplo n.º 1
0
        private static void DrawIcon(Graphics g, DrawingNode node)
        {
            NodeDisplaySettings settings = node.UserData as NodeDisplaySettings;
            Image image = settings.Icon;

            if (image == null)
            {
                return;
            }

            // Flip the image around its center.
            var m     = g.Transform;
            var saveM = m.Clone();

            m.Multiply(new System.Drawing.Drawing2D.Matrix(1, 0, 0, -1, 0, 2 * (float)node.GeometryNode.Center.Y));

            g.Transform = m;

            var x = (float)(node.GeometryNode.Center.X - (node.GeometryNode.Width / 2) + (node.Attr.LabelMargin / 2));
            var y = (float)(node.GeometryNode.Center.Y - (kIconSize / 2));

            // Apply fade-out alpha to the icon.
            ColorMatrix colorMatrix = new ColorMatrix();

            colorMatrix.Matrix33 = settings.IsFadedOut ? 0.5f : 1.0f;
            ImageAttributes imageAttributes = new ImageAttributes();

            imageAttributes.SetColorMatrix(colorMatrix);

            g.DrawImage(image, new Rectangle((int)x, (int)y, kIconSize, kIconSize), 0, 0, kIconSize, kIconSize, GraphicsUnit.Pixel, imageAttributes);

            g.Transform = saveM;
        }
Exemplo n.º 2
0
        public static StringBuilder SerializeToDotFile(this IGraph graph, NodeDisplaySettings nodeSettings = null, EdgeDisplaySettings edgeSettings = null)
        {
            StringBuilder result = null;

            if (IsDirectedGraph(graph))
            {
                DirectedGraphDotFileSerializer sr = new DirectedGraphDotFileSerializer(graph);
                result = sr.Serialize();
                // TODO node & edge settings
            }
            else
            {
                UndirectedGraphDotFileSerializer sr = new UndirectedGraphDotFileSerializer();
                result = sr.Serialize(graph, nodeSettings, edgeSettings);
            }

            return(result);
        }
Exemplo n.º 3
0
        public StringBuilder Serialize(IGraph g, NodeDisplaySettings nodeSettings = null, EdgeDisplaySettings edgeSettings = null)
        {
            StringBuilder result = new StringBuilder();

            nodeDisplaySettings = nodeSettings;
            edgeDisplaySettings = edgeSettings;

            BuildTables(g);
            graph = g;

            result.Append(FilePrologue);
            result.Append(GenerateNodesElement());
            result.Append(GenerateEdgesElement());
            //stream.Write(GenerateAnnotationsElement(g));
            result.Append(FileEpilogue);

            return(result);
        }
Exemplo n.º 4
0
 public StringBuilder SerializeToDotFile(IGraph graph, NodeDisplaySettings nodeSettings = null, EdgeDisplaySettings edgeSettings = null)
 {
     return(graph.SerializeToDotFile());
 }