Example #1
0
        private void MainFormBttnEquality_Click(Object sender, EventArgs e)
        {
            Boolean isOk = CheckInput();

            if (!isOk)
            {
                SystemSounds.Beep.Play();
                return;
            }

            var fract1 = new Fraction(Int32.Parse(MainFormTxtbxNumerator1.Text), Int32.Parse(MainFormTxtbxDenumerator1.Text));
            var fract2 = new Fraction(Int32.Parse(MainFormTxtbxNumerator2.Text), Int32.Parse(MainFormTxtbxDenumerator2.Text));

            GetCurrentOperation(out Operation currOperation1);
            Fraction result = currOperation1 switch
            {
                Operation.Add => fract1.Sum(fract2),
                Operation.Substract => fract1.Substact(fract2),
                Operation.Multiply => fract1.Multiply(fract2),
                Operation.Divide => fract1.Divide(fract2),
                _ => throw new Exception(),
            };

            result.Reduse();

            MainFromTxtbxNumerator3.Text   = result.Numerator.ToString();
            MainFormTxtbxDenumerator3.Text = result.Denumenator.ToString();
        }