You are on page 1of 60

DĐZĐ ĐLE ĐLGĐLĐ BASĐT BĐR PROGRAM

int[] dizi ={ -3, 5, 8 };


dizi[1] = 12;
MessageBox.Show(dizi[1].ToString());

DĐZĐ ĐLE ĐLGĐLĐ PROGRAM

int[] dizi =new int[5];


dizi[0] = 10;
dizi[1] = 12;

MessageBox.Show(dizi[0].ToString() + dizi[1].ToString());

ÇOK BOYUTLU DĐZĐ ĐLE ĐLGĐLĐ PROGRAM

private void button1_Click(object sender, EventArgs e)


{
int[,] dizi =new int[2,2];
dizi[0,0] = 5;
dizi[0,1] = 4;
dizi[1, 0] = 1;
dizi[1, 1] = 17;
MessageBox.Show(dizi[0, 0].ToString() + dizi[0, 1].ToString() +
dizi[1, 0].ToString() + dizi[1, 1].ToString());

ÇOK BOYUTLU DĐZĐDE BOŞLUK BIRAKMANIN YÖNTEMĐ

private void button1_Click(object sender, EventArgs e)


{
int[,] dizi =new int[2,2];
dizi[0,0] = 5;
dizi[0,1] = 4;
dizi[1, 0] = 1;
dizi[1, 1] = 17;
MessageBox.Show(dizi[0, 0].ToString() + " " + dizi[0,
1].ToString() + " " + dizi[1, 0].ToString() + " " + dizi[1, 1].ToString() +
" ");

AÇIKLAMA SATIRI YAPMAK ĐÇĐN YÖNTEM

// ĐŞARETĐNĐ KOYDUĞUNUZDA AÇIKLAMA OLARAK KABUL EDER.FAKAT SADECE


KULLANILDIĞI SATIRDA GEÇERLĐDĐR.
/* KOYARAK AÇIKLAMAYI YAZIP */ ĐLE KAPATARAK ĐSTEDĐĞĐMĐZ ĐKĐ SATIRIN
ARASINI AÇIKLAMA OLARAK YAPABĐLĐRSĐNĐZ.
BOOL DEĞĐŞKENLERĐ ANLATAN BĐR PROGRAM
(PARSE ĐLE NASIL STRING VE INT ARASINDA GEÇĐŞ YAPTIĞINA DĐKKAT ET!)

int a = int.Parse(textBox1.Text);
int b = int.Parse(textBox2.Text);
bool durum = a == b;
if (durum == false)
MessageBox.Show("sayılar eşit değil!");
else MessageBox.Show("sayılar eşit:)");

BOOL DEĞĐŞKENLERĐ ANLATAN BĐR PROGRAM


(DOĞRUDAN DEĞER ALIYOR)

int a = int.Parse(textBox1.Text);
int b = int.Parse(textBox2.Text);
bool durum = a == b;
MessageBox.Show(durum.ToString());

OBJECT DEĞĐŞKENLERĐ ANLATAN BĐR PROGRAM


(object türlerini mutlaka bir türe çevirerek işlem yapmalıyız!)

object a = textBox1.Text;
object b = textBox2.Text;
object c = a.ToString() + b.ToString();
MessageBox.Show(c.ToString());

KUTULAMA DENĐLEN BĐR TEKNĐKLE YAPILAN BĐR PROGRAM(BOXING)

int a = 3;
int b = 2;
int c = (int)a / b;
MessageBox.Show(c.ToString());

PUBLĐC STRUCT YAPISINI ANLAMA

Public Struct bilgisayar


{ int ram;
Int harddisk;
String marka;
Bool siyah;
}
Gibi bir örnekle açıklamak mümkün.
PUBLĐC STRUCT YAPISINI ANLAMA

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace deneme_3.hafta
{
public partial class Form1 : Form
{
Bu kısımda struct değişkenini açıklamak için değişken tanımladık.
Burada public değerini kullandığımıza dikkat edin.

public struct bilgisayar


{
public int ram;
public int harddisk;
public string marka;
public bool siyah;

}
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)


{

private void button1_Click(object sender, EventArgs e)


{

bilgisayar yenibilgisayar = new bilgisayar();


yenibilgisayar.ram = int.Parse(textBox1.Text);
yenibilgisayar.harddisk = int.Parse(textBox2.Text);
yenibilgisayar.marka = "casper";
yenibilgisayar.siyah = true;
MessageBox.Show(yenibilgisayar.marka +
yenibilgisayar.siyah.ToString() + yenibilgisayar.ram.ToString() + "Mb Ram"
+ yenibilgisayar.harddisk.ToString() + " Gb Harddisk");

}
}
}
FONKSĐYON YAPISINI ANLAMA

BUTTON’A CLICK OLARAK VERMEK ĐLE ALAN BULUNABĐLĐR.AMA BUNU FONKSĐYON OLARAK
TANIMLAMAK DAHA KULLANILABĐLĐR OLUR.

int yükseklik = int.Parse(textBox1.Text);


int boy = int.Parse(textBox2.Text);
int alan = boy * yükseklik;
MessageBox.Show(alan.ToString());

FONKSĐYON YAPISINI OLUŞTURARAK ANLAMA

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace deneme_3.hafta
{
public partial class Form1 : Form
{
public int dikdörtgenin_alanı(int yükseklik, int boy)
{int alan=yükseklik*boy;
return alan;
}

public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)


{

private void button1_Click(object sender, EventArgs e)


{
int diklan = dikdörtgenin_alanı(6, 5);
MessageBox.Show(diklan.ToString());

}
}
}
FONKSĐYON YAPISINI OLUŞTURARAK TEXTBOXTAN DEĞER ALARAK PROGRAM YAZMA

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace deneme_3.hafta
{
public partial class Form1 : Form
{
public int dikdörtgenin_alanı(int yükseklik, int boy)
{int alan=yükseklik*boy;
return alan;
}

public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)


{

private void button1_Click(object sender, EventArgs e)


{
int diklan = dikdörtgenin_alanı(6, 5);
MessageBox.Show(diklan.ToString());

private void button2_Click(object sender, EventArgs e)


{
int yükseklik = int.Parse(textBox1.Text);
int boy = int.Parse(textBox2.Text);
int sonuç = dikdörtgenin_alanı(yükseklik, boy);
MessageBox.Show(sonuç.ToString());

}
}
}
4.HAFTA DERSĐ:KARŞILAŞTIRMA KOMUTLARI
FONKSĐYON YAPISINI OLUŞTURARAK TEXTBOXTAN DEĞER ALARAK PROGRAM YAZMA

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace _4.hafta_deneme
{
public partial class Form1 : Form
{
public decimal üçgenin_alanı(decimal a, decimal h)
{

decimal alan;
alan = (a * h) / 2;
return alan;
}
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)


{
decimal uzunluk = decimal.Parse(textBox1.Text);
decimal yükseklik = decimal.Parse(textBox2.Text);
label1.Text = üçgenin_alanı(uzunluk, yükseklik).ToString();
}
}
}

ĐF YAPISI

Kullanımı:

If (karşılaştırma)
{Eğer karşılaştırma doğru ise}
Else
{Eğer karşılaştırma yanlış ise}
if (comboBox1.SelectedItem.ToString() == "ESKĐŞEHĐR")
{
MessageBox.Show("Seçtiğiniz il eskişehirdir.");
}
else
{
MessageBox.Show("Farklı bir il seçtiniz");
}

Buradaki != ifadesine dikkat edin.Bu ifade durumun tersi olarak gösterir.


Yani programın “Eskişehir ise” yerine “Eskişehir değil ise” olarak
algılamasını sağlar.
if (comboBox1.SelectedItem.ToString() != "ESKĐŞEHĐR")
{
MessageBox.Show("Seçtiğiniz il eskişehirdir.");
}

FONKSĐYON YAPISINI OLUŞTURARAK TEXTBOXTAN DEĞER ALARAK PROGRAM YAZMA

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace _4.hafta_deneme
{
public partial class Form1 : Form
{
public decimal üçgenin_alanı(decimal a, decimal h)
{

decimal alan;
alan = (a * h) / 2;
return alan;
}
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)


{

private void button1_Click_1(object sender, EventArgs e)


{
if (int.Parse(textBox1.Text) >= int.Parse(textBox2.Text))
{
MessageBox.Show("birinci sayı büyük veya eşit");

}
}

}
VE KULLANARAK ĐF DÖNGÜSÜ KULLANARAK PROGRAM YAZMA

if (int.Parse(textBox1.Text) == 5 && int.Parse(textBox2.Text) == 7)


{
MessageBox.Show("sayı bir =5 ve sayı iki=7 dir.");
}
ĐF DÖNGÜSÜ YERĐNE BOOL DEĞĐŞKEN KULLANARAK PROGRAM YAZMA

int a = int.Parse(textBox1.Text);
int b=int.Parse(textBox2.Text);
bool durum;
durum = a > b;
if (durum)
MessageBox.Show("Birinci sayı ikinci sayıdan büyük");
UNUTULMAMASI GEREKEN BAZI KARŞILAŞTIRMALAR

Eşit ise “==”


Eşit değil ise “!=”
Değil “!”

Bağlaçlar
Ve “&&”
Veya “||”

SWĐTCH VE CASE ,BREAK KOMUTLARI

: işareti etiket manasına gelir.


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace _4.hafta_deneme
{
public partial class Form1 : Form
{
public decimal üçgenin_alanı(decimal a, decimal h)
{

decimal alan;
alan = (a * h) / 2;
return alan;
}
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)


{

private void button1_Click_1(object sender, EventArgs e)


{
switch (comboBox1.SelectedItem.ToString())
{case "ESKĐŞEHĐR":
MessageBox.Show("ĐL ESKĐŞEHĐR");
break;
case "ANKARA":
MessageBox.Show("ĐL ANKARA");
break;
case "ĐSTANBUL":
MessageBox.Show("ĐL ĐSTANBUL");
break;
case "RĐZE":
MessageBox.Show("ĐL RĐZE");
break;

}
}

DEFAULT KOMUTU
Burada komutla seçim dışı bırakılan bir eleman için default kullanılır.

{
switch (comboBox1.SelectedItem.ToString())
{case "ESKĐŞEHĐR":
MessageBox.Show("ĐL ESKĐŞEHĐR");
break;
case "ANKARA":
MessageBox.Show("ĐL ANKARA");
break;
default:
MessageBox.Show("BAŞKA BĐR ĐL SEÇĐLDĐ");
break;
}
ĐKĐ CASE DEĞERĐNĐ BĐR ARADA KULLANMA
{
switch (comboBox1.SelectedItem.ToString())
{case "ESKĐŞEHĐR":
case "ANKARA":
MessageBox.Show("BÖLGE ĐÇ ANADOLU");
break;
case "RĐZE":
MessageBox.Show("KARADENĐZ BÖLGESĐ");
break;

default:
MessageBox.Show("BAŞKA BĐR ĐL SEÇĐLDĐ");
break;

GOTO KOMUTU ĐLE HERHANGĐ BĐR YERE ATLAMA YAPMA

{
if (comboBox1.SelectedItem.ToString() == "ESKĐŞEHĐR")
goto ESKĐŞEHĐR;

MessageBox.Show("ATLANAN YER");

ESKĐŞEHĐR:
MessageBox.Show("Đl ESKĐŞEHĐR");

VĐZE FĐNAL HESAPLAYAN BĐR PROGRAM

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace _5.hafta
{
public partial class Form1 : Form
{

double ortalama(double vize,double final)


{
double ortalama=(vize*0.4+final*0.6);
return ortalama;

public Form1()

{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)


{
double vizenotu=double.Parse(textBox1.Text);
double finalnotu=double.Parse(textBox2.Text);
double sonuç=ortalama(vizenotu , finalnotu);
textBox3.Text=sonuç.ToString();
if (sonuç>=50)
{label5.Text="Başarılı";

}
else
{label5.Text="Başarısız";
}
}

private void Form1_Load(object sender, EventArgs e)


{

}
}
}

FOR DÖNGÜSÜ KULLANILIŞI

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace _5.hafta
{
public partial class Form1 : Form
{
public Form1()

{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)


{
for (int sayaç = 0; sayaç < 15; sayaç ++)
{
MessageBox.Show("Döngü="+sayaç.ToString());

}
}

private void Form1_Load(object sender, EventArgs e)


{

}
}
}

FOR DÖNGÜSÜ KULLANILIŞI mod2’nin kullanılışına dikkat

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace _5.hafta
{
public partial class Form1 : Form
{
public decimal toplam;

public Form1()

{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)


{
for (int sayaç = 0; sayaç <= 5; sayaç ++)
{
int kalan=sayaç%2;

if(kalan!=0)
{
toplam = toplam + sayaç;
}
}
textBox1.Text = toplam.ToString();
}

private void Form1_Load(object sender, EventArgs e)


{

}
}
}

FOR DÖNGÜSÜ KULLANILIŞI


Đki sayı arasında kalan sayıların toplamını alan bir program

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace _5.hafta
{
public partial class Form1 : Form
{
public decimal toplam;

public Form1()

{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)


{

int başlangıç = int.Parse(textBox1.Text);


int bitiş = int.Parse(textBox2.Text);
for (int i=başlangıç; i <= bitiş; i++)
{
toplam =i+ toplam;
}
MessageBox.Show("iki sayı arasındaki sayıların toplamı=" +
toplam);
}

private void Form1_Load(object sender, EventArgs e)


{

}
}
}

6.hafta

sing System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)


{
listBox1.Items.Add(textBox1.Text);
}
private void button2_Click(object sender, EventArgs e)
{
for (int i = 0; i < listBox1.Items.Count; i++)
{
listBox2.Items.Add(listBox1.Items[i]);

}
}
}
}

PROGRAMIN ÇALIŞMA HALĐ

AYNI ĐŞLEM FOREACH KOMUTU ĐLE DE YAPILABĐLĐR. AŞAĞIDAKĐ


ÖRNEKTE BUNU GÖRÜYORUZ.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)


{
listBox1.Items.Add(textBox1.Text);
}

private void button2_Click(object sender, EventArgs e)


{
foreach (object döngü in listBox1.Items)
{
listBox2.Items.Add(döngü);
}
}
}
}

FOREACH ĐLE BAŞKA BĐR ÖRNEK

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)


{
int[] dizi = new int[10];
for (int i = 0; i <= dizi.Length-1 ; i++)
{
dizi[i] = i;
}
foreach (object döngü in dizi)
{
listBox1.Items.Add(döngü);
}
}

}
}

FOREACH ĐLE BAŞKA BĐR ÖRNEK

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Collections;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)


