Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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 Kalkulator
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- string LiczbaPierwsza, Liczbadruga, Copy, a;
- char RodzajDzialania = ' ';
- private void reset()
- {
- t_box_wynik.Clear();
- LiczbaPierwsza = "";
- Liczbadruga = "";
- }
- private void btn_dodawanie_Click(object sender, EventArgs e)
- {
- RodzajDzialania = '+';
- t_box_wynik.Text = "";
- }
- private void btn_odejmowanie_Click(object sender, EventArgs e)
- {
- RodzajDzialania = '-';
- t_box_wynik.Text = "";
- }
- private void btn_mnożenie_Click(object sender, EventArgs e)
- {
- RodzajDzialania = '*';
- t_box_wynik.Text = "";
- }
- private void btn_dzielenie_Click(object sender, EventArgs e)
- {
- RodzajDzialania = '/';
- t_box_wynik.Text = "";
- }
- private void btn_1_Click(object sender, EventArgs e)
- {
- Dzialanie(1);
- }
- private void btn_2_Click(object sender, EventArgs e)
- {
- Dzialanie(2);
- }
- private void btn_3_Click(object sender, EventArgs e)
- {
- Dzialanie(3);
- }
- private void btn_4_Click(object sender, EventArgs e)
- {
- Dzialanie(4);
- }
- private void btn_5_Click(object sender, EventArgs e)
- {
- Dzialanie(5);
- }
- private void btn_6_Click(object sender, EventArgs e)
- {
- Dzialanie(6);
- }
- private void btn_7_Click(object sender, EventArgs e)
- {
- Dzialanie(7);
- }
- private void btn_8_Click(object sender, EventArgs e)
- {
- Dzialanie(8);
- }
- private void btn_9_Click(object sender, EventArgs e)
- {
- Dzialanie(9);
- }
- private void btn_0_Click(object sender, EventArgs e)
- {
- Dzialanie(0);
- }
- private void btn_reset_Click(object sender, EventArgs e)
- {
- reset();
- /*/t_box_wynik.Clear(); //takie coś czyści wszystko ale nie usuwa
- LiczbaPierwsza = "";
- Liczbadruga = "";/*/
- }
- private void btn_przecinek_Click(object sender, EventArgs e)
- {
- MessageBox.Show("Nii działa xD", "Informacja dotycząca przecinka", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- private void btn_wynik_Click(object sender, EventArgs e)
- {
- switch (RodzajDzialania)
- {
- case ('+'):
- t_box_wynik.Text = (double.Parse(LiczbaPierwsza) + double.Parse(Liczbadruga)).ToString();
- break;
- case ('-'):
- t_box_wynik.Text = (double.Parse(LiczbaPierwsza) - double.Parse(Liczbadruga)).ToString();
- break;
- case ('*'):
- t_box_wynik.Text = (double.Parse(LiczbaPierwsza) * double.Parse(Liczbadruga)).ToString();
- break;
- case ('/'):
- t_box_wynik.Text = (double.Parse(LiczbaPierwsza) / double.Parse(Liczbadruga)).ToString();
- break;
- }
- LiczbaPierwsza = "";
- Liczbadruga = "";
- RodzajDzialania = ' ';
- LiczbaPierwsza = t_box_wynik.Text;
- {
- Liczbadruga = "";
- }
- }
- private void btn_zmiana_znaku_Click(object sender, EventArgs e)
- {
- a = t_box_wynik.Text;
- Convert.ToInt64(a);
- a = a * -1;
- Convert.ToString(a);
- t_box_wynik.Text = a;
- }
- private void btn_Copy_Click(object sender, EventArgs e)
- {
- Copy = t_box_wynik.Text;
- t_box_2.Text = Copy; // + ('+'.ToString())
- reset();
- }
- private void Dzialanie(double liczba)
- {
- if (RodzajDzialania == ' ')
- {
- LiczbaPierwsza += liczba;
- t_box_wynik.Text = LiczbaPierwsza;
- }
- else
- {
- Liczbadruga += liczba;
- t_box_wynik.Text = Liczbadruga;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement