public void SetUp()
        {
            m_oGraph = new Graph();

            Rectangle oRectangle = new Rectangle(21, 34, 56, 78);

            m_oLayoutContext = new LayoutContext(oRectangle);

            m_oLayOutGraphAsyncArguments =
            new LayOutGraphAsyncArguments(m_oGraph, m_oLayoutContext);
        }
Esempio n. 2
0
        LayOutGraphOnBackgroundWorker
        (
            BackgroundWorker oBackgroundWorker,
            DoWorkEventArgs oDoWorkEventArgs
        )
        {
            Debug.Assert(oBackgroundWorker != null);
            Debug.Assert(oDoWorkEventArgs != null);
            AssertValid();

            Debug.Assert(oDoWorkEventArgs.Argument is LayOutGraphAsyncArguments);

            LayOutGraphAsyncArguments oLayOutGraphAsyncArguments =
                (LayOutGraphAsyncArguments)oDoWorkEventArgs.Argument;

            IGraph oGraph = oLayOutGraphAsyncArguments.Graph;

            LayoutContext oLayoutContext =
                oLayOutGraphAsyncArguments.LayoutContext;

            LayoutContext oAdjustedLayoutContext;

            if (!GetAdjustedLayoutContext(oGraph, oLayoutContext,
                                          out oAdjustedLayoutContext))
            {
                return;
            }

            // Honor the optional LayOutTheseVerticesOnly key on the graph.

            ICollection <IVertex> oVerticesToLayOut = GetVerticesToLayOut(oGraph);
            Int32 iVerticesToLayOut = oVerticesToLayOut.Count;

            if (iVerticesToLayOut == 0)
            {
                return;
            }

            // Binning is supported only if the entire graph is being laid out.

            if (this.SupportsBinning && m_bUseBinning &&
                iVerticesToLayOut == oGraph.Vertices.Count)
            {
                // Lay out the graph's smaller components in bins.

                GraphBinner oGraphBinner = new GraphBinner();
                oGraphBinner.MaximumVerticesPerBin = m_iMaximumVerticesPerBin;
                oGraphBinner.BinLength             = m_iBinLength;

                ICollection <IVertex> oRemainingVertices;
                Rectangle             oRemainingRectangle;

                if (oGraphBinner.LayOutSmallerComponentsInBins(oGraph,
                                                               oVerticesToLayOut, oAdjustedLayoutContext,
                                                               out oRemainingVertices, out oRemainingRectangle))
                {
                    // The remaining vertices need to be laid out in the remaining
                    // rectangle.

                    oVerticesToLayOut = oRemainingVertices;

                    oAdjustedLayoutContext =
                        new LayoutContext(oRemainingRectangle);
                }
                else
                {
                    // There are no remaining vertices, or there is no space
                    // left.

                    oVerticesToLayOut = new IVertex[0];
                }
            }

            if (oVerticesToLayOut.Count > 0)
            {
                // Let the derived class do the work.

                if (!LayOutGraphCore(oGraph, oVerticesToLayOut,
                                     oAdjustedLayoutContext, oBackgroundWorker))
                {
                    // LayOutGraphAsyncCancel() was called.

                    oDoWorkEventArgs.Cancel = true;
                    return;
                }

                LayoutMetadataUtil.MarkGraphAsLaidOut(oGraph);
            }
        }
 public void TearDown()
 {
     m_oLayOutGraphAsyncArguments = null;
     m_oGraph = null;
     m_oLayoutContext = null;
 }
 //*************************************************************************
 //  Constructor: LayOutGraphAsyncArgumentsTest()
 //
 /// <summary>
 /// Initializes a new instance of the
 /// <see cref="LayOutGraphAsyncArgumentsTest" /> class.
 /// </summary>
 //*************************************************************************
 public LayOutGraphAsyncArgumentsTest()
 {
     m_oLayOutGraphAsyncArguments = null;
     m_oGraph = null;
     m_oLayoutContext = null;
 }