{
ArrayList dizi = new ArrayList();
dizi.Add("eskişehir");
dizi.Add(26);
dizi.Add(15.85);
dizi.Add(true);
foreach (object döngü in dizi)
{
listBox1.Items.Add(döngü);
}
}

}
}
8.hafta çalışması

HATA YAKALAMA
Try-catch metodu ve hata yakalama

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)


{
try
{
if (textBox1.Text == ""|| textBox2.Text=="")
{ throw new Exception("Bu yext kutusunu boş bırakamazsın");
}

int i, j;
i = int.Parse(textBox1.Text);
j = int.Parse(textBox2.Text);
if(i>100||i<0)
{
throw new Exception("Not sıfır ile yüz arasında
olmalıdır.");
}
decimal k = (decimal)i / j;
label1.Text = k.ToString();

}
catch(Exception hata)
{
MessageBox.Show(hata.Message);
}
}
}
}
Finally bloğu
(Hata olsa da olmasa da çalışır)

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)


{
try
{
if (textBox1.Text == "" || textBox2.Text == "")
{ throw new Exception("Bu yext kutusunu boş bırakamazsın");
}

int i, j;
i = int.Parse(textBox1.Text);
j = int.Parse(textBox2.Text);
if (i > 100 || i < 0)
{
throw new Exception("Not sıfır ile yüz arasında
olmalıdır.");
}
decimal k = (decimal)i / j;
label1.Text = k.ToString();

}
catch (Exception hata)
{
MessageBox.Show(hata.Message);
}
finally
{
MessageBox.Show("Program çalıştı!");
}
}
}
}
Basit bir şifreleme programı

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsApplication2
{
public partial class Form1 : Form
{
int sayaç = 0;
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)


{
try
{

string password1 = textBox1.Text;


string password = "abc";
if (password1=="")
{ throw new Exception("Bu kısmı boş bırakamazsınız!"); }

if (password1==password)
{ throw new Exception("Programa hoşgeldiniz."); }

else
{sayaç += 1;
throw new Exception("Şifreniz hatalı!");

}
catch
(Exception hata)
{
MessageBox.Show(hata.Message);

}
finally
{
if (sayaç == 3)
{
MessageBox.Show("3 kere hata yaptınız, program
kapatılıyor.");
Application.Exit();
}
}

}
}
}

Matematik Fonksiyonları yazmak üzerine bir program

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsApplication2
{
public partial class Form1 : Form
{

public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)


{
double x;
x = Math.Floor(Convert.ToDouble(textBox1.Text));
label1.Text = x.ToString();

}
}
}

