Class ViewportExtensions
Inherited Members
Namespace: Mapsui.Extensions
Assembly: Mapsui.dll
Syntax
public static class ViewportExtensions
Methods
| Edit this page View SourceHasSize(Viewport)
True if Width and Height are not zero
Declaration
public static bool HasSize(this Viewport viewport)
Parameters
Type | Name | Description |
---|---|---|
Viewport | viewport |
Returns
Type | Description |
---|---|
bool |
IsRotated(Viewport)
IsRotated is true, when viewport displays map rotated
Declaration
public static bool IsRotated(this Viewport viewport)
Parameters
Type | Name | Description |
---|---|---|
Viewport | viewport |
Returns
Type | Description |
---|---|
bool |
ScreenToWorld(Viewport, MPoint)
Converts a point in screen pixels to one in screen units, respecting rotation
Declaration
public static MPoint ScreenToWorld(this Viewport viewport, MPoint screenPosition)
Parameters
Type | Name | Description |
---|---|---|
Viewport | viewport | |
MPoint | screenPosition | Coordinate in screen units |
Returns
Type | Description |
---|---|
MPoint | MPoint in world units |
ScreenToWorld(Viewport, double, double)
Converts X/Y in screen pixels to a point in screen units, respecting rotation
Declaration
public static MPoint ScreenToWorld(this Viewport viewport, double screenX, double screenY)
Parameters
Type | Name | Description |
---|---|---|
Viewport | viewport | |
double | screenX | |
double | screenY |
Returns
Type | Description |
---|---|
MPoint | MPoint in world units |
ScreenToWorldXY(Viewport, double, double)
Converts X/Y in screen pixels to a point in screen units, respecting rotation
Declaration
public static (double worldX, double worldY) ScreenToWorldXY(this Viewport viewport, double screenX, double screenY)
Parameters
Type | Name | Description |
---|---|---|
Viewport | viewport | |
double | screenX | |
double | screenY |
Returns
Type | Description |
---|---|
(double x, double y) | Tuple of x and y in world coordinates |
ToExtent(Viewport)
Calculates extent from the viewport.
Declaration
public static MRect ToExtent(this Viewport viewport)
Parameters
Type | Name | Description |
---|---|---|
Viewport | viewport |
Returns
Type | Description |
---|---|
MRect |
Remarks
This MRect is horizontally and vertically aligned, even if the viewport is rotated. So this MRect perhaps contain parts, that are not visible.
ToSection(Viewport)
IsRotated is true, when viewport displays map rotated
Declaration
public static MSection ToSection(this Viewport viewport)
Parameters
Type | Name | Description |
---|---|---|
Viewport | viewport |
Returns
Type | Description |
---|---|
MSection |
WorldToScreen(Viewport, MPoint)
Converts X/Y in world units to a point in device independent unit (or DIP or DP), respecting rotation
Declaration
public static MPoint WorldToScreen(this Viewport viewport, MPoint worldPosition)
Parameters
Type | Name | Description |
---|---|---|
Viewport | viewport | |
MPoint | worldPosition | Coordinate in world units |
Returns
Type | Description |
---|---|
MPoint | MPoint in screen pixels |
WorldToScreen(Viewport, MRect)
Transforms the MRect from world coordinates to screen coordinates. Note, that an MRect always represents and unrotated box. If the Viewport is rotated this will result in an unrotated box that encompasses the rotated transformation.
Declaration
public static MRect WorldToScreen(this Viewport viewport, MRect rect)
Parameters
Type | Name | Description |
---|---|---|
Viewport | viewport | Viewport |
MRect | rect | The MRect to transform |
Returns
Type | Description |
---|---|
MRect | Transformed rect |
WorldToScreen(Viewport, double, double)
Converts X/Y in world units to a point in device independent units (or DIP or DP), respecting rotation
Declaration
public static MPoint WorldToScreen(this Viewport viewport, double worldX, double worldY)
Parameters
Type | Name | Description |
---|---|---|
Viewport | viewport | |
double | worldX | X coordinate in world units |
double | worldY | Y coordinate in world units |
Returns
Type | Description |
---|---|
MPoint | MPoint in screen pixels |
WorldToScreenXY(Viewport, double, double)
Converts X/Y in world units to a point in device independent units (or DIP or DP), respecting rotation
Declaration
public static (double screenX, double screenY) WorldToScreenXY(this Viewport viewport, double worldX, double worldY)
Parameters
Type | Name | Description |
---|---|---|
Viewport | viewport | |
double | worldX | X coordinate in world units |
double | worldY | Y coordinate in world units |
Returns
Type | Description |
---|---|
(double x, double y) | Tuple of x and y in screen coordinates |