Using System; using System. Collections. Generic; using



Download 0,75 Mb.
bet5/6
Sana26.04.2022
Hajmi0,75 Mb.
#582493
1   2   3   4   5   6
Bog'liq
O\'quv amaliyot eldorga

Paint dasturini tuzing.
Yechish:
Dastur kodi:
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 kurs_ishi
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();

this.Width = 950;


this.Height = 700;
bm = new Bitmap(pic.Width,pic.Height);
g = Graphics.FromImage(bm);
g.Clear(Color.White);
pic.Image = bm;
}
Bitmap bm;
Graphics g;
bool paint = false;
Point px, py;
Pen p = new Pen(Color.Black,1);
Pen erase = new Pen(Color.White,10);
int index;
int x, y, sX, sY,cX,cY;

ColorDialog cd = new ColorDialog();


Color new_color;

private void pic_MouseDown(object sender, MouseEventArgs e)


{
paint = true;
py = e.Location;

cX = e.X;


cY = e.Y;

}


private void pic_MouseMove(object sender, MouseEventArgs e)
{
if(paint)
{
if(index==1)
{
px = e.Location;
g.DrawLine(p,px,py);
py = px;
}
if (index == 2)
{
px = e.Location;
g.DrawLine(erase, px, py);
py = px;
}
}
pic.Refresh();

x = e.X;
y = e.Y;


sX = e.X - cX;
sY = e.Y - cY;

}


private void pic_MouseUp(object sender, MouseEventArgs e)
{
paint = false;

sX = x - cX;


sY = y - cY;

if (index == 3)


{
g.DrawEllipse(p,cX,cY,sX,sY);
}
if (index == 4)
{
g.DrawRectangle(p, cX, cY, sX, sY);
}
if (index == 5)
{
g.DrawLine(p, cX, cY, x, y);
}
}

private void btn_pencil_Click(object sender, EventArgs e)


{
index = 1;
}

private void btn_eraser_Click(object sender, EventArgs e)


{
index = 2;
}

private void btn_ellipse_Click(object sender, EventArgs e)


{
index = 3;
}

private void btn_rect_Click(object sender, EventArgs e)


{
index = 4;
}

private void btn_line_Click(object sender, EventArgs e)


{
index = 5;
}

private void pic_Paint(object sender, PaintEventArgs e)


{
Graphics g = e.Graphics;

if (paint)


{
if (index == 3)
{
g.DrawEllipse(p, cX, cY, sX, sY);
}
if (index == 4)
{
g.DrawRectangle(p, cX, cY, sX, sY);
}
if (index == 5)
{
g.DrawLine(p, cX, cY, x, y);
}
}
}

private void btn_clear_Click(object sender, EventArgs e)


{
g.Clear(Color.White);
pic.Image = bm;
index = 0;
}

private void btn_color_Click(object sender, EventArgs e)


{
cd.ShowDialog();
new_color = cd.Color;
pic_color.BackColor = cd.Color;
p.Color = cd.Color;
}

}
}




Download 0,75 Mb.

Do'stlaringiz bilan baham:
1   2   3   4   5   6




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish