private void pictureBox1_MouseMove(object sender, MouseEventArgs e) { int x = e.X, y = e.Y; Point p = new Point(x, y); if (_tLines.Count > 0) { jLine tLine = _tLines.FirstOrDefault(t => t.Rect.Contains(p));//point to line rectangle if (tLine != null) { toolStripStatusLabel1.Text = tLine.Text; jWord word = tLine.Words.FirstOrDefault(w => w.Rect.Contains(p));//point to word rectangle if (word != null) { toolStripStatusLabel2.Text = word.Text; } } else { toolStripStatusLabel1.Text = ""; toolStripStatusLabel2.Text = ""; } } toolStripStatusLabel4.Text = p.ToString(); }
private void pictureBox1_MouseDown(object sender, MouseEventArgs e) { int x = e.X, y = e.Y; Point p = new Point(x, y); if (_tLines.Count > 0) { //draw rectangle over selected word jLine tLine = _tLines.FirstOrDefault(t => t.Rect.Contains(p)); if (e.Button == MouseButtons.Right) { Clipboard.SetText(tLine.Text); } if (tLine != null) { jWord word = tLine.Words.FirstOrDefault(w => w.Rect.Contains(p)); if (word != null) { //draw picture over background original using (Bitmap bmp = new Bitmap(pictureBox1.BackgroundImage.Width, pictureBox1.BackgroundImage.Height)) { bmp.MakeTransparent();//less memory using (Graphics g = Graphics.FromImage(bmp)) { using (Pen pen = new Pen(Color.Green, 4)) { g.DrawRectangle(pen, word.Rect);//word rectangle } } pictureBox1.Image = (Bitmap)bmp.Clone(); } toolStripStatusLabel3.Text = word.Text; } } } }