• Sonuç bulunamadı

string yenisaatdeger; string yenidakikadeger; string yenisaniyedeger;

N/A
N/A
Protected

Academic year: 2022

Share "string yenisaatdeger; string yenidakikadeger; string yenisaniyedeger;"

Copied!
10
0
0

Yükleniyor.... (view fulltext now)

Tam metin

(1)

PC KAPATMA PROGRAMI

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 PCKapatma {

public partial class Form1 : Form {

public Form1() {

InitializeComponent();

}

private void timer1_Tick(object sender, EventArgs e) {

label1.Text = DateTime.Now.ToLongTimeString(); // Güncel saati yazdırma işlemi

if (label7.Text == DateTime.Now.ToLongTimeString()) // ayarlanan Saat ile güncel saat denk olduğunda

{

System.Diagnostics.Process.Start("shutdown", "-f -s"); // Sistemi Kapat (-f arkaplanda çalışan uygulamaları kapat, -s 30 sn içinde sistemi kapat) }

}

private void Form1_Load(object sender, EventArgs e) {

timer1.Enabled = true; // Form yüklendiğinde güncel saati başlat label1.Text = DateTime.Now.ToLongTimeString(); // Yazdır

for (int i = 0; i <= 23; i++) // Comboboxa otomatik veriyi yükleme {

comboBox1.Items.Add(i);

}

for (int i = 0; i <= 59; i++) // comboboxa veriyi (dakika ve saniye) yükleme {

comboBox2.Items.Add(i);

comboBox3.Items.Add(i);

} }

int kapamasure; // Global olarak değişkenlerimi tanımlıyorum

(2)

string yenisaatdeger;

string yenidakikadeger;

string yenisaniyedeger;

private void button1_Click(object sender, EventArgs e) {

if (radioButton1.Checked == true) // Eğer radyo butonda ilk seçenek seçili ise (saate göre kapanma)her 3 combo boxtaki değeri string olarak alıyorum.

{

string saat = comboBox1.SelectedItem.ToString();

string dakika = comboBox2.SelectedItem.ToString();

string saniye = comboBox3.SelectedItem.ToString();

//Alınan değerleri Convert ediyorum, karşılaştırma yapmak için..

int saatdeger = Convert.ToInt32(saat);

int dakikadeger = Convert.ToInt32(dakika);

int saniyedeger = Convert.ToInt32(saniye);

// Saat değeri 10 dan küçük ise labela yazdırırken başına 0 değerini ekliyorum.

if (saatdeger < 10) {

yenisaatdeger = "0" + saatdeger.ToString();

} else {

yenisaatdeger = saatdeger.ToString();

}

// Dakika değeri 10 dan küçük ise labela yazdırırken başına 0 değerini ekliyorum.

if (dakikadeger < 10) {

yenidakikadeger = "0" + dakikadeger.ToString();

} else {

yenidakikadeger = dakikadeger.ToString();

}

// Saniye değeri 10 dan küçük ise labela yazdırırken başına 0 değerini ekliyorum.

if (saniyedeger < 10) {

yenisaniyedeger = "0" + saniyedeger.ToString();

} else {

yenisaniyedeger = saniyedeger.ToString();

}

// Saat formatını belirlediğim karar yapısına göre label da yazdırıyorum label7.Text = yenisaatdeger + ":" + yenidakikadeger + ":" +

yenisaniyedeger;

}

// Eğer radyo buton 2 işaretli ise;

if (radioButton2.Checked == true)

// seçilen dakika sıfır değilse, seçilen ifadeyi 60 (saniye) ile çarpıyorum, timer 2 yi başlatıyorum.

{

if (Convert.ToInt32(comboBox2.SelectedItem) != 0)

(3)

kapamasure = 60 * kapamadakika;

timer2.Start();

}

// seçilen değer sıfır ise kullanıcıya uyarı veriyor.

else {

MessageBox.Show("Lütfen sıfır değerini seçmeyiniz");

} } }

private void button2_Click(object sender, EventArgs e)

