Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace WindowsFormsApplication11
- {
- public partial class Form1 : Form
- {
- Bitmap b;
- Graphics g;
- Pen p;
- Line line1, line2;
- //Rectangle rec;
- public Form1()
- {
- InitializeComponent();
- Init();
- Draw();
- }
- private void Init()
- {
- line1 = new Line(100, 100, 250, 10);
- line2 = new Line(250, 10, 400, 100);
- //rec = new rectangle(100, 100, 400, 300);
- p = new Pen(Color.Chocolate, 2);
- b = new Bitmap(pictureBox1.Width, pictureBox1.Height);
- g = Graphics.FromImage(b);
- pictureBox1.Image = b;
- }
- private void pictureBox1_Click(object sender, EventArgs e)
- {
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- Draw();
- }
- public void Draw()
- {
- Pen p = new Pen(Color.Chocolate, 20);
- Bitmap b = new Bitmap(pictureBox1.Width, pictureBox1.Height);
- Graphics g = Graphics.FromImage(b);
- Point p1 = new Point(100, 100);
- Size s = new Size(300, 200);
- Rectangle r = new Rectangle(100, 100, 300, 200);
- g.DrawLine(p, 100, 100, 250, 10);
- g.DrawLine(p, 250, 10, 400, 100);
- g.DrawLine(p,450,30,600, 300);
- g.DrawLine(p,300,300, 450,30);
- g.DrawRectangle(p, r.x1, r.x2, r.y1, r.y2);
- pictureBox1.Image = b;
- }
- private void Draw(Line line)
- {
- g.DrawLine(p, line.x1, line.y1, line.x2, line.y2);
- }
- private void Draw(Rectangle r)
- {
- g.DrawRectangle(p, r.x1, r.x2, r.y1, r.y2);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement