void getCharLoc(int x, int y, out int xpos, out int ypos) { System.Windows.Forms.PictureBox pb = pictureBox; x = Constrain(x, 0, pb.Width - 1); y = Constrain(y, 0, pb.Height - 1); float scaleW = pb.Width / (float)osd.screen.Width; float scaleH = pb.Height / (float)osd.screen.Height; int ansW = (int)((x / scaleW / OSD.CHAR_W) % OSD.SCREEN_W); int ansH = 0; if (osd.pal_checked()) { ansH = (int)((y / scaleH / OSD.CHAR_H) % OSD.SCREEN_H); } else { ansH = (int)((y / scaleH / OSD.CHAR_H) % OSD.SCREEN_H_NTSC); } xpos = Constrain(ansW, 0, OSD.SCREEN_W - 1); ypos = Constrain(ansH, 0, OSD.SCREEN_H - 1); }
private void pictureBox1_MouseMove(object sender, MouseEventArgs e) { if (e.Button == System.Windows.Forms.MouseButtons.Left && mousedown == true) { int ansW, ansH; getCharLoc(e.X, e.Y, out ansW, out ansH); if (ansH >= osd.getCenter() && !(osd.pal_checked() || osd.auto_checked())) { ansH += 3; } ansW -= clickX; //запомним куда ткнули ansH -= clickY; NUM_X.Value = Constrain(ansW, 0, osd.get_basesize().Width - 1); NUM_Y.Value = Constrain(ansH, 0, OSD.SCREEN_H - 1); pictureBox.Focus(); } else { mousedown = false; } }