Proje Hakkında:
Bu kısımda toplama ,çıkarma,çarpma,bölme,karekök,üs alma,logaritma ve son olarak trigonomtrik ifadelerin değerlerini bulabilen bir kod dizisi ve aşamaları yer almaktadır.
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 hessap
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
//Değer atamaları
double sayi1, sayi2, sonuc;
int secim = 0;
// Ondalıklı sayıları için virgül butonunu aktif etme fonksiyonu.
private void button11_Click(object sender, EventArgs e)
{
if(textBox1.Text.IndexOf(",")<)
{
textBox1.Text = textBox1.Text + ",";
}
}
//Bütün rakamların basma fonksiyonu
private void secili(object sender, EventArgs e)
{
if(textBox1.Text== "0")
{
textBox1.Text = "";
}
textBox1.Text = textBox1.Text + ((Button)sender).Text;
}
//Bütün textboxu temizleme yani C butonu aktif etme fonksiyonu
private void button16_Click(object sender, EventArgs e)
{
textBox1.Text = "0";
}
//Del butonunu aktif etme fonksiyonu
private void button17_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text.Substring(0, textBox1.Text.Length-1);
if(textBox1.Text=="")
{
textBox1.Text = "0";
}
}
//eşittir butonu aktif etme fonksiyonu
private void button18_Click(object sender, EventArgs e)
{
sayi2 = double.Parse(textBox1.Text);
if (secim==1)
{
sonuc = sayi1 + sayi2;
textBox1.Text = sonuc.ToString();
}
if (secim == 2)
{
sonuc = sayi1 - sayi2;
textBox1.Text = sonuc.ToString();
}
if (secim == 3)
{
sonuc = sayi1 / sayi2;
textBox1.Text = sonuc.ToString("0.000");
}
if (secim == 4)
{
sonuc = sayi1 * sayi2;
textBox1.Text = sonuc.ToString();
}
if (secim == 5)
{
sonuc = Math.Sqrt(sayi1);
textBox1.Text = sonuc.ToString();
}
if (secim == 6)
{
sonuc = Math.Tan((Math.PI *sayi1) / 180);
textBox1.Text = sonuc.ToString();
}
if (secim == 7)
{
sonuc = Math.Cos((Math.PI * sayi1) / 180);
textBox1.Text = sonuc.ToString();
}
if (secim == 8)
{
sonuc = Math.Sin((Math.PI * sayi1) / 180);
textBox1.Text = sonuc.ToString();
}
if (secim == 9)
{
sonuc = Math.Pow(sayi1 , sayi2);
textBox1.Text = sonuc.ToString();
}
if (secim == 10)
{
sonuc = Math.Log(sayi1);
textBox1.Text = sonuc.ToString();
}
if (secim == 11)
{
sonuc = (1 / Math.Tan((Math.PI * sayi1) / 180));
textBox1.Text = sonuc.ToString();
}
}
//Keys kütüphanesi ile numPad ve klavye üstü sayıları aktif ederek klavye kullanılarak //işlem yapmaya yaran kod bloğu.
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
if(e.KeyCode==Keys.NumPad1 || e.KeyCode==Keys.D1)
{
button1.PerformClick();
}
if (e.KeyCode == Keys.NumPad2 || e.KeyCode == Keys.D2)
{
button2.PerformClick();
}
if (e.KeyCode == Keys.NumPad3 || e.KeyCode == Keys.D3)
{
button3.PerformClick();
}
if (e.KeyCode == Keys.NumPad4 || e.KeyCode == Keys.D4)
{
button4.PerformClick();
}
if (e.KeyCode == Keys.NumPad5 || e.KeyCode == Keys.D5)
{
button5.PerformClick();
}
if (e.KeyCode == Keys.NumPad6 || e.KeyCode == Keys.D6)
{
button6.PerformClick();
}
if (e.KeyCode == Keys.NumPad7 || e.KeyCode == Keys.D7)
{
button7.PerformClick();
}
if (e.KeyCode == Keys.NumPad8 || e.KeyCode == Keys.D8)
{
button8.PerformClick();
}
if (e.KeyCode == Keys.NumPad9 || e.KeyCode == Keys.D9)
{
button9.PerformClick();
}
if (e.KeyCode == Keys.NumPad0 || e.KeyCode == Keys.D0)
{
button10.PerformClick();
}
if (e.KeyCode == Keys.Back)
{
button17.PerformClick();
}
if (e.KeyCode == Keys.Add)
{
button12.PerformClick();
}
if (e.KeyCode == Keys.OemMinus)
{
button13.PerformClick();
}
}
//toplama çıkarmaa ve diğer işlemlerin butonlarını aktif etme fonksiyonları
private void button12_Click(object sender, EventArgs e)
{
sayi1 = double.Parse(textBox1.Text);
textBox1.Text = "0";
secim = 1;
}
private void button13_Click(object sender, EventArgs e)
{
sayi1 = double.Parse(textBox1.Text);
textBox1.Text = "0";
secim = 2;
}
private void button14_Click(object sender, EventArgs e)
{
sayi1 = double.Parse(textBox1.Text);
textBox1.Text = "0";
secim = 3;
}
private void button15_Click(object sender, EventArgs e)
{
sayi1 = double.Parse(textBox1.Text);
textBox1.Text = "0";
secim = 4;
}
private void button19_Click(object sender, EventArgs e)
{
sayi1 = double.Parse(textBox1.Text);
textBox1.Text = "0";
secim = 5;
}
private void button20_Click(object sender, EventArgs e)
{
sayi1 = double.Parse(textBox1.Text);
textBox1.Text = "0";
secim = 6;
}
private void button21_Click(object sender, EventArgs e)
{
sayi1 = double.Parse(textBox1.Text);
textBox1.Text = "0";
secim = 7;
}
private void button22_Click(object sender, EventArgs e)
{
sayi1 = double.Parse(textBox1.Text);
textBox1.Text = "0";
secim = 8;
}
private void button23_Click(object sender, EventArgs e)
{
sayi1 = double.Parse(textBox1.Text);
textBox1.Text = "0";
secim = 9;
}
private void button24_Click(object sender, EventArgs e)
{
sayi1 = double.Parse(textBox1.Text);
textBox1.Text = "0";
secim = 10;
}
private void button25_Click(object sender, EventArgs e)
{
sayi1 = double.Parse(textBox1.Text);
textBox1.Text = "0";
secim = 11;
}
}
}