I think I've run into a thread synchronization problem. I have a C# program where I have a extended Panel class (MapEditorPanel) and I also have a form that contains that MapEditorPanel. I have a MouseClick Event on both the Form and the Panel. The MapEditorPanels event updates the variables activeRow and activeColumn, which are the column and row that was clicked on.
How can I update the form that contains this MapEditorPanel with the activeRow and activeColumn after the panel is clicked?
When I had originally is two click events. One I set on the Form that is raised when the MapEditorPanel is clicked, but if I try to access the activeColumn and activeRow immidiately after the panel is clicked it loads the previous activeRow and Column because the MapEditorPanel has not finished calculating which row and column were clicked. (Which is called by its MouseClick event).
This is the FORMS MouseClick event:
private void mapViewer_MouseClick(object sender, MouseEventArgs e)
{
// Remove red border from old active tile
if (activeTile != null)
activeTile.removeTileEffect();
activeTile = map[mapViewer.ActiveColumn, mapViewer.ActiveRow];
RowBox.Text = "" + activeTile.Row;
ColumnBox.Text = "" + activeTile.Column;
BaseImageBox.Text = "" + activeTile.getBaseImageDescription();
TopImageBox.Text = "" + activeTile.getTopImageDescription();
// Add red border to active tile
activeTile.addTileEffect(gm.getTileEffect("RedBorderTile"));
}
This is the PANELS MouseClick event:
private void MapEditorPanel_MouseClick(object sender, MouseEventArgs e)
{
Point mapCoordinates = getMapPointFromScreen(e.Location);
Tile tileClicked = map.getTileFromPoint(mapCoordinates);
activeRow = (tileClicked.Row);
activeColumn = (tileClicked.Column);
}