Rastgele sayı bulmak için bir program


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsApplication2
{
public partial class Form1 : Form
{

public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)


{
double x;
Random rastgelesayı = new Random();
x = rastgelesayı.Next();
label1.Text = x.ToString();

}
}
}

SAYISAL LOTO PROGRAMI (BASĐT)


(%49 ĐFADESĐ 1 ĐLE 49 ARASINDA SAYI VERĐLECEĞĐNĐ
GÖSTERĐYOR.)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsApplication2
{
public partial class Form1 : Form
{

public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)


{
double x;
Random rastgelesayı = new Random();
x = rastgelesayı.Next()%49;
label1.Text = x.ToString();

}
}
}
SAYISAL LOTO PROGRAMI (PROFESYÖNEL)
(%49 ĐFADESĐ 1 ĐLE 49 ARASINDA SAYI VERĐLECEĞĐNĐ
GÖSTERĐYOR.)

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsApplication2
{
public partial class Form1 : Form
{

public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)


{
listBox1.Items.Clear();
int[]loto=new int[6];
int i, j;
Random rnd = new Random();
loto[0] = rnd.Next() % 49 + 1;
listBox1.Items.Add(loto[0].ToString());
for (i = 1; i <= 5; i++)
{
loto[i] = rnd.Next() % 49 + 1;
for (j = 0; j <= i - 1; j++)
{
if (loto[i] == loto[j])
{
loto[i] = rnd.Next() % 49 + 1;
j = -1;
}
}
listBox1.Items.Add(loto[i].ToString());}

}
}
}

