using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
namespace WindowsApplication2
{
public partial class Form1 : Form
{
private Rectangle rect;
private bool inRect = false;
private int a = 20, b = 70;
{
public partial class Form1 : Form
{
private Rectangle rect;
private bool inRect = false;
private int a = 20, b = 70;
public Form1()
{
InitializeComponent();
{
InitializeComponent();
rect = new Rectangle(70, 70, 70 + a, 70 + b);
}
}
private void Form1_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
g.DrawRectangle(Pens.Black, rect);
}
{
Graphics g = e.Graphics;
g.DrawRectangle(Pens.Black, rect);
}
private void Form1_MouseMove(object sender, MouseEventArgs e)
{
Graphics g = this.CreateGraphics();
{
Graphics g = this.CreateGraphics();
if(! inRect)
{
if(rect.Contains(e.X, e.Y))
{
g.DrawRectangle(Pens.Pink, rect);
inRect = true;
return;
}
} else if( inRect )
{
if(!rect.Contains(e.X, e.Y))
{
Invalidate();
inRect = false;
return;
}
}
}
}
}
{
if(rect.Contains(e.X, e.Y))
{
g.DrawRectangle(Pens.Pink, rect);
inRect = true;
return;
}
} else if( inRect )
{
if(!rect.Contains(e.X, e.Y))
{
Invalidate();
inRect = false;
return;
}
}
}
}
}