First of all, im not really sure how to explain this very well as I am finding it very very strange.
I am trying to draw a grid into a form and have the colours of the grid change if they are selected by the user.
Here is my draw and mouse event handler:
Code:
private void OnPaint(object sender, PaintEventArgs e)
{
Painter.Instance.ClearScreen(Color.Blue);
//m_mainGrid[0].IsSelected = true;
foreach (GridNode node in m_mainGrid)
node.Draw(true, true);
}
private void OnClick(object sender, EventArgs e)
{
m_mainGrid[0].IsSelected = true;
Invalidate();
}
GridNode.Draw is defined like this:
Code:
public void Draw(bool showId, bool showPos)
{
if (IsSelected)
Painter.Instance.FillBorderRectangle(Rect, Color.Green, Color.Black);
else
Painter.Instance.FillBorderRectangle(Rect, Color.Red, Color.Black);
}
The problem I am having is that even when the node is selected it gets drawn as red. The debugger breaks into the DrawMethod and sets it to Green and it never breaks into the line where it goes to red. But still the image on my screen is red.
If I uncomment the m_mainGrid[0].IsSelected = true line, it does show up as green.
Any ideas?