GEYĐK BĐR PROGRAM

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsApplication2
{
public partial class Form1 : Form
{

public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)


{
label1.Text = "";
string değer1 = textBox1.Text;
string değer2 = textBox2.Text;
int varyok;
varyok = string.Compare(değer1, değer2);
if (varyok == -1)
{
label1.Text = "Evet içinde var";

}
else if (varyok == 0)
{
label1.Text = "Đkisi aynı";

}
else { label1.Text = "Hayır içinde yok"; }

}
}
}

TARĐH KONTROLLERĐ ÖRNEĞĐ

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace _9.hafta
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)


{
textBox1.Text = dateTimePicker1.Value.ToString();
}
}
}

TARĐH KONTROLLERĐ ÖRNEĞĐ

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace _9.hafta
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)


{
DateTime tarih = new DateTime();
DateTime yenitarih = new DateTime();
tarih = dateTimePicker1.Value;
yenitarih = tarih.AddDays(20);
textBox1.Text = yenitarih.ToString();
}
}
}

LĐSTE KUTUSU VE ARRAY DĐZĐLER

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Collections;

namespace _9.hafta
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)


{
ArrayList dizi = new ArrayList();
dizi.AddRange(listBox1.Items);
dizi.Sort();
listBox1.Items.Clear();
foreach (string takım in dizi)
{
listBox1.Items.Add(takım);
}

}
}
}

