示例#1
0
        public DOM.Page CreateDOMPage(Drawing layout_diagram, IVisio.Application vis)
        {
            var page_node = new DOM.Page();

            MsaglRenderer.ResolveMasters(layout_diagram, vis);

            var mg_graph = this.CreateMGGraph(layout_diagram);

            this.CreateDOMShapes(page_node.Shapes, mg_graph, vis);



            if (this.LayoutOptions.UseDynamicConnectors)
            {
                this.CreateDynamicConnectorEdges(page_node.Shapes, mg_graph);
            }
            else
            {
                this.CreateBezierEdges(page_node.Shapes, mg_graph);
            }


            // Additional Page properties
            page_node.PageCells.PlaceStyle   = 1;
            page_node.PageCells.RouteStyle   = 5;
            page_node.PageCells.AvenueSizeX  = 2.0;
            page_node.PageCells.AvenueSizeY  = 2.0;
            page_node.PageCells.LineRouteExt = 2;
            page_node.Size = this.layout_bb.Size;

            return(page_node);
        }
示例#2
0
        private static void ResolveMasters(Drawing layout_diagram, IVisio.Application app)
        {
            // for masters that are identified by their name and stencil, go find the actual master objects by
            // loading the specified stenciles

            var documents      = app.Documents;
            var master_to_size = new Dictionary <IVisio.Master, VA.Drawing.Size>();

            // Load and cache all the masters
            var loader = new Internal.MasterLoader();

            foreach (var layout_shape in layout_diagram.Shapes)
            {
                loader.Add(layout_shape.MasterName, layout_shape.StencilName);
            }
            loader.Resolve(documents);

            // If no size was provided for the shape, then set the size based on the master
            var layoutshapes_without_size_info = layout_diagram.Shapes.Where(s => s.Size == null);

            foreach (var layoutshape in layoutshapes_without_size_info)
            {
                var master = loader.Get(layoutshape.MasterName, layoutshape.StencilName);
                var size   = MsaglRenderer.TryGetValue(master_to_size, master.VisioMaster);
                if (!size.HasValue)
                {
                    var master_bb = master.VisioMaster.GetBoundingBox(IVisio.VisBoundingBoxArgs.visBBoxUprightWH);
                    size = master_bb.Size;
                    master_to_size[master.VisioMaster] = size.Value;
                }
                layoutshape.Size = size.Value;
            }
        }
示例#3
0
        public static void Render(IVisio.Page page, Drawing drawing, MsaglLayoutOptions options)
        {
            if (page == null)
            {
                throw new ArgumentNullException(nameof(page));
            }

            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            var renderer = new MsaglRenderer();

            renderer.LayoutOptions = options;
            renderer.Render(drawing, page);
            page.ResizeToFitContents(renderer.LayoutOptions.ResizeBorderWidth);
        }
示例#4
0
 public void Render(IVisio.Page page, MsaglLayoutOptions options)
 {
     MsaglRenderer.Render(page, this, options);
 }