This document is archived and information here might be outdated.  Recommended version.


IMapServerLayout.ToPagePoints Method (ArcObjects .NET 10.8 SDK)
ArcObjects Help for .NET developers > ArcObjects Help for .NET developers > ArcObjects namespaces > Carto > ESRI.ArcGIS.Carto > Interfaces > IM > IMapServerLayout Interface > IMapServerLayout.ToPagePoints Method
ArcGIS Developer Help

IMapServerLayout.ToPagePoints Method

Converts a screen location to a page coordinate.

[Visual Basic .NET]
Public Function ToPagePoints ( _
    ByVal pageExtent As IEnvelope, _
    ByVal pageDisplay As IImageDisplay, _
    ByVal screenXValues As ILongArray, _
    ByVal screenYValues As ILongArray _
) As IPointCollection
[C#]
public IPointCollection ToPagePoints (
    IEnvelope pageExtent,
    IImageDisplay pageDisplay,
    ILongArray screenXValues,
    ILongArray screenYValues
);
[C++]
HRESULT ToPagePoints(
  IEnvelope* pageExtent,
  IImageDisplay* pageDisplay,
  ILongArray* screenXValues,
  ILongArray* screenYValues
);
[C++]
Parameters
pageExtent [in]

pageExtent is a parameter of type IEnvelope* pageDisplay [in]
pageDisplay is a parameter of type IImageDisplay* screenXValues [in]
screenXValues is a parameter of type ILongArray* screenYValues [in]
screenYValues is a parameter of type ILongArray*

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Remarks

Use ToPagePoints to convert pixel coordinates on the screen to page units coordinates on the layout.

[C#]

The following sample code shows how to convert the lower left corner of your layout image (screen location) to page coordinates. It assumes that you already have a valid MapServerLayout and PageDescription object, and that you are not working with a server context. However, if you are developing an ArcGIS for Server application using a server context, you should not use New to create local ArcObjects, but you should always create objects within the server by calling CreateObject on IServerContext.

IMapServerLayout mapServerLayout;
IPageDescription pageDesc;

// Create image display
IImageDisplay imageDisp = new ImageDisplayClass();
imageDisp.Height = 550;
imageDisp.Width = 425;

// Get page extent
IEnvelope pageExtent = pageDesc.Extent ;

// Get screen location (lower left corner of image)
ILongArray screenXValues = new LongArrayClass();
ILongArray screenYValues = new LongArrayClass();
screenXValues.Add(0);
// Be aware that origin of screen coordinate system is upper left corner!
screenYValues.Add(550);

// Convert screen location to page coordinates
IPointCollection pointCollection;
pointCollection = mapServerLayout.ToPagePoints(pageExtent, imageDisp, screenXValues, screenYValues);
IPoint point = pointCollection.get_Point(0);

// Please note:
// 1. Origin of screen coordinate system is upper left corner
// 2. If aspect ratio of requested layout image is different from aspect ratio of
// input map layout, requested layout image will be adjusted to fit
// input map layout -> following screen locations are not necessarily 0:
MessageBox.Show(point.X.ToString());
MessageBox.Show(point.Y.ToString());

See Also

IMapServerLayout Interface