DOSYA ARATTIRMA PROGRAMI

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Collections;
using System.IO;

namespace _9.hafta
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)


{

string[] dosyaadı =
Directory.GetFileSystemEntries("C:\\windows", "*.txt");
foreach (string eklenen in dosyaadı)
{
listBox1.Items.Add(eklenen);
}
}
}
}

DOSYA AÇMA VE YENĐĐ DOSYA PROGRAMI

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace WindowsApplication3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)


{
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
FileStream dosyaakımı = new
FileStream(saveFileDialog1.FileName, FileMode.OpenOrCreate);
StreamWriter yaz = new StreamWriter(dosyaakımı);
yaz.WriteLine(textBox1.Text);
yaz.Close();
}
}

private void button2_Click(object sender, EventArgs e)


{
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
FileStream dosyaakımı = new
FileStream(openFileDialog1.FileName, FileMode.Open);
StreamReader oku = new StreamReader(dosyaakımı);
textBox1.Text = oku.ReadLine();
oku.Close();
}
}
}
}

DOSYA AÇMA KAPATMA ÜZERĐNE HARĐKA BĐR ÖRNEK


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace WindowsApplication4
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)


{
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
FileStream dosya = new
FileStream(saveFileDialog1.FileName,FileMode.OpenOrCreate);
BinaryWriter yazıcı = new BinaryWriter(dosya);
int tamsayı = int.Parse(textBox1.Text);
decimal desayı = decimal.Parse(textBox2.Text);
string yazi = textBox3.Text;
yazıcı.Write(tamsayı);
yazıcı.Write(desayı);
yazıcı.Write(yazi);
yazıcı.Close();
}
}

private void button2_Click(object sender, EventArgs e)


{
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
FileStream dosya = new FileStream(openFileDialog1.FileName,
FileMode.Open);
BinaryReader okuyucu = new BinaryReader(dosya);
int tamsayı = okuyucu.ReadInt32();
decimal desayı = okuyucu.ReadDecimal();
string yazi = okuyucu.ReadString();
okuyucu.Close();
textBox1.Text = tamsayı.ToString();
textBox2.Text = desayı.ToString();
textBox3.Text = yazi;

}
}
}
}

BUTTON KULLANIMI ĐLE ĐLGĐLĐ BĐR ÖRNEK


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace _10.hafta_dersi
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)


{

private void button1_Click(object sender, EventArgs e)


{
MessageBox.Show("Ok. tıklandı.");
}

private void button2_Click(object sender, EventArgs e)


{
Application.Exit();
}

private void Form1_KeyDown(object sender, KeyEventArgs e)


{
if (e.KeyCode == Keys.P&&e.Modifiers==Keys.Control)
{ MessageBox.Show("Yazdırılıyor"); }

}
}
}

FORMLAR ÜZERĐNE BĐR ÇALIŞMA


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace _10.hafta_dersi
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)


{

private void button1_Click(object sender, EventArgs e)


{
MessageBox.Show("Ok. tıklandı.");
}

private void button2_Click(object sender, EventArgs e)


{
Application.Exit();
}

private void Form1_KeyDown(object sender, KeyEventArgs e)


{
if (e.KeyCode == Keys.P&&e.Modifiers==Keys.Control)
{ MessageBox.Show("Yazdırılıyor"); }

private void yENĐToolStripMenuItem_Click(object sender, EventArgs


e)
{
Form2 yeniform = new Form2();
yeniform.MdiParent = this;
yeniform.Show();
}

private void kAPATToolStripMenuItem_Click(object sender, EventArgs


e)
{
Application.Exit();
}
}
}
Yardım menüsü için

Helpprovider sürükle sonra form1 in load olayına şu kodu yaz

private void Form1_Load(object sender, EventArgs e)


{
helpProvider1.SetHelpString(textBox1, "Bu kutuya adını yaz");
helpProvider1.SetHelpString(textBox2, "Bu kutuya soyadını
yaz");
}

Addrange metodu ile dizi ekleme örneği

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace _11.hafta
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void BTN_EKLE_Click(object sender, EventArgs e)


{
string eklenen = txt_eklenecek.Text;
listBox1.Items.Add(eklenen);
}

private void btn_dizi_ekle_Click(object sender, EventArgs e)


{
string[] dizi ={ "Kütahya", "Bursa", "Konya" };
listBox1.Items.AddRange(dizi);
}
}
}
LĐSTBOX TEMĐZLEME YÖNTEMĐ

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace _11.hafta
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void BTN_EKLE_Click(object sender, EventArgs e)


{
string eklenen = txt_eklenecek.Text;
listBox1.Items.Add(eklenen);
}

private void btn_dizi_ekle_Click(object sender, EventArgs e)


{
string[] dizi ={ "Kütahya", "Bursa", "Konya" };
listBox1.Items.AddRange(dizi);
}

private void btn_temizle_Click(object sender, EventArgs e)


{
listBox1.Items.Clear();
}
}
}