//Eğer iptal butonuna basılmış ise işlemi iptal ettiriyorum (-a), Timer duruyor.

{

System.Diagnostics.Process.Start("shutdown", " -a");

label7.Text = "";

timer2.Stop();

}

private void radioButton1_CheckedChanged(object sender, EventArgs e) {

comboBox1.Enabled = true;

comboBox2.Enabled = true;

comboBox3.Enabled = true;

}

private void radioButton2_CheckedChanged(object sender, EventArgs e)

// Eğer radyo buton 2 seçili ise, saat ve saniye seçilmesin diye combobox'a false veriyorum.

{

comboBox1.Enabled = false;

comboBox2.Enabled = true;

comboBox3.Enabled = false;

}

private void timer2_Tick(object sender, EventArgs e)

// Dakikaya göre kapanma seçildiğinde kalan süreyi ekrana yazdırıyorum.

{

kapamasure--;

label7.Text = kapamasure.ToString();

Refresh();

// süre 0 olduğunda sistemi 30 saniye içinde kapatıyorum.

if (kapamasure == 0) {

System.Diagnostics.Process.Start("shutdown", "-f -s");

} }

private void button3_Click(object sender, EventArgs e) // Çıkış butonu uyarısı..

{

DialogResult sonuc;

sonuc = MessageBox.Show("Çıkmak İstediğinizden Eminmisiniz?", "Uyarı", MessageBoxButtons.OKCancel);

{

if (sonuc == DialogResult.OK) {

Application.Exit();

} } } }

}

(4)

MOUSE TAKİP PROGRAMI

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

namespace mauseTakip {

public partial class Form1 : Form {

//Global alanda değişkenlerimizi tanımlıyoruz bool ciz;

int baslaX, baslaY;

public Form1() {

InitializeComponent();

}

//Formun arka plan rengini belirliyoruz.

private void Form1_Load(object sender, EventArgs e) {

this.BackColor = Color.Orchid;

}

//MouseDown: Mouse tuşuna basıldığında çalışacak olaylar private void Form1_MouseDown(object sender, MouseEventArgs e) {

ciz = true;

baslaX = e.X;

baslaY = e.Y;

}

// MouseMove: Form üzerinde mouse hareket ettirilmesi ile çalışacak olaylar private void Form1_MouseMove(object sender, MouseEventArgs e)

{

Graphics g = this.CreateGraphics();

Pen p = new Pen(Color.PowderBlue, 2);

Point point1 = new Point(baslaX, baslaY);

(5)

{

g.DrawLine(p, point1, point2);

baslaX = e.X;

baslaY = e.Y;

} }

//MouseUp: Mouse tuşuna bastıktan sonra çekildiğinde çalışacak olaylar private void Form1_MouseUp(object sender, MouseEventArgs e) {

ciz = false;

} } }

(6)

OTOBÜS BİLET REZERVASYON

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 OtobusRezervasyon {

public partial class Form1 : Form {

public Form1() {

InitializeComponent();

}

private void cbxModel_SelectedIndexChanged(object sender, EventArgs e) {

//kullanıcının model seçimine göre koltukları üret ve otobüse döşe //403:46, 404:48,travego:52

int kolyuksayisi;

if (cbxModel.Text == "Mercedes 403") {

//46 koltuk üret kolyuksayisi = 46;

}

else if (cbxModel.Text == "Mercedes 404") {

//48 koltuk üret kolyuksayisi = 48;

}

(7)

kolyuksayisi = 52;

//52 koltuk üret }

//mevcut kontrol varsa onları temizle //koltuksayisina göre üretim yap flpOtobus.Controls.Clear();

for (int i = 1; i <= kolyuksayisi; i++) {

Button btn = new Button();

btn.Text = i.ToString();

btn.Width = 30;

btn.Height = 20;

btn.Click += new EventHandler(btn_Click);

flpOtobus.Controls.Add(btn);

} }

void btn_Click(object sender, EventArgs e) {

Button btn = sender as Button;

//Tıklanan Butonun özelliklerini yeni butona aktarıyoruz.

lblKoltukNo.Text = btn.Text;

}

private void btnReserveEt_Click(object sender, EventArgs e) {

//koltuk nosu belli olan ve cinsiyet seçimi yapılmış olan kişi için koltuğu rezerve et

if (rbBay.Checked) {

//Bay için reserve et

ReserveEt(lblKoltukNo.Text, true);

}

else if(rbBayan.Checked) {

//Bayan için reserve et

ReserveEt(lblKoltukNo.Text, false);

} else {

MessageBox.Show("Lütfen Cinsiyet Seçimi Yapınız");

}

lblKoltukNo.Text = "0";

}

void ReserveEt(string koltukNo,bool cinsiyet) {

//flpotobüs içerisindeki tüm controlleri kapsayan bir döngü //text özelliği koltukno ya eşit

foreach (Control btn in flpOtobus.Controls) {

if (btn.Text == koltukNo) {

if (cinsiyet) {

btn.BackColor = Color.LightBlue;

} else {

btn.BackColor = Color.Pink ; }

(8)

btn.Enabled = false;

} } } } }

