Smrf.NodeXL.ExcelTemplate.VertexLocationConverter.WorkbookToGraph C# (CSharp) Method

WorkbookToGraph() public method

public WorkbookToGraph ( System.Single workbookX, System.Single workbookY ) : PointF
workbookX System.Single
workbookY System.Single
return System.Drawing.PointF
    WorkbookToGraph
    (
        Single workbookX,
        Single workbookY 
    )
    {
        AssertValid();

        // The WPF y-axis increases from top to bottom, but the NodeXL y-axis
        // increases from bottom to top.  Hide this from the user by flipping
        // y-axis values here and in GraphToWorkbook().

        workbookY = MaximumXYWorkbook - workbookY;

        Single fGraphX =
            m_oGraphRectangle.Left + (workbookX - MinimumXYWorkbook) *
            m_oGraphRectangle.Width / WorkbookRange
            ;

        fGraphX = Math.Max(fGraphX, m_oGraphRectangle.Left);
        fGraphX = Math.Min(fGraphX, m_oGraphRectangle.Right);

        Single fGraphY =
            m_oGraphRectangle.Top + (workbookY - MinimumXYWorkbook) *
            m_oGraphRectangle.Height / WorkbookRange
            ;

        fGraphY = Math.Max(fGraphY, m_oGraphRectangle.Top);
        fGraphY = Math.Min(fGraphY, m_oGraphRectangle.Bottom);

        return ( new PointF(fGraphX, fGraphY) );
    }

Usage Example

コード例 #1
0
    TestWorkbookToGraph4()
    {
        // Empty rectangle.

        m_oVertexLocationConverter = new VertexLocationConverter(
            Rectangle.FromLTRB(100, 200, 100, 200) );

        Single WorkbookX = VertexLocationConverter.MaximumXYWorkbook;
        Single WorkbookY = VertexLocationConverter.MaximumXYWorkbook;
        Single ExpectedGraphX = 100;
        Single ExpectedGraphY = 200;

        PointF oGraphPointF = m_oVertexLocationConverter.WorkbookToGraph(
            WorkbookX, WorkbookY);

        Assert.AreEqual(ExpectedGraphX, oGraphPointF.X);
        Assert.AreEqual(ExpectedGraphY, oGraphPointF.Y);
    }
All Usage Examples Of Smrf.NodeXL.ExcelTemplate.VertexLocationConverter::WorkbookToGraph