111,104
社区成员




都是使用gdi 代码的方式画 . 这种东西没有"可视化"的.
using System.Drawing;
using System.Windows.Forms;
namespace WindowsFormsApp1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Paint(object sender, PaintEventArgs e)
{
// 获取窗体客户区大小(不包括标题栏和边框)
int clientWidth = ClientSize.Width;
int clientHeight = ClientSize.Height;
// 计算窗体中心点
int centerX = clientWidth / 2;
int centerY = clientHeight / 2;
// 定义圆的直径
int diameter = 100;
int radius = diameter / 2;
// 计算圆的外接矩形(左上角坐标)
Rectangle rect = new Rectangle(
centerX - radius,
centerY - radius,
diameter,
diameter
);
// 使用红色画笔绘制圆(空心)
using (Pen redPen = new Pen(Color.Red, 3))
{
e.Graphics.DrawEllipse(redPen, rect);
}
}
}
}