CreateNodeXLVisual ( GeneralUserSettings oGeneralUserSettings ) { Debug.Assert(oGeneralUserSettings != null); AssertValid(); NodeXLVisual oNodeXLVisual = new NodeXLVisual(); GraphDrawer oGraphDrawer = oNodeXLVisual.GraphDrawer; VertexDrawer oVertexDrawer = oGraphDrawer.VertexDrawer; EdgeDrawer oEdgeDrawer = oGraphDrawer.EdgeDrawer; oGeneralUserSettings.TransferToGraphDrawer(oGraphDrawer); // Override some of the user's settings. oVertexDrawer.Shape = VertexShape.Disk; oVertexDrawer.Radius = 2.0; oEdgeDrawer.Width = 1; oEdgeDrawer.SelectedWidth = 1; return(oNodeXLVisual); }
CreateSubgraphImage ( IGraph oSubgraph, CreateSubgraphImagesAsyncArgs oCreateSubgraphImagesAsyncArgs, Size oImageSizePx ) { Debug.Assert(oSubgraph != null); Debug.Assert(oCreateSubgraphImagesAsyncArgs != null); AssertValid(); Rectangle oSubgraphRectangle = new Rectangle(new Point(0, 0), oImageSizePx); // Lay out the graph, then draw it using the NodeXLVisual object. IAsyncLayout oLayout = oCreateSubgraphImagesAsyncArgs.Layout; oLayout.LayOutGraph(oSubgraph, new LayoutContext(oSubgraphRectangle)); NodeXLVisual oNodeXLVisual = oCreateSubgraphImagesAsyncArgs.NodeXLVisual; GraphDrawingContext oGraphDrawingContext = CreateGraphDrawingContext(oSubgraphRectangle, oLayout.Margin, oCreateSubgraphImagesAsyncArgs.GeneralUserSettings); oNodeXLVisual.GraphDrawer.DrawGraph(oSubgraph, oGraphDrawingContext); // Save the graph to a bitmap. Bitmap oBitmap = WpfGraphicsUtil.VisualToBitmap(oNodeXLVisual, oSubgraphRectangle.Width, oSubgraphRectangle.Height); return(oBitmap); }