Example #1
0
        private void CreateBezierEdges(DOM.ShapeList domshapes, MG.Core.Layout.GeometryGraph mg_graph)
        {
            // DRAW EDGES WITH BEZIERS
            foreach (var mg_edge in mg_graph.Edges)
            {
                var ud = (NodeUserData)mg_edge.UserData;
                var layoutconnector = ud.Connector;
                var vconnector      = this.draw_edge_bezier(mg_edge);
                layoutconnector.DOMNode = vconnector;
                domshapes.Add(vconnector);
            }

            foreach (var mg_edge in mg_graph.Edges)
            {
                var ud = (NodeUserData)mg_edge.UserData;
                var layout_connector = ud.Connector;

                if (layout_connector.Cells != null)
                {
                    var bezier_node = (DOM.BezierCurve)layout_connector.DOMNode;
                    bezier_node.Cells = layout_connector.Cells.ShallowCopy();
                }
            }

            foreach (var mg_edge in mg_graph.Edges)
            {
                var ud = (NodeUserData)mg_edge.UserData;
                var layout_connector = ud.Connector;

                if (!string.IsNullOrEmpty(layout_connector.Label))
                {
                    // this is a bezier connector
                    // draw a manual box instead
                    var label_bb = this.ToDocumentCoordinates(Internal.MsaglUtil.ToVARectangle(mg_edge.Label.BoundingBox));
                    var vshape   = new DOM.Rectangle(label_bb);
                    domshapes.Add(vshape);

                    vshape.Cells = this.DefaultBezierConnectorShapeCells.ShallowCopy();
                    vshape.Text  = new Text.Markup.TextElement(layout_connector.Label);
                }
            }
        }
Example #2
0
        private void CreateDynamicConnectorEdges(DOM.ShapeList shape_nodes, MG.Core.Layout.GeometryGraph mg_graph)
        {
            // CREATE EDGES
            foreach (var edge in mg_graph.Edges)
            {
                var ud = (NodeUserData)edge.UserData;
                var layout_connector = ud.Connector;

                VisioAutomation.DOM.Connector vconnector;
                if (layout_connector.MasterName != null && layout_connector.StencilName != null)
                {
                    vconnector = new VA.DOM.Connector(
                        layout_connector.From.DOMNode,
                        layout_connector.To.DOMNode, layout_connector.MasterName, layout_connector.StencilName);
                }
                else
                {
                    vconnector = new VA.DOM.Connector(
                        layout_connector.From.DOMNode,
                        layout_connector.To.DOMNode, "Dynamic Connector", "connec_u.vss");
                }
                layout_connector.DOMNode = vconnector;
                shape_nodes.Add(vconnector);
            }

            foreach (var edge in mg_graph.Edges)
            {
                var ud = (NodeUserData)edge.UserData;
                var layoutconnector = ud.Connector;

                var vconnector = (DOM.Connector)layoutconnector.DOMNode;

                int con_route_style   = (int)this.ConnectorTypeToCellVal_Appearance(layoutconnector.ConnectorType);
                int shape_route_style = (int)this.ConnectorTypeToCellVal_Style(layoutconnector.ConnectorType);

                vconnector.Text = new Text.Markup.TextElement(layoutconnector.Label);

                vconnector.Cells = layoutconnector.Cells != null?
                                   layoutconnector.Cells.ShallowCopy()
                                       : new DOM.ShapeCells();

                vconnector.Cells.ConLineRouteExt = con_route_style;
                vconnector.Cells.ShapeRouteStyle = shape_route_style;
            }
        }
Example #3
0
        private void CreateDOMShapes(DOM.ShapeList domshapeslist, MG.Core.Layout.GeometryGraph mg_graph, IVisio.Application app)
        {
            var node_centerpoints = mg_graph.Nodes
                                    .Select(n => this.ToDocumentCoordinates(Internal.MsaglUtil.ToVAPoint(n.Center)))
                                    .ToArray();

            // Load up all the stencil docs
            var app_documents = app.Documents;
            var uds           = mg_graph.Nodes.Where(n => n.UserData != null).Select(n => (NodeUserData)n.UserData).ToList();
            var shapes        = uds.Where(ud => ud.Shape != null).Select(ud => ud.Shape).ToList();
            var stencilnames0 = shapes.Select(s => s.StencilName).ToList();
            var stencil_names = stencilnames0.Distinct().ToList();

            var compare = StringComparer.InvariantCultureIgnoreCase;

            var stencil_map = new Dictionary <string, IVisio.Document>(compare);

            foreach (var stencil_name in stencil_names)
            {
                if (!stencil_map.ContainsKey(stencil_name))
                {
                    var stencil = app_documents.OpenStencil(stencil_name);
                    stencil_map[stencil_name] = stencil;
                }
            }

            var master_map = new Dictionary <string, IVisio.Master>(compare);

            foreach (var nv in shapes)
            {
                var key = nv.StencilName + "+" + nv.MasterName;
                if (!master_map.ContainsKey(key))
                {
                    var stencil = stencil_map[nv.StencilName];
                    var masters = stencil.Masters;
                    var master  = masters[nv.MasterName];
                    master_map[key] = master;
                }
            }

            // Create DOM Shapes for each AutoLayoutShape

            int count = 0;

            foreach (var layout_shape in shapes)
            {
                var key        = layout_shape.StencilName.ToLower() + "+" + layout_shape.MasterName;
                var master     = master_map[key];
                var shape_node = new DOM.Shape(master, node_centerpoints[count]);
                layout_shape.DOMNode = shape_node;
                domshapeslist.Add(shape_node);
                count++;
            }

            // FORMAT EACH SHAPE
            foreach (var n in mg_graph.Nodes)
            {
                var ud           = (NodeUserData)n.UserData;
                var layout_shape = ud.Shape;
                if (layout_shape != null)
                {
                    this.format_shape(layout_shape, layout_shape.DOMNode);
                }
            }
        }