dessel191

Program Main

May 8th, 2017
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 11.53 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10.  
  11. namespace WindowsFormsApp1
  12. {
  13.     public partial class Form1 : Form
  14.     {
  15.  
  16.         static bool action = false;
  17.         static bool action2 = false;
  18.         static bool action3 = false;
  19.         static double x, y;
  20.        
  21.         public Form1()
  22.         {
  23.             InitializeComponent();
  24.         }
  25.         private void button2_Click(object sender, EventArgs e)
  26.         {            
  27.             Ekran.add("1");
  28.             textBox1.Text = Ekran.rets();
  29.         }
  30.  
  31.         private void button3_Click(object sender, EventArgs e)
  32.         {
  33.             Ekran.add("2");
  34.             textBox1.Text = Ekran.rets();
  35.         }
  36.  
  37.         private void button4_Click(object sender, EventArgs e)
  38.         {
  39.             Ekran.add("3");
  40.             textBox1.Text = Ekran.rets();
  41.         }
  42.  
  43.         private void button5_Click(object sender, EventArgs e)
  44.         {
  45.             Ekran.add("4");
  46.             textBox1.Text = Ekran.rets();
  47.         }
  48.  
  49.         private void button6_Click(object sender, EventArgs e)
  50.         {
  51.             Ekran.add("5");
  52.             textBox1.Text = Ekran.rets();
  53.         }
  54.  
  55.         private void button7_Click(object sender, EventArgs e)
  56.         {
  57.             Ekran.add("6");
  58.             textBox1.Text = Ekran.rets();
  59.         }
  60.  
  61.         private void button8_Click(object sender, EventArgs e)
  62.         {
  63.             Ekran.add("7");
  64.             textBox1.Text = Ekran.rets();
  65.         }
  66.  
  67.         private void button9_Click(object sender, EventArgs e)
  68.         {
  69.             Ekran.add("8");
  70.             textBox1.Text = Ekran.rets();
  71.         }
  72.  
  73.         private void button10_Click(object sender, EventArgs e)
  74.         {
  75.             Ekran.add("9");
  76.             textBox1.Text = Ekran.rets();
  77.         }
  78.  
  79.         private void button1_Click(object sender, EventArgs e)
  80.         {
  81.             Ekran.add("0");
  82.             textBox1.Text = Ekran.rets();
  83.         }
  84.  
  85.         private void button11oo_Click(object sender, EventArgs e)
  86.         {
  87.             Ekran.add("00");
  88.             textBox1.Text = Ekran.rets();
  89.         }
  90.  
  91.         private void button12dot_Click(object sender, EventArgs e)
  92.         {
  93.             Ekran.add(".");
  94.             textBox1.Text = Ekran.rets();
  95.         }
  96.  
  97.         private void button21_Click(object sender, EventArgs e)
  98.         {
  99.             Ekran.clr();
  100.             textBox1.Text = "";
  101.             label1.Text = "";
  102.             Ekran.setdzialanie(0);
  103.         }
  104.  
  105.         private void button22_Click(object sender, EventArgs e)
  106.         {
  107.             Calc.MemPlus(Ekran.retd());
  108.             radioButton1.Checked = true;
  109.             Ekran.clr();
  110.                
  111.         }
  112.  
  113.         private void button23_Click(object sender, EventArgs e)
  114.         {
  115.             Calc.MemMinus(Ekran.retd());
  116.             radioButton1.Checked = true;
  117.             Ekran.clr();
  118.         }
  119.  
  120.         private void button24_Click(object sender, EventArgs e)
  121.         {
  122.             Ekran.set(Calc.MemR());
  123.             textBox1.Text = Ekran.rets();
  124.             Ekran.clr();
  125.  
  126.         }
  127.  
  128.         private void button25_Click(object sender, EventArgs e)
  129.         {
  130.             Calc.MemCLR();
  131.             radioButton1.Checked = false;
  132.         }
  133.  
  134.         private void button13_Click(object sender, EventArgs e)
  135.         {
  136.             if (Ekran.ostdzialanied() == 2)
  137.             {
  138.                 if(!action)
  139.                     y = Double.Parse(textBox1.Text);
  140.                 x = Calc.Roznica(x, y);                
  141.                 Ekran.set(x);
  142.                 textBox1.Text = Ekran.rets();
  143.                 action = true;
  144.             }
  145.             else
  146.             {
  147.                
  148.                 Ekran.setdzialanie(2);
  149.                 label1.Text = Ekran.ostdzialanie();
  150.                 x = Ekran.retd();
  151.                
  152.             }
  153.             Ekran.clr();
  154.             action2 = false;
  155.             action3 = false;
  156.         }
  157.  
  158.         private void button12_Click(object sender, EventArgs e)
  159.         {
  160.             if (Ekran.ostdzialanied() == 3)
  161.             {
  162.                 y = Double.Parse(textBox1.Text);
  163.                 x = Calc.Iloczyn(x, y);
  164.                 Ekran.set(x);
  165.                 textBox1.Text = Ekran.rets();
  166.                 action2 = true;
  167.             }
  168.             else
  169.             {                
  170.                 Ekran.setdzialanie(3);
  171.                 label1.Text = Ekran.ostdzialanie();
  172.                 x = Ekran.retd();
  173.            
  174.             }
  175.             Ekran.clr();
  176.             action = false;
  177.             action3 = false;
  178.  
  179.         }
  180.  
  181.         private void button11_Click(object sender, EventArgs e)
  182.         {
  183.             if (Ekran.ostdzialanied() == 4)
  184.             {
  185.                 y = Double.Parse(textBox1.Text);
  186.                 try
  187.                 {
  188.                     x = Calc.Iloraz(x, y);
  189.                     Ekran.set(x);
  190.                     textBox1.Text = Ekran.rets();
  191.                 }
  192.                 catch (Exception E)
  193.                 {
  194.                     textBox1.Text = "Dzielenie przez 0";
  195.                 }
  196.                 action3 = true;
  197.             }
  198.             else
  199.             {
  200.                 Ekran.setdzialanie(4);
  201.                 label1.Text = Ekran.ostdzialanie();
  202.                 x = Ekran.retd();
  203.             }
  204.             Ekran.clr();
  205.             action = false;
  206.             action2 = false;
  207.            
  208.         }
  209.  
  210.         private void button20_Click(object sender, EventArgs e)
  211.         {
  212.  
  213.             switch (Ekran.ostdzialanied())
  214.             {
  215.                 case 1:
  216.                     y = Double.Parse(textBox1.Text);
  217.                     y = Calc.Suma(x, y);
  218.                     Ekran.set(y);
  219.                     textBox1.Text = Ekran.rets();
  220.                     action = false;
  221.                     action2 = false;
  222.                     action3 = false;
  223.                     break;
  224.                 case 2:
  225.                     if(!action)
  226.                         y = Double.Parse(textBox1.Text);
  227.                     x = Calc.Roznica(x, y);
  228.                     Ekran.set(x);
  229.                     textBox1.Text = Ekran.rets();
  230.                     action = true;
  231.                     action2 = false;
  232.                     action3 = false;
  233.                     break;
  234.                 case 3:
  235.                     if(!action2)
  236.                         y = Double.Parse(textBox1.Text);
  237.                     x = Calc.Iloczyn(x, y);
  238.                     Ekran.set(x);
  239.                     textBox1.Text = Ekran.rets();
  240.                     action = false;
  241.                     action2 = true;
  242.                     action3 = false;
  243.                     break;
  244.                 case 4:
  245.                     if(!action3)
  246.                         y = Double.Parse(textBox1.Text);
  247.                     x = Calc.Iloraz(x, y);
  248.                     Ekran.set(x);
  249.                     textBox1.Text = Ekran.rets();
  250.                     action = false;
  251.                     action2 = false;
  252.                     action3 = true;
  253.                     break;
  254.                 case 5:
  255.                     x = Ekran.retd();
  256.                     x = Calc.Kwadrat(x);
  257.                     Ekran.set(x);
  258.                     textBox1.Text = Ekran.rets();
  259.                     action = false;
  260.                     action2 = false;
  261.                     action3 = false;
  262.                     break;
  263.                 case 6:
  264.                     x = Ekran.retd();
  265.                     x = Calc.Odwr(x);
  266.                     Ekran.set(x);
  267.                     textBox1.Text = Ekran.rets();
  268.                     action = false;
  269.                     action2 = false;
  270.                     action3 = false;
  271.                     break;
  272.                 case 7:
  273.                     x = Ekran.retd();
  274.                     x = Calc.Procent(x);
  275.                     Ekran.set(x);
  276.                     textBox1.Text = Ekran.rets();
  277.                     action = false;
  278.                     action2 = false;
  279.                     action3 = false;
  280.                     break;
  281.                 case 8:
  282.                     x = Ekran.retd();
  283.                     x = Calc.Negacja(x);
  284.                     Ekran.set(x);
  285.                     textBox1.Text = Ekran.rets();
  286.                     action = false;
  287.                     action2 = false;
  288.                     action3 = false;
  289.                     break;
  290.  
  291.                 case 9:
  292.                     x = Ekran.retd();
  293.                     x = Calc.Sqrt(x);
  294.                     Ekran.set(x);
  295.                     textBox1.Text = Ekran.rets();
  296.                     action = false;
  297.                     action2 = false;
  298.                     action3 = false;
  299.                     break;
  300.  
  301.                 default:
  302.                     action = false;
  303.                     action2 = false;
  304.                     action3 = false;
  305.                     break;
  306.  
  307.             }
  308.            
  309.         }
  310.  
  311.         private void button15_Click(object sender, EventArgs e)
  312.         {
  313.             x = Ekran.retd();
  314.             x = Calc.Kwadrat(x);
  315.             Ekran.set(x);
  316.             textBox1.Text = Ekran.rets();
  317.             Ekran.setdzialanie(5);
  318.             label1.Text = Ekran.ostdzialanie();
  319.  
  320.             action = false;
  321.             action2 = false;
  322.             action3 = false;
  323.         }
  324.  
  325.         private void button16_Click(object sender, EventArgs e)
  326.         {
  327.             x = Ekran.retd();
  328.             x = Calc.Odwr(x);
  329.             Ekran.set(x);
  330.             textBox1.Text = Ekran.rets();
  331.             Ekran.setdzialanie(6);
  332.             label1.Text = Ekran.ostdzialanie();
  333.  
  334.             action = false;
  335.             action2 = false;
  336.             action3 = false;
  337.         }
  338.  
  339.         private void button18_Click(object sender, EventArgs e)
  340.         {
  341.             x = Ekran.retd();
  342.             x = Calc.Procent(x);
  343.             Ekran.set(x);
  344.             textBox1.Text = Ekran.rets();
  345.             Ekran.setdzialanie(7);
  346.             label1.Text = Ekran.ostdzialanie();
  347.  
  348.             action = false;
  349.             action2 = false;
  350.             action3 = false;
  351.         }
  352.  
  353.         private void button19_Click(object sender, EventArgs e)
  354.         {
  355.             x = Ekran.retd();
  356.             x = Calc.Negacja(x);
  357.             Ekran.set(x);
  358.             textBox1.Text = Ekran.rets();
  359.             Ekran.setdzialanie(8);
  360.             label1.Text = Ekran.ostdzialanie();
  361.  
  362.             action = false;
  363.             action2 = false;
  364.             action3 = false;
  365.         }
  366.  
  367.         private void button17_Click(object sender, EventArgs e)
  368.         {
  369.             x = Ekran.retd();
  370.             x = Calc.Sqrt(x);
  371.             Ekran.set(x);
  372.             textBox1.Text = Ekran.rets();
  373.             Ekran.setdzialanie(9);
  374.             label1.Text = Ekran.ostdzialanie();
  375.  
  376.             action = false;
  377.             action2 = false;
  378.             action3 = false;
  379.         }
  380.  
  381.         private void button14_Click(object sender, EventArgs e)
  382.         {
  383.            
  384.             if (Ekran.ostdzialanied() == 1)
  385.             {
  386.                 y = Double.Parse(textBox1.Text);
  387.                 y = Calc.Suma(x, y);
  388.                 Ekran.set(y);
  389.                 textBox1.Text = Ekran.rets();
  390.             }
  391.             else
  392.             {
  393.                Ekran.setdzialanie(1);
  394.                label1.Text = Ekran.ostdzialanie();
  395.                x = Ekran.retd();                
  396.             }
  397.                 Ekran.clr();
  398.             action = false;
  399.            
  400.         }
  401.     }
  402. }
Advertisement
Add Comment
Please, Sign In to add comment