DrawingVisualGeoCanvas¶
Namespace: ThinkGeo.Core
This class represents a canvas that is used to draw geographic shapes. It is intended to be inherited for the implementation of drawing visual systems.
public class DrawingVisualGeoCanvas : GeoCanvas
Inheritance Object → GeoCanvas → DrawingVisualGeoCanvas
Properties¶
Dpi¶
The DPI value for the final drawing result, only valid when HasDpi set to true.
public float Dpi { get; set; }
Property Value¶
CurrentScale¶
public double CurrentScale { get; }
Property Value¶
FontDisplayDensity¶
public double FontDisplayDensity { get; }
Property Value¶
DrawingQuality¶
public DrawingQuality DrawingQuality { get; set; }
Property Value¶
DrawingQuality
MapUnit¶
public GeographyUnit MapUnit { get; }
Property Value¶
GeographyUnit
Width¶
public float Width { get; protected set; }
Property Value¶
Height¶
public float Height { get; protected set; }
Property Value¶
CurrentWorldExtent¶
public RectangleShape CurrentWorldExtent { get; protected set; }
Property Value¶
RectangleShape
SupportKeyColor¶
public bool SupportKeyColor { get; }
Property Value¶
KeyColors¶
public Collection<GeoColor> KeyColors { get; }
Property Value¶
NativeImage¶
public object NativeImage { get; }
Property Value¶
IsDrawing¶
public bool IsDrawing { get; protected set; }
Property Value¶
ScaleFactor¶
public float ScaleFactor { get; set; }
Property Value¶
CancellationTokenSource¶
public CancellationTokenSource CancellationTokenSource { get; set; }
Property Value¶
ClippingArea¶
public RectangleShape ClippingArea { get; set; }
Property Value¶
RectangleShape
Constructors¶
DrawingVisualGeoCanvas()¶
Constructor of DrawingVisualGeoCanvas.
public DrawingVisualGeoCanvas()
Methods¶
BeginDrawingCore(Object, RectangleShape, GeographyUnit)¶
This method converts a NativeImage to a commonly-used object. In GdiPlus, this object is often an Image control in Wpf.
protected void BeginDrawingCore(object nativeImage, RectangleShape worldExtent, GeographyUnit drawingMapUnit)
Parameters¶
nativeImage
Object
worldExtent
RectangleShape
drawingMapUnit
GeographyUnit
EndDrawingCore()¶
This method ends drawing and commits the drawing on the GeoCanvas.
protected void EndDrawingCore()
DrawAreaCore(IEnumerable<ScreenPointF[]>, GeoPen, GeoBrush, DrawingLevel, Single, Single, PenBrushDrawingOrder)¶
This method draws the area on the GeoCanvas.
protected void DrawAreaCore(IEnumerable<ScreenPointF[]> screenPoints, GeoPen outlinePen, GeoBrush fillBrush, DrawingLevel drawingLevel, float xOffset, float yOffset, PenBrushDrawingOrder penBrushDrawingOrder)
Parameters¶
screenPoints
IEnumerable<ScreenPointF[]>
This parameter is the area point in screen coordinates.
outlinePen
GeoPen
This parameter describes the outline GeoPen that will be used to draw the area.
fillBrush
GeoBrush
This parameter describes the GeoBrush that will be used to draw the area.
drawingLevel
DrawingLevel
This parameter determines the level for drawing.
xOffset
Single
This parameter determines the X offset for the area to be drawn.
yOffset
Single
This parameter determines the Y offset for the area to be drawn.
penBrushDrawingOrder
PenBrushDrawingOrder
This parameter determines pen and brush drawing order.
Exceptions¶
InvalidOperationException
In the event you attempt to call this method when the GeoCanvas' IsDrawing mode is false, it will throw an InvalidOperationException.
ArgumentException
Passing invalid well-known binary in the areaShapeWkb parameter will throw an ArgumentException.
ArgumentNullException
If you pass a null as the areaShapeWkb, we will throw an ArgumentNullException.
ArgumentNullException
If you pass a null as the outlinePen and a null as the fillBrush, we will throw an ArgumentNullException.
ArgumentOutOfRangeException
If you pass in a drawingLevel that is not defined in the enumeration, it will throw an ArgumentOutOfRangeException.
Remarks:
This method is used to draw on the GeoCanvas. It provides you with a number of overloads that allow you to control how things are drawn. Specify the GeoBrush to fill in an area. Specify the GeoPen to outline an area using that GeoPen. You can also call an overload that will allow you to specify both a GeoPen and a GeoBrush.
The DrawingLevel allows you to specify the level you will draw on when you are drawing multiple areas. This is very useful when you want to draw a drop shadow, for example. In that case, you could draw the black backdrop on the lowest level with an offset, then draw the normal shape on a higher level without an offset.
DrawLineCore(IEnumerable<ScreenPointF>, GeoPen, DrawingLevel, Single, Single)¶
Draws a LineShape on the GeoCanvas.
protected void DrawLineCore(IEnumerable<ScreenPointF> screenPoints, GeoPen linePen, DrawingLevel drawingLevel, float xOffset, float yOffset)
Parameters¶
screenPoints
IEnumerable<ScreenPointF>
This parameter represents the line points in screen coordinates.
linePen
GeoPen
This parameter describes the GeoPen that will be used to draw the LineShape.
drawingLevel
DrawingLevel
This parameter determines the DrawingLevel that the GeoPen will draw on.
xOffset
Single
This parameter determines the X offset for the line to be drawn.
yOffset
Single
This parameter determines the Y offset for the line to be drawn.
Exceptions¶
InvalidOperationException
In the event you attempt to call this method when the GeoCanvas' IsDrawing mode is false, it will throw an InvalidOperationException.
ArgumentException
Passing invalid well-known binary in the lineShapeWkb parameter will throw an ArgumentException.
ArgumentNullException
If you pass a null as the lineShapeWkb, we will throw an ArgumentNullException.
ArgumentNullException
If you pass a null as the linePen, we will throw an ArgumentNullException.
ArgumentOutOfRangeException
If you pass in a drawingLevel that is not defined in the enumeration, it will throw an ArgumentOutOfRangeException.
Remarks:
This method is used to draw a line on the GeoCanvas using the specified GeoPen.
The DrawingLevel allows you to specify the level you will draw on when drawing multiple lines. This is very useful when you want to draw a road, for example. You can draw the black background on the lowest level, then draw a slightly thinner white line on a higher level. This will result in a great effect for a road.
DrawEllipseCore(ScreenPointF, Single, Single, GeoPen, GeoBrush, DrawingLevel, Single, Single, PenBrushDrawingOrder)¶
Draws the point on the GeoCanvas.
protected void DrawEllipseCore(ScreenPointF screenPoint, float width, float height, GeoPen outlinePen, GeoBrush fillBrush, DrawingLevel drawingLevel, float xOffset, float yOffset, PenBrushDrawingOrder penBrushDrawingOrder)
Parameters¶
screenPoint
ScreenPointF
This parameter is the point in screen coordinates.
width
Single
This parameter describes the width of the ellipse to be drawn.
height
Single
This parameter describes the height of the ellipse to be drawn.
outlinePen
GeoPen
This parameter describes the outline GeoPen that will be used to draw the point.
fillBrush
GeoBrush
This parameter describes the fill GeoBrush that will be used to draw the point.
drawingLevel
DrawingLevel
This parameter determines the DrawingLevel that the GeoPen or GeoBrush will draw on.
xOffset
Single
This parameter determines the X offset of the ellipse to be drawn.
yOffset
Single
This parameter determines the Y offset of the ellipse to be drawn.
penBrushDrawingOrder
PenBrushDrawingOrder
This parameter determines pen and brush drawing order.
Exceptions¶
InvalidOperationException
In the event you attempt to call this method when the GeoCanvas' IsDrawing mode is false, it will throw an InvalidOperationException.
ArgumentException
Passing invalid well-known binary in the pointShapeWkb parameter will throw an ArgumentException.
ArgumentNullException
If you pass a null as the pointShapeWkb, we will throw an ArgumentNullException.
ArgumentNullException
If you pass a null as the outlinePen and a null as the fillBrush, we will throw an ArgumentNullException.
ArgumentOutOfRangeException
If you pass in a drawingLevel that is not defined in the enumeration, it will throw an ArgumentOutOfRangeException.
Remarks:
This method is used to draw a point on the GeoCanvas. It provides you with a number of overloads that allow you to control how it is drawn. Specify the GeoBrush to fill in the area of the point. Specify the GeoPen to outline the point using that GeoPen. You can also call a overload that will allow you to specify both a GeoPen and a GeoBrush.
The DrawingLevel allows you to specify the level you will draw on when drawing many points.
DrawScreenImageWithoutScalingCore(GeoImage, Single, Single, DrawingLevel, Single, Single, Single)¶
Draws an unscaled image on the GeoCanvas.
protected void DrawScreenImageWithoutScalingCore(GeoImage image, float centerXInScreen, float centerYInScreen, DrawingLevel drawingLevel, float xOffset, float yOffset, float rotateAngle)
Parameters¶
image
GeoImage
The image you want to draw unscaled.
centerXInScreen
Single
The X coordinate of the center point (in screen coordinates) of where you want to draw the image.
centerYInScreen
Single
The Y coordinate of the center point (in screen coordinates) of where you want to draw the image.
drawingLevel
DrawingLevel
This parameter determines the DrawingLevel the image will draw on.
xOffset
Single
This parameter determines the X offset for the image to be drawn.
yOffset
Single
This parameter determines the Y offset for the image to be drawn.
rotateAngle
Single
This parameter determines the rotation angle for the image to be drawn.
Exceptions¶
InvalidOperationException
In the event you attempt to call this method when the GeoCanvas' IsDrawing mode is false, it will throw an InvalidOperationException.
ArgumentNullException
If you pass a null as the image, we will throw an ArgumentNullException.
ArgumentOutOfRangeException
If you pass in a drawingLevel that is not defined in the enumeration, it will throw an ArgumentOutOfRangeException.
ArgumentException
Passing an invalid image parameter will throw an ArgumentException.
Remarks:
Drawing an image unscaled is faster than using the API that scales it.
DrawScreenImageCore(GeoImage, Single, Single, Single, Single, DrawingLevel, Single, Single, Single)¶
Draws a scaled image on the GeoCanvas.
protected void DrawScreenImageCore(GeoImage image, float centerXInScreen, float centerYInScreen, float widthInScreen, float heightInScreen, DrawingLevel drawingLevel, float xOffset, float yOffset, float rotateAngle)
Parameters¶
image
GeoImage
The image you want to draw.
centerXInScreen
Single
The X coordinate of the center point (in screen coordinates) of where you want to draw the image.
centerYInScreen
Single
The Y coordinate of the center point (in screen coordinates) of where you want to draw the image.
widthInScreen
Single
The width you want to scale the image to. This is the width at which the image will be
drawn.
heightInScreen
Single
The height you want to scale the image to. This is the height at which the image will be
drawn.
drawingLevel
DrawingLevel
This parameter determines the DrawingLevel the image will draw on.
xOffset
Single
This parameter determines the X offset for the image to be drawn.
yOffset
Single
This parameter determines the Y offset for the image to be drawn.
rotateAngle
Single
This parameter determines the rotation angle for the image to be drawn.
Exceptions¶
InvalidOperationException
In the event you attempt to call this method when the GeoCanvas' IsDrawing mode is false, it will throw an InvalidOperationException.
ArgumentNullException
If you pass a null as the image, we will throw an ArgumentNullException.
ArgumentOutOfRangeException
If you pass in a drawingLevel that is not defined in the enumeration, it will throw an ArgumentOutOfRangeException.
ArgumentOutOfRangeException
If you pass in a widthInScreen that is not greater than 0, it will throw a ArgumentOutOfRangeException.
ArgumentOutOfRangeException
If you pass in a heightInScreen that is not greater than 0, it will throw a ArgumentOutOfRangeException.
Remarks:
Drawing an image scaled is slower than using the API that draws it unscaled.
DrawTextCore(String, GeoFont, GeoBrush, GeoPen, IEnumerable<ScreenPointF>, DrawingLevel, Single, Single, DrawingTextAlignment, Single)¶
This method allows you to draw text at the specified location, using the specified brush and font parameters.
protected void DrawTextCore(string text, GeoFont font, GeoBrush fillBrush, GeoPen haloPen, IEnumerable<ScreenPointF> textPathInScreen, DrawingLevel drawingLevel, float xOffset, float yOffset, DrawingTextAlignment drawingTextAlignment, float rotateAngle)
Parameters¶
text
String
This parameter specifies the text you wish to draw.
font
GeoFont
This parameter represents the font you wish to use to draw the text.
fillBrush
GeoBrush
This parameter specifies the kind of fill you want to use to draw the
text.
haloPen
GeoPen
This parameter specifies the HaloPen that will be used to draw the text, when the HaloPen effect is needed.
textPathInScreen
IEnumerable<ScreenPointF>
This parameter specifies the path on which to draw the text.
drawingLevel
DrawingLevel
This parameter specifies the drawing level you wish to draw the text on. Higher
levels overwrite lower levels.
xOffset
Single
This parameter determines the X offset for the text to be drawn.
yOffset
Single
This parameter determines the Y offset for the text to be drawn.
drawingTextAlignment
DrawingTextAlignment
rotateAngle
Single
This parameter determines the rotation angle for the text to be drawn.
Exceptions¶
InvalidOperationException
In the event you attempt to call this method when the GeoCanvas' IsDrawing mode is false, it will throw an InvalidOperationException.
ArgumentOutOfRangeException
If you pass in a drawingLevel that is not defined in the enumeration, it will throw an ArgumentOutOfRangeException.
ArgumentNullException
If you pass a null as the fillBrush, we will throw an ArgumentNullException.
ArgumentNullException
If you pass a null as the text, we will throw an ArgumentNullException.
ArgumentNullException
If you pass a null as the font, we will throw an ArgumentNullException.
ArgumentException
If you pass a blank string as the text parameter, we will throw an ArgumentException.
Remarks:
This method is used to draw text on the GeoCanvas.
The DrawingLevel allows you to specify the level you will draw on when drawing multiple text items. This is very useful when you want to draw a drop shadow, for example. You can draw the black backdrop on the lowest level with an offset, then draw the normal text on a higher level without an offset.
MeasureTextCore(String, GeoFont)¶
This method returns the rectangle that contains the specified text, when that text is drawn with the specified font.
protected DrawingRectangleF MeasureTextCore(string text, GeoFont font)
Parameters¶
text
String
This parameter represents the text you want to measure.
font
GeoFont
This parameter represents the font of the text you want to measure.
Returns¶
DrawingRectangleF
This method returns the rectangle that contains the specified text, when that text is drawn
with the specified font.
Exceptions¶
ArgumentNullException
If you pass a null as the text, we will throw an ArgumentNullException.
ArgumentNullException
If you pass a null as the font, we will throw an ArgumentNullException.
ArgumentException
If you pass a blank string as the text parameter, we will throw an ArgumentException.
Remarks:
This method is typically used for labeling, to determine whether labels overlap.
GetCanvasWidthCore()¶
This method gets the canvas width of the specified native image object.
protected float GetCanvasWidthCore()
Returns¶
Single
The returning canvas width.
GetCanvasHeightCore()¶
This method gets the canvas height of the specified native image object.
protected float GetCanvasHeightCore()
Returns¶
Single
The returning canvas height.
FlushCore()¶
This method flush drawing and commits the drawing on the GeoCanvas.
protected void FlushCore()
Remarks:
This method should be called when you are finished drawing. It will commit the image changes to the image you passed in on BeginDrawing. It will also set IsDrawing to false. After you call this method it will put the GeoCanvas into an invalid state, so if you then call any drawing methods it will raise an exception.
DrawArcCore(GeoPen, Single, Single, Single, Single, Single, Single, DrawingLevel)¶
protected void DrawArcCore(GeoPen pen, float x, float y, float width, float height, float startAngle, float sweepAngle, DrawingLevel drawingLevel)
Parameters¶
pen
GeoPen
x
Single
y
Single
width
Single
height
Single
startAngle
Single
sweepAngle
Single
drawingLevel
DrawingLevel
Events¶
DrawingProgressChanged¶
public event EventHandler<DrawingProgressChangedEventArgs> DrawingProgressChanged;