//point ob2 = new point(); ob2.x = e.X; ob2.y = e.Y; Invalidate(); } }
private void Form1_Paint_1(object sender, PaintEventArgs e) {
int i, j, n;
n = G.Vertices.Count;
Graphics g = this.CreateGraphics(); Node ob = new Node();
for (i = 0; i < n; i++)//进行重绘点 {
ob = G.Vertices[i];
Pen pen = new Pen(ob.c, ob.w);
g.DrawEllipse(pen, ob.x, ob.y, 8, 8);//画点
g.DrawString(ob.Name, new Font(\宋体\, 15), Brushes.Blue, new Point(ob.x + 5, ob.y));//点边上的标记
}
for (i = 0; i < n; i++)//重绘边 {
for (j = 0; j < n; j++) {
if (G.edge[i, j] != Stone) {
Pen pen = new Pen(Color.Red, 4);
g.DrawLine(pen, new Point(G.Vertices[i].x, G.Vertices[i].y), new Point(G.Vertices[j].x, G.Vertices[j].y));//画边 } } } }
}
[Serializable()]
class Node //定点类型 {
public int ID;
public string Name = \; public int x, y; public Color c; public int w; }
struct AdjMGraph //图类型 {
public List
Using 命令
(图片移动)
namespace 第十次作业 {
public partial class Form1 : Form {
public int dx, dy; public Form1() {
InitializeComponent(); }
private void button1_Click(object sender, EventArgs e) {
comboBox1.Items.Add(shuru.Text); }
private void button2_Click(object sender, EventArgs e) {
MessageBox.Show(\是否删除\, \删除确认\, MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (true) {
comboBox1.Items.Clear(); } }
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) {
shuchu.Text = comboBox1.SelectedItem.ToString();
}
private void timer1_Tick(object sender, EventArgs e) {
progressBar1.Maximum = this.Width-189; progressBar1.Minimum = 0;
this.label3.Text = \现在时间为:\ + DateTime.Now.ToString(); pictureBox1.Left -= dx; pictureBox1.Top+= dy;
if (pictureBox1.Left >= this.Width-185 ) dx = -dx; if (pictureBox1.Top >= this.Height-158) dy = -dy; if (pictureBox1.Left <= 0) dx = -dx; if (pictureBox1.Top <= 0) dy = -dy;
if (pictureBox1.Left <=progressBar1.Maximum && pictureBox1.Left >= 0) {
progressBar1.Value = pictureBox1.Left; }
}
private void Form1_Load(object sender, EventArgs e) {
dx = 6; dy = 4; timer1.Start(); }
private void button3_Click(object sender, EventArgs e) {
timer1.Start(); }
private void button4_Click(object sender, EventArgs e) {
timer1.Stop(); } } }
Using 命令 using System.Collections;
namespace youxi {
public partial class 气泡 : Form {
//泛型集合
List
int sum=0;Pen pen;Graphics g;int N;
public 气泡() {
InitializeComponent(); }
//自动生成对象
private void timer1_Tick(object sender, EventArgs e) {
if (sum < N) {
Circle ob = new Circle(); ob.r = rand.Next(30, 50); ob.dx = rand.Next(20, 30); ob.dy = rand.Next(20, 30);
ob.c = Color.FromArgb(rand.Next(0, 255), rand.Next(0, 255), rand.Next(0, 255));//颜色随机的出现。
ob.b = rand.Next(2*ob.r, this.Height); ob.a= rand.Next(2*ob.r, this.Width ); //ob.a = 0; sum++;
ob.w = rand.Next(6, 10);
(气泡程序)
list.Add(ob); //存储圆 } }
private void Form1_Load(object sender, EventArgs e) {
timer1.Start(); timer2.Start();
g = this.CreateGraphics(); pen = new Pen(Color.Red ); N = 2; }
private void timer2_Tick(object sender, EventArgs e) {
foreach (Circle ob in list) {
pen.Color = this.BackColor; pen.Width = ob.w;
g.DrawEllipse(pen, ob.a - ob.r, ob.b - ob.r, 2 * ob.r, 2 * ob.r);
ob.a += ob.dx; ob.b += ob.dy;
pen.Color = ob.c; pen.Width = ob.w;
g.DrawEllipse(pen, ob.a-ob.r, ob.b-ob.r, 2 * ob.r, 2 * ob.r);
if (ob.a > this.Width - ob.r) {
ob.dx = -ob.dx; }
if (ob.a <0) {
ob.dx = -ob.dx; }
if (ob.b > this.Height - ob.r) {
ob.dy = -ob.dy; }
if (ob.b <0) {
ob.dy = -ob.dy; } } } } }
public class Circle {
public int a, b, r, w;//圆心坐标(a,b),半径r,笔的宽度w public Color c; //线条的颜色 public int dx, dy, Id; //步长,身份id //无参构造函数。 public Circle() {
a = 0; b =10; r = 5; w = 2; c = Color.Red; dx = 10; dy = 10; }
//有参构造函数。
public Circle(int a1, int b1, int r1, int w1, int dx1, int dy1, Color c1) {
a = a1; b = b1; r = r1; w = w1; dx = dx1; dy = dy1; c = c1; }
~Circle() { }
}
Using 命令
using System.IO;//
using System.Collections;//数组 using System.Drawing.Imaging;
using System.Runtime.Serialization; //系列1
using System.Runtime.Serialization.Formatters.Binary;//系列2
namespace _200911520156赵善恩 {
public partial class Form1 : Form {
int x1, x2, y1, y2, flag = 0; int w = 2; int index;
Color C = Color.Red;
ArrayList arrline = new ArrayList();//存储线
ArrayList arrRectangle = new ArrayList();//存矩形对象 ArrayList arrEllipse = new ArrayList();//存储椭圆
public MemoryStream fs2;//内存流
public BinaryFormatter formatter;//格式化
// public int sizeofCline = 0;//直线对象的字节数
public byte[] buffer;//定义字节数组存放读取的数据 public Form1() {
InitializeComponent();
(画圆,椭圆,矩形,直线)