Chinaunix首页 | 论坛 | 博客
  • 博客访问: 539643
  • 博文数量: 156
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 1183
  • 用 户 组: 普通用户
  • 注册时间: 2013-11-22 11:42
文章分类

全部博文(156)

文章存档

2015年(67)

2014年(89)

分类: C#/.net

2014-11-28 20:37:07

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 multiple
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }


        private void LineButton_Click(object sender, EventArgs e)
        {
            int x1, y1, x2, y2;


            Graphics DrawInterface = panel1.CreateGraphics();
            Pen MyPenBlack = new Pen(Color.Black, 5);


            x1 = Convert.ToInt32(textBox1.Text);
            y1 = Convert.ToInt32(textBox2.Text);
            x2 = Convert.ToInt32(textBox3.Text);
            y2 = Convert.ToInt32(textBox4.Text);
            Point A = new Point(x1, y1);
            Point B = new Point(x2, y2);
            
            DrawInterface.Clear(Color.LightGray);
            DrawInterface.DrawLine(MyPenBlack, A, B);
        }


        private void PictureCircle_Click(object sender, EventArgs e)
        {
            int x1, y1, x2, y2;
            Graphics DrawInterface = panel1.CreateGraphics();
            Pen MyPenRed = new Pen(Color.Red, 5);


            x1 = Convert.ToInt32(textBox1.Text);
            y1 = Convert.ToInt32(textBox2.Text);
            x2 = Convert.ToInt32(textBox3.Text);
            y2 = Convert.ToInt32(textBox4.Text);
            Rectangle temp = new Rectangle(x1, y1, x2, y2);


            DrawInterface.Clear(Color.LightGray);
            DrawInterface.DrawEllipse(MyPenRed, temp);
        }


        private void PictureRectangle_Click(object sender, EventArgs e)
        {
            int x1, y1, x2, y2; 
            Graphics DrawInterface = panel1.CreateGraphics();
            Pen MyPenBlue = new Pen(Color.Blue, 5);


            x1 = Convert.ToInt32(textBox1.Text);
            y1 = Convert.ToInt32(textBox2.Text);
            x2 = Convert.ToInt32(textBox3.Text);
            y2 = Convert.ToInt32(textBox4.Text);
            Rectangle tempRect = new Rectangle(x1, y1, x2, y2);
            DrawInterface.Clear(Color.LightGray);
            DrawInterface.DrawRectangle(MyPenBlue, tempRect);
        }


        private void PicturePie_Click(object sender, EventArgs e)
        {
            int x1, y1, x2, y2;
            Graphics DrawInterface = panel1.CreateGraphics();
            Pen MyPenOrange = new Pen(Color.Orange, 5);


            x1 = Convert.ToInt32(textBox1.Text);
            y1 = Convert.ToInt32(textBox2.Text);
            x2 = Convert.ToInt32(textBox3.Text);
            y2 = Convert.ToInt32(textBox4.Text);
            Rectangle temp = new Rectangle(x1, y1, x2, y2);


            DrawInterface.Clear(Color.LightGray);
            DrawInterface.DrawPie(MyPenOrange, temp, 90, 270);
        }
    }
}

阅读(1258) | 评论(0) | 转发(0) |
0

上一篇:用C#画滑动的直线

下一篇:用C#画直线

给主人留下些什么吧!~~