Saturday, 14 September 2013

How to implement a pictureBox.MoveHover

How to implement a pictureBox.MoveHover

Event handlers are still a bit new to me. I want to call this method that
will change the value of a member in a jagged list from 0 to 1 if the
mouse hovers over a certain part of the pictureBox.
public void onMouseUp(MouseEventArgs e, List<List<int>> walls,
List<List<int>> positions)
{
for (int i = 0; i < walls.Count; i++)
{
int[] mapData = mapController.getMapData(i, walls, positions);
int column = mapData[0];
int row = mapData[1];
int right = mapData[2];
int bottom = mapData[3];
if (e.X == column * mapController.map.squareSize)
{
mapController.map.cellWalls[i][0] = 1;
}
}
}
The method may be wrong, but i just want to call it first, then i can test
it. It's in a class called mapConstructor. I have a form class called
mapDesignerView that has the picture box.
To call it i tried this from within the form:
private void pbxMap_MouseHover(object sender, System.EventArgs e)
{
mapConstructor.onMouseUp(e, map.cellPositions, map.cellPositions);
}
It won't accept a mouseEvntArgs parameter so says invalid arguments as my
method needs the mouseEventArgs. I've tried a few different things too but
would like to hear a solution rather than tell you all the wrong things i
have tried.
I would like to call it continuously while the mouse is hovering over the
picturebox, i think, and when it changes a value of the list, the
picturebox will need to redraw itself.
Thanks.

No comments:

Post a Comment