WorkbookToGraph() public method

public WorkbookToGraph ( System.Single workbookX, System.Single workbookY ) : PointF
workbookX System.Single
workbookY System.Single
return System.Drawing.PointF
    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);
    }
Ejemplo n.º 2
0
        TryGetLocation
        (
            ExcelTableReader.ExcelTableRow oRow,
            String sXColumnName,
            String sYColumnName,
            VertexLocationConverter oVertexLocationConverter,
            out PointF oLocation
        )
        {
            Debug.Assert(oRow != null);
            Debug.Assert(!String.IsNullOrEmpty(sXColumnName));
            Debug.Assert(!String.IsNullOrEmpty(sYColumnName));
            Debug.Assert(oVertexLocationConverter != null);
            AssertValid();

            oLocation = PointF.Empty;

            String sX, sY;

            Boolean bHasX = oRow.TryGetNonEmptyStringFromCell(
                sXColumnName, out sX);

            Boolean bHasY = oRow.TryGetNonEmptyStringFromCell(
                sYColumnName, out sY);

            if (bHasX != bHasY)
            {
                // X or Y alone won't do.

                goto Error;
            }

            if (!bHasX && !bHasY)
            {
                return(false);
            }

            Single fX, fY;

            if (!Single.TryParse(sX, out fX) || !Single.TryParse(sY, out fY))
            {
                goto Error;
            }

            // Transform the location from workbook coordinates to graph
            // coordinates.

            oLocation = oVertexLocationConverter.WorkbookToGraph(fX, fY);

            return(true);

Error:

            Range oInvalidCell = oRow.GetRangeForCell(sXColumnName);

            OnWorkbookFormatError(String.Format(

                                      "There is a problem with the location at {0}.  If you enter a"
                                      + " location, it must include both X and Y numbers.  Any"
                                      + " numbers are acceptable, although {1} is used for any"
                                      + " number less than {1} and and {2} is used for any number"
                                      + " greater than {2}."
                                      ,
                                      ExcelUtil.GetRangeAddress(oInvalidCell),

                                      VertexLocationConverter.MinimumXYWorkbook.ToString(
                                          ExcelTemplateForm.Int32Format),

                                      VertexLocationConverter.MaximumXYWorkbook.ToString(
                                          ExcelTemplateForm.Int32Format)
                                      ),

                                  oInvalidCell
                                  );

            // Make the compiler happy.

            return(false);
        }
    TryGetLocation
    (
        ExcelTableReader.ExcelTableRow oRow,
        String sXColumnName,
        String sYColumnName,
        VertexLocationConverter oVertexLocationConverter,
        out PointF oLocation
    )
    {
        Debug.Assert(oRow != null);
        Debug.Assert( !String.IsNullOrEmpty(sXColumnName) );
        Debug.Assert( !String.IsNullOrEmpty(sYColumnName) );
        Debug.Assert(oVertexLocationConverter != null);
        AssertValid();

        oLocation = PointF.Empty;

        String sX, sY;

        Boolean bHasX = oRow.TryGetNonEmptyStringFromCell(
            sXColumnName, out sX);

        Boolean bHasY = oRow.TryGetNonEmptyStringFromCell(
            sYColumnName, out sY);

        if (bHasX != bHasY)
        {
            // X or Y alone won't do.

            goto Error;
        }

        if (!bHasX && !bHasY)
        {
            return (false);
        }

        Single fX, fY;

        if ( !Single.TryParse(sX, out fX) || !Single.TryParse(sY, out fY) )
        {
            goto Error;
        }

        // Transform the location from workbook coordinates to graph
        // coordinates.

        oLocation = oVertexLocationConverter.WorkbookToGraph(fX, fY);

        return (true);

        Error:

            Range oInvalidCell = oRow.GetRangeForCell(sXColumnName);

            OnWorkbookFormatError( String.Format(

                "There is a problem with the location at {0}.  If you enter a"
                + " location, it must include both X and Y numbers.  Any"
                + " numbers are acceptable, although {1} is used for any"
                + " number less than {1} and and {2} is used for any number"
                + " greater than {2}."
                ,
                ExcelUtil.GetRangeAddress(oInvalidCell),

                VertexLocationConverter.MinimumXYWorkbook.ToString(
                    ExcelTemplateForm.Int32Format),

                VertexLocationConverter.MaximumXYWorkbook.ToString(
                    ExcelTemplateForm.Int32Format)
                ),

                oInvalidCell
                );

            // Make the compiler happy.

            return (false);
    }