private void TurnControl_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
if (isHorizontal)
{
if (
(e.X >= leftMargin) &&
(e.X < ClientRectangle.Width - leftMargin) &&
(e.Y >= topMargin) &&
(e.Y < ClientRectangle.Height - topMargin))
{
int cx = e.X - ClientRectangle.Width / 2;
manipulatatorPosition = (float)cx / (ClientRectangle.Width / 2 - leftMargin);
tracking = true;
}
}
else
{
if (
(e.X >= leftMargin) &&
(e.X < ClientRectangle.Width - leftMargin) &&
(e.Y >= topMargin) &&
(e.Y < ClientRectangle.Height - topMargin))
{
int cy = ClientRectangle.Height / 2 - e.Y;
manipulatatorPosition = (float)cy / (ClientRectangle.Height / 2 - topMargin);
tracking = true;
}
}
if (tracking)
{
this.Capture = true;
this.Cursor = Cursors.Hand;
NotifyClients();
// start time, which is used to notify
// about manipulator's position change
ticksBeforeNotificiation = -1;
timer.Start();
}
}
}