Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Help in custom Class

nutty boynutty boy Member Posts: 7
Hi Everybody
I made a simple project its idea as follow

i want to make a graphical object consist of filled rectangle which can be drawn on the screen and be able to move it any where on the screen. i created windows form and added to it a new class which represents my graphical object and contains the following code
[code]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Drawing.Drawing2D;

namespace DrawObject
{
public class MyObject
{
Point postion;
Size size;
Region objRegion;

public MyObject()
{
postion = new Point(20, 30);
size = new Size(30, 30);
objRegion = new Region(new Rectangle(postion, size));

}
public void Draw(Graphics g)
{
g.FillRectangle(Brushes.Blue, postion.X, postion.Y, size.Width, size.Height);
g.Dispose();
}
public Point Postion
{
get { return postion; }
set {
postion = value;
objRegion.Dispose();
objRegion = new Region(new Rectangle(postion, size));
}
}
public Size SizeObj
{
get { return size; }
set {
size = value;
objRegion.Dispose();
objRegion = new Region(new Rectangle(postion, size));
}
}
}
}
[/code]

my question is how to make my class detect mouse click so that i can register any fn to mouse click event

Comments

Sign In or Register to comment.