EKLE SĐL ÖZELLĐKLERĐ VE KULLANILIŞI

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace _11.hafta
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void BTN_EKLE_Click(object sender, EventArgs e)


{
string eklenen = txt_eklenecek.Text;
listBox1.Items.Insert(0, eklenen);
}

private void btn_dizi_ekle_Click(object sender, EventArgs e)


{
string[] dizi ={ "Kütahya", "Bursa", "Konya" };
listBox1.Items.AddRange(dizi);
}
private void btn_temizle_Click(object sender, EventArgs e)
{
listBox1.Items.Clear();
}

private void listBox1_BindingContextChanged(object sender,


EventArgs e)
{

private void Form1_Load(object sender, EventArgs e)


{
lbl_elemansayisi.Text = listBox1.Items.Count.ToString();
}

private void btn_sil_Click(object sender, EventArgs e)


{
listBox1.Items.RemoveAt(listBox1.SelectedIndex);
}
}
}

TEK KANALLA ÇALIŞAN PROGRAM


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Threading;

namespace _12.hafta_çalışma1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)


{
for (int i = 0; i <= 100; i++)
{
progressBar1.Value = i;
Thread.Sleep(30);
}
}
}
}

ÇĐFT KANAL YAPMAK

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Threading;

namespace _12.hafta_çalışma1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

void basla()
{
for (int i = 0; i <= 100; i++)
{
progressBar1.Value = i;
Thread.Sleep(30);
}
}

private void button1_Click(object sender, EventArgs e)


{
Thread kanal = new Thread(new ThreadStart(basla));
kanal.Start();
}

private void Form1_Load(object sender, EventArgs e)


{
Control.CheckForIllegalCrossThreadCalls = false;
}
}
}

3 KANALLI BĐR PROGRAM HAZIRLANMASI

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Threading;

namespace _12.hafta_çalışma1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

void basla()
{
for (int i = 0; i <= 100; i++)
{
progressBar1.Value = i;
label1.Text = i.ToString();
Thread.Sleep(30);
}
}

void basla2()
{
for (int i = 0; i <= 100; i++)
{
progressBar2.Value = i;
label2.Text = i.ToString();
Thread.Sleep(60);
}
}
private void button1_Click(object sender, EventArgs e)
{
Thread kanal = new Thread(new ThreadStart(basla));
kanal.Start();
}

private void Form1_Load(object sender, EventArgs e)


{
Control.CheckForIllegalCrossThreadCalls = false;
}

private void button2_Click(object sender, EventArgs e)


{
Thread kanal2 = new Thread(new ThreadStart(basla2));
kanal2.Start();
}
}
}

Dosya kaydetme açma vs.


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace _12.hafta_çalışma1
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}

private void btn_kaydet_Click(object sender, EventArgs e)


{
DialogResult durum = saveFileDialog1.ShowDialog();
if (durum == DialogResult.OK)
{string dosya_adi = saveFileDialog1.FileName+".rtf";

richTextBox1.SaveFile(dosya_adi); }

}
}
}

YAZICI AYARLARI ĐLE ĐLGĐLĐ BĐR PROGRAM


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace _12.hafta_çalışma1
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}

private void btn_kaydet_Click(object sender, EventArgs e)


