I am a newbie in WinForms and I have question about MouseDown and MouseUp events (sorry, if I duplicate it, but I cann't google it). So, I have a PictureBox and paint cube on it. But I need to rotate it, using the mouse. I use auto-generated events MouseDown, MouseUp, MouseMove. First of them just change bool variable (it's stupid way to check, but I cann't find the better one).
private void PictureBox_MouseDown(object sender, MouseEventArgs e)
{
RMBIsPressed = true;
}
private void PictureBox_MouseUp(object sender, MouseEventArgs e)
{
RMBIsPressed = false;
}
In MouseMove I have do {} while(), that checks state of RMBIsPressed and repaint cube, if it's need.
private void PictureBox_MouseMove(object sender, MouseEventArgs e)
{
Point mousePoint = MousePosition;
Point mousePointNext;
do
{
mousePointNext = MousePosition;
if (mousePointNext != mousePoint)
{
if (mousePoint.X < mousePointNext.X)
{
teta += deltaTeta;
}
else
{
teta -= deltaTeta;
}
if (mousePoint.Y < mousePointNext.Y)
{
phi += deltaPhi;
}
else
{
phi -= deltaPhi;
}
PictureBox.Refresh();
ViewTransformation();
DrawCube();
}
mousePoint = MousePosition;
} while (RMBIsPressed);
}
When MouseUp event happens first time, everything is all right, but in next iteration RMBIsPressed is still true, even if I release RMB. It seems do while blocks the MouseUp event. My question is: can I create another thread, which will catch MouseUp and MouseDown events and change value of RMBIsPressed? If it's possible, please tell me how.