/// <summary> /// Make sure that the PicBox have the focus, otherwise it doesn´t receive /// mousewheel events !. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void PicBox_MouseEnter(object sender, EventArgs e) { if (PicBox.Focused == false) { PicBox.Focus(); } }
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); Console.WriteLine("y=" + NUM_Y.Value.ToString()); pictureBox.Focus(); } else { mousedown = false; } }
void PicBox_MouseClick(object sender, MouseEventArgs e) { Console.WriteLine("Clicked on pixturebox control"); if (PicBox.Focused == false) { PicBox.Focus(); } }
private void Form1_Load(object sender, System.EventArgs e) { GlobalVars.GameForm = this; GlobalVars.GameEngine = new GameEngine(this.pictureBox1.Handle); this.Show(); this.Focus(); GlobalVars.GameEngine.Init(); pictureBox1.Focus(); }
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; if (osd.is_ntsc()) { // started on top screen and went to bottom if (topScreen && ansH >= OSD.SCREEN_NTSC_SKIP_LINES.Min()) { ansH += (topScreen)?3:-1; } // started on bottom screen and went to top else if (!topScreen && ansH <= OSD.SCREEN_NTSC_SKIP_LINES.Max()) { ansH -= 3; } } NUM_X.Value = Constrain(ansW, 0, osd.get_basesize().Width - 1); NUM_Y.Value = Constrain(ansH, 0, OSD.SCREEN_H - 1); Console.WriteLine("y=" + NUM_Y.Value.ToString()); pictureBox.Focus(); } else { mousedown = false; } }
private void picbNote_MouseDown(object sender, MouseEventArgs e) { picbNoteChoose = (PictureBox)sender; xNote = e.X; yNote = e.Y; xNoteMove = picbNoteChoose.Left; yNoteMove = picbNoteChoose.Top; if (bNoteErase) { cbNote.Focus(); } else { picbNoteChoose.Focus(); } }
/// <summary> /// Seleccionar una imagen dentro del componente, a partir del nombre de la misma /// </summary> /// <param name="pRutaImagen"></param> public void SeleccionarImagen( string pRutaImagen) { int mIndice = -1; for (int i = 0; i < this.ListaImagenes.Count; i++) if (this.ListaImagenes.ElementAt(i).ToLower() == pRutaImagen.ToLower()) mIndice = i; if (mIndice >= 0) { DeseleccionarImagen(); iPBoxSeleccionado = (PictureBox)this.Controls.Find("PictureBox" + mIndice.ToString() , true)[0]; iPBoxSeleccionado.Focus(); if (this.labels) { iLabelSeleccionado = (Label)this.Controls.Find("LabelPictureBox" + mIndice.ToString(), true)[0]; iLabelSeleccionado.BackColor = Color.Firebrick; iLabelSeleccionado.Focus(); } } }