Tag: 图形

如何使用Windows API捕获屏幕和鼠标指针?

我正在使用以下代码捕获位图中的屏幕。 屏幕被捕获,但我无法在屏幕上显示鼠标指针。 你能建议一些替代方法,以便捕获鼠标吗? private Bitmap CaptureScreen() { // Size size is how big an area to capture // pointOrigin is the upper left corner of the area to capture int width = Screen.PrimaryScreen.Bounds.X + Screen.PrimaryScreen.Bounds.Width; int height = Screen.PrimaryScreen.Bounds.Y + Screen.PrimaryScreen.Bounds.Height; Size size = new Size(width, height); Point pointOfOrigin = new Point(0, 0); Bitmap bitmap […]

计算距离A的给定距离的AB线上的点

我会非常疯狂地计算沿着给定线AB的点,在距离A的给定距离处,以便我可以“绘制”两个给定点之间的线。 一开始听起来很简单,但我似乎无法做到这一点。 更糟糕的是,我不明白我哪里出错了。 几何(和一般的数学)不是我强大的套件。 我已经阅读了类似的问题,并在那里有答案。 事实上,我直接从Mads Elvheim的回答中解除了我对CalculatePoint函数的当前实现: 给定一个起点和终点以及一个距离,计算沿线的一个点 (加上后面的注释中的修正 – 如果我理解正确的话)因为我的独立尝试解决问题让我无处可去,除了头等舱快递票务frusterpationland。 这是我的更新代码(请参阅EDIT备注post的底部): using System; using System.Drawing; using System.Windows.Forms; namespace DrawLines { public class MainForm : Form { // ===================================================================== // Here’s the part I’m having trouble with. I don’t really understand // how this is suposed to work, so I can’t seem to get it […]

按钮C#(WinForms)中的圆角边

你好,通过这里和其他网站的一些研究,我做了一个圆角边缘按钮。 protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); Rectangle Rect = new Rectangle(0, 0, this.Width, this.Height); GraphicsPath GraphPath = new GraphicsPath(); GraphPath.AddArc(Rect.X, Rect.Y, 50, 50, 180, 90); GraphPath.AddArc(Rect.X + Rect.Width – 50, Rect.Y, 50, 50, 270, 90); GraphPath.AddArc(Rect.X + Rect.Width – 50, Rect.Y + Rect.Height – 50, 50, 50, 0, 90); GraphPath.AddArc(Rect.X, Rect.Y + Rect.Height […]

如何画线并在Panel中选择它

我的程序可以使用canvas.Drawline()绘制线条。 如何点击线并更改此颜色(选择线)? private List coordFirst = new List(); private List coordLast = new List(); public Graphics canvas; private void Form1_Load(object sender, EventArgs e) { canvas=panel1.CreateGraphics(); } 存储在coordFirs和coodLast中的坐标线。

根据当前鼠标位置缩放图形

我正在尝试根据鼠标的当前位置缩放绘图。 现在我的onMouseWheel方法看起来像这样(基于这个StackOverflow答案 ): private void onMouseWheel(object sender, MouseEventArgs e) { if (e.Delta > 0) { _scale *= 1.25f; _translateY = eY – 1.25f * (eY – _translateY); _translateX = eX – 1.25f * (eX – _translateX); } else { _scale /= 1.25f; _translateY = eY – 0.8f * (eY – _translateY); _translateX = eX – […]

Windows 10操作系统上的Windows窗体图形问题

当我在Windows 10中运行任何Windows窗体应用程序时,窗口内的图形看起来是扭曲的: 在设计时,这不会发生: 有没有人经历过这个? (请打开图片以便更好看。)