{
DialogResult durum = saveFileDialog1.ShowDialog();
if (durum == DialogResult.OK)
{string dosya_adi = saveFileDialog1.FileName+".rtf";

richTextBox1.SaveFile(dosya_adi); }

private void btn_ac_Click(object sender, EventArgs e)


{
DialogResult durum = openFileDialog1.ShowDialog();
if(durum==DialogResult.OK)
{ string dosya_adi = saveFileDialog1.FileName;
richTextBox1.LoadFile(dosya_adi);

private void btn_font_Click(object sender, EventArgs e)


{
DialogResult fontdurum = fontDialog1.ShowDialog();
if (fontdurum == DialogResult.OK)
{
richTextBox1.SelectionFont = fontDialog1.Font;
}
}

private void btn_renksec_Click(object sender, EventArgs e)


{
DialogResult renkdurum = colorDialog1.ShowDialog();
if (renkdurum == DialogResult.OK)
{
richTextBox1.SelectionColor = colorDialog1.Color;
}
}

private void btn_yazdir_Click(object sender, EventArgs e)


{
printDialog1.ShowDialog();
printDialog1.Document = printDocument1;
printDocument1.Print();

private void printDocument1_PrintPage(object sender,


System.Drawing.Printing.PrintPageEventArgs e)
{
FontFamily yazi = new FontFamily("arial");
Font yazitipi = new Font(yazi, 10, FontStyle.Bold);
SolidBrush kalem=new SolidBrush(Color.Blue);
e.Graphics.DrawString(richTextBox1.Text, yazitipi, kalem, 50,
100);
}

private void btn_onizleme_Click(object sender, EventArgs e)


{
printPreviewDialog1.ShowDialog();

private void btn_sayfa_yapisi_Click(object sender, EventArgs e)


{
pageSetupDialog1.ShowDialog();
printDocument1.DefaultPageSettings =
pageSetupDialog1.PageSettings;
}
}
}

TĐMER KONTROLÜNÜ KULLANAN BĐR PROGRAM


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace _12.hafta_çalışma1
{
public partial class Form3 : Form
{
public Form3()
{
InitializeComponent();
}

private void btn_aktif_et_Click(object sender, EventArgs e)


{
timer1.Enabled = true;

private void timer1_Tick(object sender, EventArgs e)


{
this.Close();
}
}
}

KES KOPYALA YAPIŞTIR YAPAN BĐR PROGRAM

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace _12.hafta_çalışma1
{
public partial class Form3 : Form
{
public Form3()
{
InitializeComponent();
}

private void btn_aktif_et_Click(object sender, EventArgs e)


{
timer1.Enabled = true;

private void timer1_Tick(object sender, EventArgs e)


{
this.Close();
}

private void richTextBox1_MouseDown(object sender, MouseEventArgs


e)
{
if(e.Button==MouseButtons.Right)
{
Clipboard.SetData("Text", richTextBox1.SelectedText);

private void kESToolStripMenuItem_Click(object sender, EventArgs e)


{
Clipboard.SetData("Text", richTextBox1.SelectedText);
richTextBox1.SelectedText = "";

private void kOPYALAToolStripMenuItem_Click(object sender,


EventArgs e)
{
Clipboard.SetData("Text", richTextBox1.SelectedText);

private void yAPIŞTIRToolStripMenuItem_Click(object sender,


EventArgs e)
{
richTextBox1.Text += Clipboard.GetData("Text");
}
}
}

PĐCTUREBOX TANIMLAMA

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace _13.hafta_çalışma1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)


{
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
pictureBox1.ImageLocation = openFileDialog1.FileName;
}
}

private void button2_Click(object sender, EventArgs e)


{
Application.Exit();
}

private void btn_kopyala_Click(object sender, EventArgs e)


{
Clipboard.SetImage(pictureBox1.Image);
}

private void btn_yapistir_Click(object sender, EventArgs e)


{
pictureBox2.Image = Clipboard.GetImage();
}
}
}

RESĐM DÖNDÜRME

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace _13.hafta_çalışma1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)


{
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
pictureBox1.ImageLocation = openFileDialog1.FileName;
}

private void button2_Click(object sender, EventArgs e)


{
Application.Exit();
}

private void btn_kopyala_Click(object sender, EventArgs e)


{
Clipboard.SetImage(pictureBox1.Image);
}

private void btn_yapistir_Click(object sender, EventArgs e)


{
pictureBox2.Image = Clipboard.GetImage();
}

private void btn_dondur_Click(object sender, EventArgs e)


{
pictureBox1.Image.RotateFlip(RotateFlipType.Rotate90FlipNone);
pictureBox1.Refresh();
}
}
}

NE OLURSA OLSUN TEK SLASH KULLANMA!

Dosya KAYDETME ĐŞLEMLERĐ (Resim


kullanımı)
kullanımı)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace _13.hafta_çalışma1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)


{
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
pictureBox1.ImageLocation = openFileDialog1.FileName;
}

private void button2_Click(object sender, EventArgs e)


{
Application.Exit();
}

private void btn_kopyala_Click(object sender, EventArgs e)


{
Clipboard.SetImage(pictureBox1.Image);
}

private void btn_yapistir_Click(object sender, EventArgs e)


{
pictureBox2.Image = Clipboard.GetImage();
}
private void btn_dondur_Click(object sender, EventArgs e)
{
pictureBox1.Image.RotateFlip(RotateFlipType.Rotate90FlipNone);
pictureBox1.Refresh();
}

private void btn_kaydet_Click(object sender, EventArgs e)


{
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{ pictureBox1.Image.Save(saveFileDialog1.FileName); }
}
}
}

Çizim yaptırma

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace _12.hafta_çalışma_2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void btn_cizgi_ciz_Click(object sender, EventArgs e)


{
Graphics resim = pictureBox1.CreateGraphics();
Pen kalem = new Pen(Color.Black, 3);
resim.DrawLine(kalem, 20, 30, 150, 90);
}
}
}

FARKLI ÇĐZGĐ VE ŞEKĐLLER

TARAMA YAPILAN BĐR ÖRNEK


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;

namespace _12.hafta_çalışma_2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();

private void btn_cizgi_ciz_Click(object sender, EventArgs e)


{
Graphics resim = pictureBox1.CreateGraphics();
Pen kalem = new Pen(Color.Black, 3);
kalem.DashStyle = DashStyle.DashDotDot;
resim.DrawLine(kalem, 20, 30, 150, 190);
resim.Dispose();
}

private void btn_dikdortgen_Click(object sender, EventArgs e)


{
Graphics resim = pictureBox1.CreateGraphics();
Pen kalem = new Pen(Color.Black, 3);
SolidBrush fırca = new SolidBrush(Color.Azure);
resim.DrawRectangle(kalem, 20, 30, 100, 150);
resim.FillRectangle(fırca, 20, 30, 100, 150);
resim.Dispose();
}

