public void DOM_CustomProperties() { // Create the doc var shape_nodes = new VA.DOM.ShapeList(); var vrect1 = new VA.DOM.Rectangle(1, 1, 9, 9); vrect1.Text = new VA.Text.Markup.TextElement("HELLO WORLD"); vrect1.CustomProperties = new Dictionary<string, VA.Shapes.CustomProperties.CustomPropertyCells>(); var cp1 = new VA.Shapes.CustomProperties.CustomPropertyCells(); cp1.Value = "FOOVALUE"; cp1.Label = "Foo Label"; var cp2 = new VA.Shapes.CustomProperties.CustomPropertyCells(); cp2.Value = "BARVALUE"; cp2.Label = "Bar Label"; vrect1.CustomProperties["FOO"] = cp1; vrect1.CustomProperties["BAR"] = cp2; shape_nodes.Add(vrect1); // Render it var app = this.GetVisioApplication(); var doc = this.GetNewDoc(); shape_nodes.Render(app.ActivePage); // Verify Assert.IsNotNull(vrect1.VisioShape); Assert.AreEqual("HELLO WORLD", vrect1.VisioShape.Text); Assert.IsTrue(VA.Shapes.CustomProperties.CustomPropertyHelper.Contains(vrect1.VisioShape, "FOO")); Assert.IsTrue(VA.Shapes.CustomProperties.CustomPropertyHelper.Contains(vrect1.VisioShape, "BAR")); doc.Close(true); }
private void CreateDynamicConnectorEdges(VA.DOM.ShapeList shape_nodes, MG.GeometryGraph msagl_graph) { // CREATE EDGES foreach (var i in msagl_graph.Edges) { var layoutconnector = (DGMODEL.Connector)i.UserData; var vconnector = new VA.DOM.Connector( layoutconnector.From.DOMNode, layoutconnector.To.DOMNode, "Dynamic Connector", "connec_u.vss"); layoutconnector.DOMNode = vconnector; shape_nodes.Add(vconnector); } var edge_pairs = from n in msagl_graph.Edges let lc = (DGMODEL.Connector)n.UserData select new { msagl_edge = n, layout_connector = lc, vconnector = (VA.DOM.Connector)lc.DOMNode }; foreach (var i in edge_pairs) { int con_route_style = (int)ConnectorTypeToCellVal_Appearance(i.layout_connector.ConnectorType); int shape_route_style = (int)ConnectorTypeToCellVal_Style(i.layout_connector.ConnectorType); i.vconnector.Text = new VA.Text.Markup.TextElement(i.layout_connector.Label); i.vconnector.Cells = i.layout_connector.Cells != null? i.layout_connector.Cells.ShallowCopy() : new VA.DOM.ShapeCells(); i.vconnector.Cells.ConLineRouteExt = con_route_style; i.vconnector.Cells.ShapeRouteStyle = shape_route_style; } }
private void CreateBezierEdges(VA.DOM.ShapeList domshapes, MG.GeometryGraph msagl_graph) { // DRAW EDGES WITH BEZIERS foreach (var msagl_edge in msagl_graph.Edges) { var layoutconnector = (DGMODEL.Connector)msagl_edge.UserData; var vconnector = draw_edge_bezier(domshapes, layoutconnector, msagl_edge); layoutconnector.DOMNode = vconnector; domshapes.Add(vconnector); } var edge_pairs = from n in msagl_graph.Edges let lc = (DGMODEL.Connector)n.UserData select new { msagl_edge = n, layout_connector = lc, bezier_node = (VA.DOM.BezierCurve)lc.DOMNode }; foreach (var i in edge_pairs) { if (i.layout_connector.Cells != null) { i.bezier_node.Cells = i.layout_connector.Cells.ShallowCopy(); } } foreach (var i in edge_pairs.Where(item => !string.IsNullOrEmpty(item.layout_connector.Label))) { // this is a bezier connector // draw a manual box instead var label_bb = ToDocumentCoordinates(VA.Internal.MSAGLUtil.ToVARectangle(i.msagl_edge.Label.BoundingBox)); var vshape = new VA.DOM.Rectangle(label_bb); domshapes.Add(vshape); vshape.Cells = DefaultBezierConnectorShapeCells.ShallowCopy(); vshape.Text = new VA.Text.Markup.TextElement(i.layout_connector.Label); } }
public void DOM_CustomProperties() { // Create the doc var shape_nodes = new VA.DOM.ShapeList(); var vrect1 = new VisioAutomation.DOM.Rectangle(1, 1, 9, 9); vrect1.Text = new VA.Text.Markup.TextElement("HELLO WORLD"); vrect1.CustomProperties = new Dictionary <string, VA.Shapes.CustomProperties.CustomPropertyCells>(); var cp1 = new VA.Shapes.CustomProperties.CustomPropertyCells(); cp1.Value = "FOOVALUE"; cp1.Label = "Foo Label"; var cp2 = new VA.Shapes.CustomProperties.CustomPropertyCells(); cp2.Value = "BARVALUE"; cp2.Label = "Bar Label"; vrect1.CustomProperties["FOO"] = cp1; vrect1.CustomProperties["BAR"] = cp2; shape_nodes.Add(vrect1); // Render it var app = this.GetVisioApplication(); var doc = this.GetNewDoc(); shape_nodes.Render(app.ActivePage); // Verify Assert.IsNotNull(vrect1.VisioShape); Assert.AreEqual("HELLO WORLD", vrect1.VisioShape.Text); Assert.IsTrue(VA.Shapes.CustomProperties.CustomPropertyHelper.Contains(vrect1.VisioShape, "FOO")); Assert.IsTrue(VA.Shapes.CustomProperties.CustomPropertyHelper.Contains(vrect1.VisioShape, "BAR")); doc.Close(true); }
private void CreateDOMShapes(VA.DOM.ShapeList domshapeslist, MG.GeometryGraph msagl_graph, IVisio.Application app) { var node_centerpoints = msagl_graph.NodeMap.Values .Select(n => ToDocumentCoordinates(VA.Internal.MSAGLUtil.ToVAPoint(n.Center))) .ToArray(); // Load up all the stencil docs var app_documents = app.Documents; var nodes = msagl_graph.NodeMap.Values.Select(get_shape); var stencil_names = nodes.Select(s => s.StencilName.ToUpper()).Distinct().ToList(); var stencil_map = new Dictionary <string, IVisio.Document>(); 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>(); foreach (var nv in nodes) { var key = nv.StencilName.ToLower() + "+" + nv.MasterName; if (!master_map.ContainsKey(key)) { var stencil = stencil_map[nv.StencilName.ToUpper()]; 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 nodes) { var key = layout_shape.StencilName.ToLower() + "+" + layout_shape.MasterName; var master = master_map[key]; var shape_node = new VA.DOM.Shape(master, node_centerpoints[count]); layout_shape.DOMNode = shape_node; domshapeslist.Add(shape_node); count++; } var shape_pairs = from n in msagl_graph.NodeMap.Values let layout_shape = (DGMODEL.Shape)n.UserData select new { layout_shape, shape_node = (VA.DOM.BaseShape)layout_shape.DOMNode }; // FORMAT EACH SHAPE foreach (var i in shape_pairs) { format_shape(i.layout_shape, i.shape_node); } }