Tag: shapes

如何在C#中使用鼠标绘制和移动形状

我是C#编程的新手,想要求一些帮助。 我正在尝试使用鼠标左键移动我在Windows应用程序表单上绘制的颜色填充矩形,我正在尝试使用鼠标右键将其拖放到另一个位置。 目前我已设法绘制矩形,但右键单击是拖动整个表单。 这是我的代码: public partial class Form1 : Form { private Point MouseDownLocation; public Form1() { InitializeComponent(); this.DoubleBuffered = true; } Rectangle rec = new Rectangle(0, 0, 0, 0); protected override void OnPaint(PaintEventArgs e) { e.Graphics.FillRectangle(Brushes.DeepSkyBlue, rec); } protected override void OnMouseDown(MouseEventArgs e) { if (e.Button == MouseButtons.Left) { rec = new Rectangle(eX, eY, […]

如何使用GDI +绘制环形(甜甜圈)?

我一直试图在C#中绘制一个带有透明孔和渐变边缘的环 (厚度环),但收效甚微。 有没有人对如何做到这一点有任何建议? 这是一个很好的Blend Utility 这是最终结果 – 感谢BlueMonkMN Rectangle GetSquareRec(double radius, int x, int y) { double r = radius; double side = Math.Sqrt(Math.Pow(r, 2) / 2); Rectangle rec = new Rectangle(x – ((int)side), y – ((int)side), (int)(side * 2) + x, (int)(side * 2) + y); return rec; } void Form1_Paint(object sender, PaintEventArgs e) […]