如何允许c#中的g.拉线在放入picturebox后进行调整
我试着用一个图片盒,挑出2个点(照片中的眼睛)。我将用如何允许c#中的g.拉线在放入picturebox后进行调整,c#,visual-studio-2010,picturebox,C#,Visual Studio 2010,Picturebox,我试着用一个图片盒,挑出2个点(照片中的眼睛)。我将用g.DrawString选择两点,在这里我将画两个不同的“x”。现在的问题是,如果用户将“x”放置在错误的位置,而我想对其进行调整,我会被卡住。是否有任何代码允许移动g.DrawString“x” using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using
g.DrawString
选择两点,在这里我将画两个不同的“x”。现在的问题是,如果用户将“x”放置在错误的位置,而我想对其进行调整,我会被卡住。是否有任何代码允许移动g.DrawString
“x”
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Camera
{
public partial class CamDisplay : Form
{
public CamDisplay()
{
InitializeComponent();
this.pictureBox1.ImageLocation = @"C:\center90\center90(1).jpg";
}
bool MousedClicked = true;
bool MouseClicked2 = true;
private void pictureBox1_MouseClick(object sender, MouseEventArgs e)
{
base.OnMouseClick(e);
if (MousedClicked == true)
{
txtXaxis.Text = e.X.ToString();
txtYaxis.Text = e.Y.ToString();
MousedClicked = false;
using (Graphics g = Graphics.FromHwnd(pictureBox1.Handle))
{
using (Font myFont = new Font("Calibri", 8))
{
g.DrawString("X", myFont, Brushes.Red, new PointF(e.X, e.Y));
}
}
}
else if (MouseClicked2 == true)
{
txtRXaxis.Text = e.X.ToString();
txtRYaxis.Text = e.Y.ToString();
MouseClicked2 = false;
using (Graphics g = Graphics.FromHwnd(pictureBox1.Handle))
{
using (Font myFont = new Font("Calibri", 8))
{
g.DrawString("X", myFont, Brushes.Red, new PointF(e.X, e.Y));
}
}
}
else
{
MousedClicked = false;
MouseClicked2 = false;
}
}
private void CamDisplay_MouseEnter(object sender, EventArgs e)
{
pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;
pictureBox1.Cursor = Cursors.Hand;
}
}
}
你的问题不清楚。据我所知,您有两种选择:
我在我的代码中添加了一些可以给我一些建议我应该在哪里进行更改吗?很抱歉耽搁了很长时间,我一直很忙。快速浏览一下代码,您似乎在鼠标单击事件中直接绘制到窗口。这将是对上述建议(2)的一种修改。刷新窗口/控件实际上应该“擦除”两个标记。尝试调用pictureBox1.Refresh()。