All pastes #69372 Raw Edit

va

public text v1 · immutable
#69372 ·published 2006-06-22 20:53 UTC
rendered paste body
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsApplication1
{
    public partial class Form1 : Form
    {
        private Rectangle RcDraw;

        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_MouseMove(object sender, MouseEventArgs e)
        {
            Console.WriteLine("Mouse X: {0}", e.X);
            Console.WriteLine("Mouse Y: {0}", e.Y);
        }

        private void Form1_MouseDown(object sender, MouseEventArgs e)
        {
            // Determine the initial rectangle coordinates...

            RcDraw.X = e.X; // mouse X
            RcDraw.Y = e.Y; // mouse Y
            RcDraw.Width = 5; // width (float)
            RcDraw.Height = 5; // height (float)

            this.Invalidate(RcDraw);
        }

        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            // Draw the rectangle...

            e.Graphics.DrawRectangle(new Pen(Color.Blue, PenWidth), RcDraw);
        }
    }
}