Beispiel #1
0
        /// <summary>
        /// Draws a circle directly on top of the desktop.
        /// </summary>
        /// <param name="color">The color of the circle.</param>
        /// <param name="x">The x coordinate of the center of the circle.</param>
        /// <param name="y">The y coordinate of the center of the circle.</param>
        /// <param name="size">The size of the circle.</param>
        /// <param name="thickness">The thickness of the circle.</param>
        public static void Circle(Color color, int x, int y, int size, int thickness)
        {
            IntPtr desktop = WinAPI.GetDC(IntPtr.Zero);
            Pen    pen     = new Pen(color, thickness);

            using (Graphics g = Graphics.FromHdc(desktop))
            {
                g.DrawEllipse(pen, (x - size / 2), (y - size / 2), size, size);
            }
            WinAPI.ReleaseDC(IntPtr.Zero, desktop);
        }
Beispiel #2
0
        /// <summary>
        /// Draws a rectangle directly on top of the desktop.
        /// </summary>
        /// <param name="color">The color of the rectangle.</param>
        /// <param name="x">The x coordinate of the top left corner.</param>
        /// <param name="y">The y coordinate of the top left corner.</param>
        /// <param name="width">The width of the rectangle.</param>
        /// <param name="height">The height of the rectangle.</param>
        /// <param name="thickness">The thickness of the rectangle.</param>
        public static void Rectangle(Color color, int x, int y, int width, int height, int thickness)
        {
            IntPtr desktop = WinAPI.GetDC(IntPtr.Zero);
            Pen    pen     = new Pen(color, thickness);

            using (Graphics g = Graphics.FromHdc(desktop))
            {
                g.DrawRectangle(pen, new Rectangle(x, y, width, height));
            }
            WinAPI.ReleaseDC(IntPtr.Zero, desktop);
        }
Beispiel #3
0
        /// <summary>
        /// Draws text directly on top of the desktop.
        /// </summary>
        /// <param name="str">The text to draw.</param>
        /// <param name="x">The x coordinate of the text.</param>
        /// <param name="y">The y coordinate of the text.</param>
        /// <param name="color">The color of the text.</param>
        /// <param name="fontSize">The size of the font.</param>
        public static void String(string str, int x, int y, Color color, int fontSize)
        {
            IntPtr desktop = WinAPI.GetDC(IntPtr.Zero);
            Brush  br      = new SolidBrush(color);
            Font   font    = new Font("Arial", fontSize); // Lucida Console is also nice.

            using (Graphics g = Graphics.FromHdc(desktop))
            {
                g.DrawString(str, font, br, new Point(x, y));
            }
            WinAPI.ReleaseDC(IntPtr.Zero, desktop);
        }