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 LV7___Zadatak_2
- {
- public partial class Form1 : Form
- {
- Graphics g;
- Pen p;
- public Form1()
- {
- InitializeComponent();
- g = pbDrawing.CreateGraphics();
- }
- private void pbDrawing_Click(object sender, EventArgs e)
- {
- }
- private void pbDrawing_MouseUp(object sender, MouseEventArgs e)
- {
- if (rbRed.Checked == true)
- {
- p = new Pen(Color.Red, sbThickness.Value);
- }
- else if (rbGreen.Checked == true)
- {
- p = new Pen(Color.Green, sbThickness.Value);
- }
- else if (rbBlue.Checked == true)
- {
- p = new Pen(Color.Blue, sbThickness.Value);
- }
- if (rbCircle.Checked == true)
- {
- Circle c = new Circle();
- c.draw(g, p, e.X, e.Y);
- }
- else if (rbSquare.Checked == true)
- {
- Square s = new Square();
- s.draw(g, p, e.X, e.Y);
- }
- else if (rbTriangle.Checked == true)
- {
- Triangle t = new Triangle();
- t.draw(g, p, e.X, e.Y);
- }
- }
- }
- class Circle
- {
- int r;
- public Circle()
- {
- r = 10;
- }
- public void draw(Graphics g, Pen p, int x, int y)
- {
- g.DrawEllipse(p, x, y, r, r);
- }
- }
- class Square
- {
- int a, b;
- public Square()
- {
- a = 10;
- b = 10;
- }
- public void draw(Graphics g, Pen p, int x, int y)
- {
- g.DrawRectangle(p, x, y, a, b);
- }
- }
- class Triangle
- {
- int a;
- public Triangle()
- {
- }
- public void draw(Graphics g, Pen p, int x, int y)
- {
- Point[] points = { new Point(x, y), new Point(x + 90, y), new Point(x + 40, y + 90) };
- g.DrawPolygon(p, points);
- }
- }
- }
Add Comment
Please, Sign In to add comment