Example #1
0
 private void CBtn_Click(object sender, EventArgs e)
 {
     enter   = false;
     isEqual = false;
     ResultTxt.Clear();
     ResultLbl.Text = "";
     total          = 0;
 }
Example #2
0
        private void OperatorsClick(object sender, EventArgs e)
        {
            if (ResultTxt.Text != string.Empty)
            {
                //isEqual = false;

                lastIsOperator = -1;
                //firstme = false;

                if (sender is Button button)
                {
                    if (isOperator == false)
                    {
                        CalculateTotal();
                        firstTotal = false;
                        CallOperator(button);
                        isOperator = true;

                        //iki setir sonradan
                        ResultTxt.Clear();
                        ResultTxt.Text = total.ToString();
                    }
                    //if(lastIsOperator == 1)
                    //{
                    //    CallOperator(button);

                    //    lastIsOperator = 0;
                    //}
                }
            }

            //CalculateTotal();
            //lastIsOperator = -1;
            //firstTotal = false;
            //if (sender is Button button)
            //{
            //    if(isOperator==false)
            //    {
            //        CallOperator(button);
            //        isOperator = true;
            //    }
            //    //if(lastIsOperator == 1)
            //    //{
            //    //    CallOperator(button);

            //    //    lastIsOperator = 0;
            //    //}
            //}
        }
Example #3
0
 /// <summary>
 /// Called when the user presses the "Test" button. We perform the regex
 /// testing here and show the results to the user.
 /// </summary>
 /// <param name="sender">Event sender.</param>
 /// <param name="e">Event arguments.</param>
 private void TestBtn_Click(object sender, System.EventArgs e)
 {
     try {
         RegexTester tester = new RegexTester();
         using (new CursorChanger(this, Cursors.WaitCursor)) {
             ResultTxt.Text = tester.ModifyWithRegex(SampleTxt.Text, RegexTxt.Text,
                                                     ReplacementTxt.Text, IgnoreCaseChk.Checked);
         }
         // If we made it here, the regular expression is valid.
         InvalidNoticeLbl.Visible = false;
     } catch (RegexTesterException) {
         // Invalid regular expression.
         ResultTxt.Clear();
         InvalidNoticeLbl.Visible = true;
     }
 }
Example #4
0
        private void NumberClick(object sender, EventArgs e)
        {
            isEqual    = false;
            isOperator = false;
            if (sender is Button button)
            {
                if (lastIsOperator == -1)
                {
                    ResultTxt.Clear();
                }
                lastIsOperator  = 1;
                ResultTxt.Text += button.Text;

                //Random random = new Random();
                //double value = (random.NextDouble() * (9999.99 - 0.99) + 0.99);
                //double b = Math.Round(value, 2, MidpointRounding.ToEven);



                //if (firstme)
                //    ResultTxt.Text += button.Text;
                //else if (myqueue)
                //{
                //    ResultTxt.Text += button.Text;
                //    myqueue = false;
                //}
                //else if (myqueue == false)
                //    ResultTxt.Text = total.ToString();


                //if (lastIsOperator == -1)
                //    total += Double.Parse(button.Text);


                //isOperator = false;
                //ResultTxt.Text += total;
                //ResultTxt.Text += button.Text;
            }
        }
Example #5
0
        private void CalculateTotal()
        {
            if (Double.Parse(ResultTxt.Text) < 0 && enter == false)
            {
                ResultTxt.Text = (-Double.Parse(ResultTxt.Text)).ToString();
            }


            //if (firstTotal && enter==true)
            //{
            //    total -= Double.Parse(ResultTxt.Text);
            //    ResultTxt.Text = (-Double.Parse(ResultTxt.Text)).ToString();
            //}
            //if (firstTotal && enter==false)
            //    total += Double.Parse(ResultTxt.Text);


            if (firstTotal)
            {
                total += Double.Parse(ResultTxt.Text);
            }


            else if (select == 1)
            {
                total += Double.Parse(ResultTxt.Text);
            }
            else if (select == 2)
            {
                total -= Double.Parse(ResultTxt.Text);
            }
            else if (select == 3 && isEqual == false)
            {
                total *= Double.Parse(ResultTxt.Text);
            }
            else if (select == 3 && isEqual == true)
            {
                total += Double.Parse(ResultTxt.Text);
            }
            else
            {
                total /= Double.Parse(ResultTxt.Text);
                int a;
            }
            //if (ResultTxt.Text == "∞")
            //{
            //    ResultTxt.Clear();
            //    ResultLbl.Text = "";
            //    Application.Exit();
            //}
            //if(total==Double.NaN)
            //{
            //    ResultTxt.Clear();
            //    ResultLbl.Text = "";
            //    Application.Exit();
            //}
            if (Double.IsInfinity(total))
            {
                ResultTxt.Clear();
                ResultLbl.Text = "";
                Application.Exit();
            }
        }