CreateLayout ( LayoutUserSettings oLayoutUserSettings ) { Debug.Assert(oLayoutUserSettings != null); AssertValid(); LayoutManager oLayoutManager = new LayoutManager(); oLayoutManager.Layout = oLayoutUserSettings.Layout; IAsyncLayout oLayout = oLayoutManager.CreateLayout(); oLayoutUserSettings.TransferToLayout(oLayout); // Don't use binning, even if the user is using binning in the // NodeXLControl. oLayout.UseBinning = false; return(oLayout); }
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); }
/// <summary> /// Activate the options that were previously set with calls to properties. /// </summary> virtual public void ActivateOptions() { // Close the current asynchronous processing. Close(); // Check the asynchronous layout. if (Layout == null) { throw new LogException(Resources.Strings.AsyncLayoutIsNull); } // Check the asynchronous strategy. if (Strategy == null) { throw new LogException(Resources.Strings.AsyncStrategyIsNull); } // Check the asynchronous target appender. if (Appender == null) { throw new LogException(Resources.Strings.AsyncAppenderIsNull); } _asyncLayout = Layout; _asyncStrategy = Strategy; _asyncAppender = Appender; // Start new asynchronous processing. _asyncStrategy.HandleItem += loggingMessage => Appender.DoAppend(loggingMessage); _asyncStrategy.HandleOverflow += bufferLimit => ErrorHandler.Error(string.Format(Resources.Strings.AsyncQueueOverflow, bufferLimit)); _asyncStrategy.StartProcessing(); // Append header. if (!string.IsNullOrEmpty(_asyncLayout.Header)) { _asyncStrategy.AddItem(_asyncLayout.Header + Environment.NewLine); } }
TransferToLayout ( IAsyncLayout asyncLayout ) { Debug.Assert(asyncLayout != null); AssertValid(); asyncLayout.Margin = this.Margin; asyncLayout.UseBinning = this.UseBinning; asyncLayout.MaximumVerticesPerBin = this.MaximumVerticesPerBin; asyncLayout.BinLength = this.BinLength; if (asyncLayout is FruchtermanReingoldLayout) { FruchtermanReingoldLayout oFruchtermanReingoldLayout = (FruchtermanReingoldLayout)asyncLayout; oFruchtermanReingoldLayout.C = this.FruchtermanReingoldC; oFruchtermanReingoldLayout.Iterations = this.FruchtermanReingoldIterations; } }
//************************************************************************* // Constructor: NodeXLControl() // /// <summary> /// Initializes a new instance of the <see cref="NodeXLControl" /> class. /// </summary> //************************************************************************* public NodeXLControl() { m_oGraph = new Graph(); m_oGraphDrawer = new GraphDrawer(this); m_oAsyncLayout = new FruchtermanReingoldLayout(); OnNewLayout(m_oAsyncLayout); m_oLastLayoutContext = new LayoutContext(System.Drawing.Rectangle.Empty); m_oLastGraphDrawingContext = null; m_eLayoutState = LayoutState.Stable; m_eMouseMode = MouseMode.Select; m_bMouseAlsoSelectsIncidentEdges = true; m_bAllowVertexDrag = true; m_oVerticesBeingDragged = null; m_oMarqueeBeingDragged = null; m_oTranslationBeingDragged = null; m_oSelectedVertices = new HashSet<IVertex>(); m_oSelectedEdges = new HashSet<IEdge>(); m_oCollapsedGroups = new Dictionary<String, IVertex>(); m_oDoubleClickedVertexInfo = null; m_bShowVertexToolTips = false; m_oLastMouseMoveLocation = new Point(-1, -1); // Create a helper object for displaying vertex tooltips. CreateVertexToolTipTracker(); m_oVertexToolTip = null; m_bGraphZoomCentered = false; this.AddLogicalChild(m_oGraphDrawer.VisualCollection); CreateTransforms(); // Prevent a focus rectangle from being drawn around the control when // it captures keyboard focus. The focus rectangle does not behave // properly when the layout and render transforms are applied -- // sometimes the rectangle disappears, and sometimes it gets magnified // by the render layout. this.FocusVisualStyle = null; // AssertValid(); }
//************************************************************************* // Method: OnNewLayout() // /// <summary> /// Performs required tasks when a new layout is used. /// </summary> /// /// <param name="oNewAsyncLayout"> /// The new layout object. /// </param> //************************************************************************* protected void OnNewLayout( IAsyncLayout oNewAsyncLayout ) { // AssertValid(); Debug.Assert(oNewAsyncLayout != null); this.VertexDrawer.LimitVerticesToBounds = !oNewAsyncLayout.SupportsOutOfBoundsVertices; oNewAsyncLayout.LayOutGraphIterationCompleted += new EventHandler(this.AsyncLayout_LayOutGraphIterationCompleted); oNewAsyncLayout.LayOutGraphCompleted += new AsyncCompletedEventHandler( this.AsyncLayout_LayOutGraphCompleted); }
//************************************************************************* // Method: TransferToLayout() // /// <summary> /// Transfers the settings to an <see cref="IAsyncLayout" /> object. /// </summary> /// /// <param name="asyncLayout"> /// Layout to transfer the settings to. /// </param> //************************************************************************* public void TransferToLayout( IAsyncLayout asyncLayout ) { Debug.Assert(asyncLayout != null); AssertValid(); asyncLayout.Margin = this.Margin; asyncLayout.UseBinning = this.UseBinning; asyncLayout.MaximumVerticesPerBin = this.MaximumVerticesPerBin; asyncLayout.BinLength = this.BinLength; if (asyncLayout is FruchtermanReingoldLayout) { FruchtermanReingoldLayout oFruchtermanReingoldLayout = (FruchtermanReingoldLayout)asyncLayout; oFruchtermanReingoldLayout.C = this.FruchtermanReingoldC; oFruchtermanReingoldLayout.Iterations = this.FruchtermanReingoldIterations; } }