/// <summary> /// This is the resolution and zoom of things we see on the screen. /// The image is simply shifted and flipped /// </summary> /// <param name="camera"></param> /// <returns></returns> public virtual Thing ToScreenResolution() { var zoom = videoProcessing.GetZoom(); switch (pointMode) { case PointMode.ScreenUnzoomed: X *= zoom; Y *= zoom; break; case PointMode.Raw: X = (X - videoProcessing.FrameCenter.X); Y = (videoProcessing.FrameCenter.Y - Y); //flip Y axis to switch from graphic coordinates to table coordinates break; case PointMode.MM: // convert to unzoomed pixels X = X / videoProcessing.XmmPerPixel * zoom; Y = Y / videoProcessing.YmmPerPixel * zoom; // apply appropriate zoom break; } pointMode = PointMode.Screen; return(this); }
//forward mouse clicks private void PictureBox_MouseClick(object sender, MouseEventArgs e) { //MouseEventArgs me = (MouseEventArgs)e; //Point coordinates = me.Location; if (e.Button == MouseButtons.Right) { return; //skip right button presses } var pictureBox = (PictureBox)sender; if (pictureBox.Image == null) { return; } // as we are stretching the image, we find the point on the bitmap (where measurements are based) // to do the computation double strechX = (double)pictureBox.Image.Width / (double)pictureBox.Width; double strechY = (double)pictureBox.Image.Height / (double)pictureBox.Height; double x = (e.X - pictureBox.Size.Width / 2) * strechX; double y = (pictureBox.Size.Height / 2 - e.Y) * strechY; // make sure we get it to the right handler in case the images are swapped if ((pictureBox.Equals(DownCamera_PictureBox) && !_isSwap) || (pictureBox.Equals(UpCamera_PictureBox) && _isSwap)) { var zoom = downVideoProcessing.GetZoom(); if (downClickDelegate != null) { downClickDelegate(x / zoom, y / zoom, e.X, e.Y); } } else { var zoom = upVideoProcessing.GetZoom(); if (upClickDelegate != null) { upClickDelegate(x / zoom, y / zoom, e.X, e.Y); } } }