(9)

TOPAMA OYUN

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 ToplamaOyun {

public partial class Form1 : Form {

public Form1() {

InitializeComponent();

}

Random r = new Random();

int dogru_Sayisi = 0, yanlis_Sayisi = 0;

//Başlat butonuna basıldığında textBox1 ve textBox2 ye rastgele sayılar atanıyor.

private void btnBasla_Click(object sender, EventArgs e) {

textBox1.Text = r.Next(100).ToString();

textBox2.Text = r.Next(100).ToString();

}

//textBox3'te tuşa basma olayı(KeyDown) ile yapılacak işlemler private void textBox3_KeyDown(object sender, KeyEventArgs e) {

if (e.KeyCode == Keys.Enter) //tuşu enter olarak belirliyoruz {

int gercekSonuc = 0, tahmin = 0;

gercekSonuc = int.Parse(textBox1.Text) + int.Parse(textBox2.Text);//olması gereken sonuç

tahmin = int.Parse(textBox3.Text);//kullanıcının girdiği sonuç

(10)

if (gercekSonuc == tahmin) // kullanıcının girdiği toplama sonucu doğru ise

{

dogru_Sayisi++; //doğru sayısını 1 arttır }

else {

yanlis_Sayisi++; // değilse yanlış sayısını 1 arttır }

//Doğru ya da yanlış sayısı labele yazdırılıyor.

lblDogru.Text = dogru_Sayisi.ToString();

lblYanlis.Text = yanlis_Sayisi.ToString();

//textBox1 ve textBox2 ye her işlemin sonunda rastgele sayı üretilmesi sağlanıyor. textBox3 temizleniyor.

textBox1.Text = r.Next(100).ToString();

textBox2.Text = r.Next(100).ToString();

textBox3.Text = "";

} }

} }

Referanslar

Benzer Belgeler

As a result of the endeavours of these institutions, states were influenced and the climate change issue entered the political agenda of the international community

Then, we have calculated the enhancement factor from the obtained measurement results by dividing the transmission result of the circular aperture with the omega-like

Since no spatial information is used during the clustering procedure, pixels with the same cluster label can either form a single connected spatial region, or can belong to

To con firm the formation of nanoparticles, we investigated samples using TEM, which showed spherical nanoparticle formation with an average core size of 11.0 ± 1.9 nm (Figure

Bu çalişmada; işletmelerin pazar yönlü ha- reket etmelerinde e-öğrenme stratejisinin, bireysel ve örgütsel açidan gelişme- nin sağlanabilmesi, pazar odakli plan, politika

Toplumsal bağın güçlenmesi açısından dayanışma adlı alt kategori DKAB ders kitabında geçen düz metinlerden birinde şöyle yer almıştır;. “İslam dini insanların

For example, Herbert Kelman, who conducted many problem-solving workshops between the Israelis and Palestinians, observed that the workshops allowed the participants to gain

The intermediate adduct (9) was obtained using simple purification by liquid–liquid extraction, and the crude product (9) was then used in the second Suzuki coupling reaction