Using Using Using Using Using Using Using Using Namespace Public Partial Class

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

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 paint2
{
public partial class Form1 : Form
{
Pen p;
int x = 0;
int y = 0;
Graphics g;
bool start;
bool paint = false;
SolidBrush color;
Color ca;
public Form1()
{
InitializeComponent();
g = convas.CreateGraphics();
p = new Pen(maincolor.BackColor,4);
}

private void pictureBox3_Click(object sender, EventArgs e)


{
p.Color = yellow.BackColor;
maincolor.BackColor = yellow.BackColor;
}

private void pictureBox2_Click(object sender, EventArgs e)


{
p.Color = purple.BackColor;
maincolor.BackColor = purple.BackColor;
}

private void convas_MouseDown(object sender, MouseEventArgs e)


{
start = true;
}private void convas_MouseLeave(object sender, EventArgs e)
{
start = false;
x = 0;
y = 0; }
private void panel1_MouseMove(object sender, MouseEventArgs e)
{
if (start)
{
if (x > 0 && y > 0)
{
g.DrawLine(p, x, y, e.X, e.Y); }
x = e.X;
y = e.Y;}
}
private void blue_Click(object sender, EventArgs e)
{
p.Color = blue.BackColor;
maincolor.BackColor = blue.BackColor;}
private void red_Click(object sender, EventArgs e)
{
p.Color = red.BackColor;
maincolor.BackColor = red.BackColor;
}

private void green_Click(object sender, EventArgs e)


{
p.Color = green.BackColor;
maincolor.BackColor = green.BackColor;
}

private void pictureBox7_Click(object sender, EventArgs e)


{
p.Color = black.BackColor;
maincolor.BackColor = black.BackColor;
}
private void convas_MouseDown(object sender, MouseEventArgs e)
{
paint = true;
}

private void convas_MouseUp(object sender, MouseEventArgs e)


{
paint = false;
}

private void button1_Click_1(object sender, EventArgs e)


{
p.Color = Color.White;
}
private void Form1_MouseMove(object sender, MouseEventArgs e)
{
private void convas_MouseMove(object sender, MouseEventArgs e)
{ if (paint)
{
if (er.Text == "Eraiser")
{

int rsize = Convert.ToInt32(tberasier.Text);


Graphics g = convas.CreateGraphics();
color = new SolidBrush(Color.Red);
g.FillEllipse(color, e.X - rsize / 2, e.Y - rsize / 2, rsize, rsize);
}
else
{
int rsize = Convert.ToInt32(tberasier.Text);
Graphics g = convas.CreateGraphics();
color = new SolidBrush(Color.White);
g.FillEllipse(color, e.X - rsize / 2, e.Y - rsize / 2, rsize, rsize);
} }}
private void button2_Click(object sender, EventArgs e)
{
ColorDialog c = new ColorDialog();
if (c.ShowDialog() == DialogResult.OK)
{

p.Color = c.Color;

}
private void button3_Click(object sender, EventArgs e)
{
p.Color = Color.White;
p.Width = 10;

private void button4_Click(object sender, EventArgs e)


{
//p.Color = Color.White;
p.Width = 20;
ColorDialog c = new ColorDialog();
if (c.ShowDialog() == DialogResult.OK)
{
//panel1.BackColor = c.Color;
p.Color = c.Color;}
}
Lab Manual

Of

Enterprise & Application Development

Submitted to………….Ma’am Misbah Naz

Submitted By

Sehrish Rubi.............................Info.Tech 16037


Fareeha Firdous........................Info.Tech 16035
Zarka Amjad.............................Info.Tech 16045
Department...............................................CS-IT
Semester…………………..............................….6 th

You might also like