GDI+(绘圆)
来源:互联网 发布:淘宝官网网页版 编辑:程序博客网 时间:2024/06/03 20:33
题目要求:
编写一个window应用程序,实现一个左右移动的半径为30个像素的红色圆,并在圆内显示相对于窗体的坐标
输入代码:
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 _322{ public partial class Form1 : Form { int X, Y; string str = "("; public Form1() { InitializeComponent(); } private void Form1_Paint(object sender, PaintEventArgs e) { Graphics g = e.Graphics; Pen p = new Pen(Color.Black, 2); int R = 80; Random rd = new Random(); X = rd.Next(0,this.ClientSize.Width-R); str += X.ToString(); str += ","; Y = rd.Next(0,this.ClientSize.Height-R); str += Y.ToString(); str += ")"; g.DrawEllipse(p, X, Y, 2 * R, 2 * R); SolidBrush brush = new SolidBrush(Color.Red); g.FillEllipse(brush, X, Y, 2 * R, 2 * R); label1.Font = new Font("宋体", 10); label1.BackColor = Color.Yellow; label1.Location = new Point(X + R, Y + R); label1.Text = str; str = "("; g.Dispose(); } private void label1_Click(object sender, EventArgs e) { } }}
运行截图:
总结:
代码动态添加控件其实比这方法好点
0 0
- GDI+(绘圆)
- GDI+
- GDI+
- GDI+
- GDI
- GDI
- GDI+
- GDI+
- GDI+
- gdi+
- GDI+
- GDI+
- GDI+
- GDI+
- GDI+
- GDI
- GDI+
- GDI
- 软件测试
- OpenGL三维坐标与二维坐标:gluProject 和 gluUnproject 的详解
- Python基础
- C++ 类的6个缺省函数
- Android 关于 OnScrollListener 事件顺序次数的简要分析
- GDI+(绘圆)
- Python学习资料推荐
- mysql带 like 的模糊查询
- 第八周项目4-指向学生类的指针
- LaTeX文档插入图片的几种常用方法
- 终端接口
- 一段程序代码 --- 实现解析字典,自动转换生成属性。
- 自定义侧拉删除(没有嵌套ListView)
- java 文件的复制