Skip to content

Class GraphicsWindow

Kristian Virtanen edited this page Oct 23, 2024 · 3 revisions

Description:

The GraphicsWindow class provides functionality for creating, customizing, and managing a graphical window. You can control its properties, such as background color, dimensions, resizability, and draw shapes and text on it. The class also includes event handling for key and mouse actions within the graphics window.

Properties

GraphicsWindow.BackgroundColor

  • Description: Gets or sets the background color of the graphics window. The color should be a valid color name.

GraphicsWindow.BrushColor

  • Description: Gets or sets the brush color used for filling shapes. The color should be a valid color name.

GraphicsWindow.CanResize

  • Description: Gets or sets a value indicating whether the graphics window is resizable.

GraphicsWindow.FontBold

  • Description: Gets or sets a value indicating whether bold text is used in the graphics window.

GraphicsWindow.FontItalic

  • Description: Gets or sets a value indicating whether italic text is used in the graphics window.

GraphicsWindow.FontName

  • Description: Gets or sets the name of the font used for drawing text.

GraphicsWindow.FontSize

  • Description: Gets or sets the size of the font used for drawing text.

GraphicsWindow.Height

  • Description: Gets or sets the height of the graphics window in pixels.

GraphicsWindow.LastError

  • Description: Stores the last error message, if any operation fails, including a timestamp in yyyy-MM-dd HH:mm:ss format.

GraphicsWindow.PenColor

  • Description: Gets or sets the pen color for drawing shapes. The color should be a valid color name.

GraphicsWindow.PenWidth

  • Description: Gets or sets the width of the pen used for drawing shapes.

GraphicsWindow.Width

  • Description: Gets or sets the width of the graphics window in pixels.

Events

GraphicsWindow.KeyDown

  • Description: Occurs when a key is pressed while the graphics window has focus.

GraphicsWindow.KeyUp

  • Description: Occurs when a key is released while the graphics window has focus.

GraphicsWindow.MouseDown

  • Description: Occurs when the mouse button is pressed down in the graphics window.

GraphicsWindow.MouseMove

  • Description: Occurs when the mouse is moved within the graphics window.

GraphicsWindow.MouseUp

  • Description: Occurs when the mouse button is released in the graphics window.

Methods

GraphicsWindow.Clear()

  • Description: Clears the graphics window, resetting it to the background color.
  • Returns: true if the window was cleared successfully, false if an error occurred.

GraphicsWindow.Show()

  • Description: Displays the graphics window and initializes it if it hasn't been created yet.
  • Returns: true if successful, false if an error occurred.

GraphicsWindow.Hide()

  • Description: Hides the graphics window.
  • Returns: true if successful, false if an error occurred.

GraphicsWindow.DrawEllipse(x, y, width, height)

  • Description: Draws an ellipse at the specified coordinates (x, y) with the given width and height.
  • Parameters:
    • x: The horizontal position of the ellipse.
    • y: The vertical position of the ellipse.
    • width: The width of the ellipse.
    • height: The height of the ellipse.
  • Returns: true if the ellipse was drawn successfully, false if an error occurred.

GraphicsWindow.FillEllipse(x, y, width, height)

  • Description: Fills an ellipse at the specified coordinates (x, y) with the given width and height using the current brush color.
  • Parameters:
    • x: The horizontal position of the ellipse.
    • y: The vertical position of the ellipse.
    • width: The width of the ellipse.
    • height: The height of the ellipse.
  • Returns: true if the ellipse was filled successfully, false if an error occurred.

GraphicsWindow.DrawRectangle(x, y, width, height)

  • Description: Draws a rectangle at the specified coordinates (x, y) with the given width and height.
  • Parameters:
    • x: The horizontal position of the rectangle.
    • y: The vertical position of the rectangle.
    • width: The width of the rectangle.
    • height: The height of the rectangle.
  • Returns: true if the rectangle was drawn successfully, false if an error occurred.

GraphicsWindow.FillRectangle(x, y, width, height)

  • Description: Fills a rectangle at the specified coordinates (x, y) with the given width and height using the current brush color.
  • Parameters:
    • x: The horizontal position of the rectangle.
    • y: The vertical position of the rectangle.
    • width: The width of the rectangle.
    • height: The height of the rectangle.
  • Returns: true if the rectangle was filled successfully, false if an error occurred.

GraphicsWindow.DrawText(x, y, text)

  • Description: Draws the specified text at the given coordinates (x, y) using the current font and pen color.
  • Parameters:
    • x: The horizontal position of the text.
    • y: The vertical position of the text.
    • text: The string of text to draw.
  • Returns: true if the text was drawn successfully, false if an error occurred.

Top

Clone this wiki locally