I'm doing a project in which you should be able to create shapes in a windows forms environment. I've got two different shapes at the moment, called Circle1 and Rectangle1, they are just what they are called an have similiar properties.
type Rectangle1(x:int, y:int,brush1)=
let mutable thisx = x
let mutable thisy = y
let mutable thiswidth = 50
let mutable thisheight = 20
let mutable brush = brush1
member obj.x with get () = thisx and set x = thisx <- x
member oby.y with get () = thisy and set y = thisy <- y
member obj.brush1 with get () = brush and set brush1 = brush <- brush1
member obj.width with get () = thiswidth and set width = thiswidth <- width
member obj.height with get () = thisheight and set height = thisheight <- height
member obj.draw(g:Graphics) = g.FillRectangle(brush,thisx,thisy,thiswidth,thisheight)
This rectangle is clickable and moveable, but I've encountered a problem. I need some kind of method that is similar to the c# bringToFront() method. So that when I click a shape, my shape goes to the front of all other shapes.
My storage list looks like this:
let mutable RectangleList:List<Rectangle1> = []
And i use a hittest to determine whether the user hit a shape or not:
let rec VilketObjRec (e:MouseEventArgs) (inputlist:List<Rectangle1>) =
match inputlist with
|[] -> None
|head::tail -> if (((e.X >= head.x) && (e.X <= (head.x + head.width))) && (e.Y >= head.y) && (e.Y <= (head.y+head.height)))
then Some(head) else VilketObjRec e tail
Anyone got any kind of idea how to tackle this problem? Cause frankly, I'm lost.