private void pbCamera_MouseClick(object sender, MouseEventArgs e) { int widthView = pbCamera.Width; int heightView = pbCamera.Height; int xMouse = e.X; int yMouse = e.Y; int idx = -1; lock (flags) { if (flags.clickCount < 4) { idx = flags.clickCount++; } } if (idx == -1) { return; } if (xMouse >= 0 && xMouse < widthView && yMouse >= 0 && yMouse < heightView) { ptsShowCorners[idx].X = xMouse; ptsShowCorners[idx].Y = yMouse; tbsPoint[idx].Text = String.Format("({0},{1})", xMouse, yMouse); if (idx == 3) { cc.UpdateCorners(ptsShowCorners, flags); } } }
private void pbCamera_MouseClick(object sender, MouseEventArgs e) { int widthView = pbCamera.Width; int heightView = pbCamera.Height; int xMouse = e.X; int yMouse = e.Y; if (e.Button == MouseButtons.Left) { int idx = -1; lock (flags) { if (flags.clickCount < 4) { idx = flags.clickCount++; } } if (idx == -1) { return; } if (xMouse >= 0 && xMouse < widthView && yMouse >= 0 && yMouse < heightView) { ptsShowCorners[idx].X = xMouse; ptsShowCorners[idx].Y = yMouse; tbsPoint[idx].Text = String.Format("({0},{1})", xMouse, yMouse); if (idx == 3) { cc.UpdateCorners(ptsShowCorners, flags); } } } else { Point2f[] res_my_car = cc.ShowToLogic(new Point2f[] { new Point2i { X = xMouse, Y = 480 - yMouse } }); if (myID == 'A') { game.CarA.Pos.x = Convert.ToInt16(res_my_car[0].X); game.CarA.Pos.y = Convert.ToInt16(res_my_car[0].Y); } else { game.CarB.Pos.x = Convert.ToInt16(res_my_car[0].X); game.CarB.Pos.y = Convert.ToInt16(res_my_car[0].Y); } } }