private void btn_daire_Click(object sender, EventArgs e)


{
Graphics resim = pictureBox1.CreateGraphics();
Pen kalem = new Pen(Color.Black, 3);
SolidBrush fırca = new SolidBrush(Color.Azure);
resim.DrawEllipse(kalem, 100, 100, 80, 80);
resim.Dispose();
}
}
}

PĐCTUREBOX’a yazı yazdırmayı sağlayan bir program

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;

namespace _12.hafta_çalışma_2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();

private void btn_cizgi_ciz_Click(object sender, EventArgs e)


{
Graphics resim = pictureBox1.CreateGraphics();
Pen kalem = new Pen(Color.Black, 3);
kalem.DashStyle = DashStyle.DashDotDot;
Point[] noktalar = new Point[4];
noktalar[0].X = 10;
noktalar[0].Y = 10;
noktalar[1].X = 150;
noktalar[1].Y = 180;
noktalar[2].X = 275;
noktalar[2].Y = 100;
noktalar[3].X = 350;
noktalar[3].Y = 300;

resim.DrawPolygon(kalem,noktalar);
resim.Dispose();

private void btn_dikdortgen_Click(object sender, EventArgs e)


{
Graphics resim = pictureBox1.CreateGraphics();
Pen kalem = new Pen(Color.Black, 3);
HatchBrush fırca = new HatchBrush(HatchStyle.DiagonalBrick,
Color.Azure,Color.AntiqueWhite);
resim.DrawRectangle(kalem, 20, 30, 100, 150);
resim.FillRectangle(fırca, 20, 30, 100, 150);
resim.Dispose();
}

private void btn_daire_Click(object sender, EventArgs e)


{
Graphics resim = pictureBox1.CreateGraphics();
Pen kalem = new Pen(Color.Black, 3);
SolidBrush fırca = new SolidBrush(Color.Black);
resim.DrawEllipse(kalem, 100, 100, 80, 80);
resim.Dispose();
}

private void btn_yazdir_Click(object sender, EventArgs e)


{
Graphics resim = pictureBox1.CreateGraphics();
Pen kalem = new Pen(Color.Black, 3);
SolidBrush fırca = new SolidBrush(Color.Black);
resim.DrawString(textBox1.Text, textBox1.Font, fırca, 40, 40);

}
}
}

SERBEST ÇĐZĐM YAPAN BĐR PROGRAM

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;

namespace _12.hafta_çalışma_2
{
public partial class Form1 : Form

{
public int x1;
public int y1;
bool cizim = false;
public int x2;
public int y2;

public Form1()
{
InitializeComponent();

private void btn_cizgi_ciz_Click(object sender, EventArgs e)


{
Graphics resim = pictureBox1.CreateGraphics();
Pen kalem = new Pen(Color.Black, 3);
kalem.DashStyle = DashStyle.DashDotDot;
Point[] noktalar = new Point[4];
noktalar[0].X = 10;
noktalar[0].Y = 10;
noktalar[1].X = 150;
noktalar[1].Y = 180;
noktalar[2].X = 275;
noktalar[2].Y = 100;
noktalar[3].X = 350;
noktalar[3].Y = 300;

resim.DrawPolygon(kalem,noktalar);
resim.Dispose();

private void btn_dikdortgen_Click(object sender, EventArgs e)


{
Graphics resim = pictureBox1.CreateGraphics();
Pen kalem = new Pen(Color.Black, 3);
HatchBrush fırca = new HatchBrush(HatchStyle.DiagonalBrick,
Color.Azure,Color.AntiqueWhite);
resim.DrawRectangle(kalem, 20, 30, 100, 150);
resim.FillRectangle(fırca, 20, 30, 100, 150);
resim.Dispose();
}

private void btn_daire_Click(object sender, EventArgs e)


{
Graphics resim = pictureBox1.CreateGraphics();
Pen kalem = new Pen(Color.Black, 3);
SolidBrush fırca = new SolidBrush(Color.Black);
resim.DrawEllipse(kalem, 100, 100, 80, 80);
resim.Dispose();
}

private void btn_yazdir_Click(object sender, EventArgs e)


{
Graphics resim = pictureBox1.CreateGraphics();
Pen kalem = new Pen(Color.Black, 3);
SolidBrush fırca = new SolidBrush(Color.Black);

resim.DrawString(textBox1.Text,new
Font("Arial",30,FontStyle.Bold,GraphicsUnit.Pixel), fırca, 40, 40);

private void pictureBox1_MouseDown(object sender, MouseEventArgs e)


{

x1 = e.X;
y1 = e.Y;
cizim = true;

private void pictureBox1_MouseMove(object sender, MouseEventArgs e)


{

private void pictureBox1_MouseUp(object sender, MouseEventArgs e)


{
if (cizim)
{
Graphics resim = pictureBox1.CreateGraphics();
Pen kalem = new Pen(Color.Black, 2);
Point nokta1 = new Point(x1, y1);
Point nokta2 = new Point(e.X, e.Y);
resim.DrawLine(kalem, nokta1, nokta2);
resim.Dispose();
}
}
}
}

You might also like