DrawingWindow Class |
The DrawingWindow class provides a basic capability for creating drawings in a .NET environment using Windows Presentation Foundation (WPF) classes. It allows you to create drawings consisting of points, lines, squares, circles, and other geometric shapes in a window to save the drawings to a file. The class also includes facilities for text, color, pictures, and simple animation.
The coordinate system follows Windows convention, meaning that an x,y coordinate starts from the top-left corner, with the y axis oriented downward.
The API is modeled after the StdDraw class with necessary adaptation for the Windows environment.
Namespace: Algs4Net
public class DrawingWindow : Window
The DrawingWindow type exposes the following members.
Name | Description | |
---|---|---|
![]() | DrawingWindow |
Creates the WPF client
|
Name | Description | |
---|---|---|
![]() | Clear |
Clears the screen to the default color (white). |
![]() | Clear(Color) |
Clears the screen to the specified color. |
![]() | DeleteVisual |
Removes a visual from the canvas
|
![]() | DrawArc |
Draws a circular arc of the specified radius,
centered at (X, Y), from angle1 to angle2 (in degrees)
clockwise. An angle of 0 would means an arc start at 3 o'clock
|
![]() | DrawCircle |
Draws a circle of the specified radius, centered at (X, Y).
|
![]() | DrawCirle |
Draws a circle of the specified radius, centered at (X, Y).
|
![]() | DrawEllipse(Double, Double, Double, Double) |
Draws an ellipse with the specified semimajor and semiminor axes,
centered at (X, Y). |
![]() | DrawEllipse(DrawingVisual, Double, Double, Double, Double) |
Draws an ellipse with the specified semimajor and semiminor axes,
centered at (X, Y). |
![]() | DrawFilledCircle(Double, Double, Double) |
Draws a filled circle of the specified radius, centered at (X, Y).
|
![]() | DrawFilledCircle(DrawingVisual, Double, Double, Double) |
Draws a filled circle of the specified radius, centered at (X, Y).
|
![]() | DrawFilledEllipse(Double, Double, Double, Double) |
Draws a filled ellipse with the specified semimajor and semiminor axes,
centered at (X, Y). |
![]() | DrawFilledEllipse(DrawingVisual, Double, Double, Double, Double) |
Draws a filled ellipse with the specified semimajor and semiminor axes,
centered at (X, Y). |
![]() | DrawFilledPolygon |
Draws a filled polygon with the vertices
(X0, Y0),
(X1, Y1), ...,
(XN-1, YN-1). |
![]() | DrawFilledRectangle |
Draws a filled rectangle of the specified size, centered at (X, Y). |
![]() | DrawFilledSquare |
Draws a filled square of the specified size, centered at (X, Y). |
![]() | DrawLine(Double, Double, Double, Double) |
Draws a line segment between (X0, Y0) and
(X1, Y1). |
![]() | DrawLine(DrawingVisual, Double, Double, Double, Double) |
Draws a line segment between (X0, Y0) and
(X1, Y1). |
![]() | DrawPicture(Double, Double, String, Double, Double) |
Loads and draws a picture centered at (X, Y) within
the specified rectangle with sizes in desiredWidth and
desiredHeight. The picture will be scaled to fit the rectangle
|
![]() | DrawPicture(Double, Double, String, Double, Double, Double) |
Loads and draws a picture centered at (X, Y) within
the specified rectangle with sizes in desiredWidth and
desiredHeight. The picture will be scaled to fit the rectangle
|
![]() | DrawPoint |
Draws a point centered at (X, Y).
The point is a filled circle whose radius is equal to half the pen thickness.
|
![]() | DrawPolygon |
Draws a polygon with the vertices
(X0, Y0),
(X1, Y1), ...,
(XN-1, YN-1). |
![]() | DrawRectangle |
Draws a rectangle of the specified size, centered at (X, Y). |
![]() | DrawSquare |
Draws a square of the specified size, centered at (X, Y). |
![]() | DrawText(Double, Double, String, Double, Boolean) |
Draws a text using the current font starting at (X, Y)
given the desired font size. The text is defaulted to flow from left
to right can be specified to flow from right to left.
|
![]() | DrawText(Double, Double, String, Double, Double, Boolean) |
Draws a text using the current font starting at (X, Y)
given the desired font size. The text is defaulted to flow from left
to right can be specified to flow from right to left.
|
![]() | GetCanvasSize |
Returns the current canvas size
|
![]() | GetFont |
Returns the curent font family
|
![]() | GetPenColor |
Returns the current pen/solid brush color
|
![]() | GetPenThickness |
Returns the current pen thickness (2 * radius), or the line width |
![]() | SetCanvasSize |
Resets the canvas size to default size
|
![]() | SetCanvasSize(Int32, Int32) |
Sets the canvas (drawing area) to be Width-by-Height pixels.
This also erases the current drawing and resets the coordinate system,
pen radius, pen color, and font back to their default values.
Ordinarly, this method is called once, at the very beginning
of a program. |
![]() | SetFont |
Resets the text font to the default font
|
![]() | SetFont(FontFamily) |
Changes the text font to the desired font family
|
![]() | SetPenColor |
Resets the the current pen/solid brush color to default (black)
|
![]() | SetPenColor(Color) |
Changes the the current pen/solid brush color to desired color
using the Color type.
|
![]() | SetPenColor(Int32, Int32, Int32) |
Changes the the current pen/solid brush color to desired color in RGB from
|
![]() | SetPenThickness |
Sets the pen size to the default size (2 Dpi).
The pen is circular, so that lines have rounded ends. When you
draw a point, you get a circle. |
![]() | SetPenThickness(Double) |
Sets the pen size or line width to the desired size.
The pen is circular, so that lines have rounded ends. When you
draw a point, you get a circle. |
![]() | SetPercentScale |
If set, the input coordinate will be in the range 0.0 - 1.0. If
an input coordinate is greater than 1, this setting will not take effect
|
For additional documentation, see Section 1.5 of Introduction to Programming in Java: An Interdisciplinary Approach by Robert Sedgewick and Kevin Wayne.