Exemplo n.º 1
0
        private void OnUndoPressed(object sender, EventArgs e)
        {
            sbInBound.Clear();
            InBound.Clear();
            this.FindByName <Label>("Input").Text = string.Empty;


            Fraction_class workFraction = new Fraction_class();

            workFraction.SetValueTo(Accumulator);

            Accumulator.SetValueTo(UndoAccum);
            sbAccumulator.Clear();
            if (displayToggle == DisplayToggle.floating)
            {
                sbAccumulator.Append(Accumulator.ToDisplayFloat(" "));
            }
            else
            {
                sbAccumulator.Append(Accumulator.ToDisplayFraction(" "));
            }

            this.FindByName <Label>("Result").Text = sbAccumulator.ToString();

            lastOperator = ' ';

            UndoAccum.SetValueTo(workFraction); // next undo will circle back
        }
Exemplo n.º 2
0
 internal void SetValueTo(Fraction_class inBound)
 {
     fractionSign = inBound.fractionSign;
     wholeNumber  = inBound.wholeNumber;
     numerator    = inBound.numerator;
     denominator  = inBound.denominator;
 }
Exemplo n.º 3
0
 public void Modulus(Fraction_class inbound)
 {
     try
     {
         double dbl = this.ToFloat() % inbound.ToFloat();
         this.Parse(dbl.ToString());
     }
     catch (Exception e0)
     {
         //
     }
 }
Exemplo n.º 4
0
        //internal void DivideBy(Fraction_class inBound)
        public void DivideBy(Fraction_class inBound)
        {
            inBound.ToSimpleFraction();
            this.ToSimpleFraction();

            this.denominator = inBound.numerator * this.denominator;
            this.numerator   = inBound.denominator * this.numerator;

            fractionSign = wholeNumber < 0 || numerator < 0 ? Sign.negative : Sign.positive;

            this.Reduce();
        }
Exemplo n.º 5
0
        internal void Add(Fraction_class inBound)
        {
            inBound.ToSimpleFraction();
            this.ToSimpleFraction();

            this.numerator =
                (inBound.numerator * this.denominator) + (this.numerator * inBound.denominator);
            this.denominator =
                (inBound.denominator * this.denominator);

            this.Reduce();
        }
Exemplo n.º 6
0
        //  internal void Subtract(Fraction_class inBound)
        public void Subtract(Fraction_class inBound)
        {
            inBound.ToSimpleFraction();
            this.ToSimpleFraction();

            this.numerator =
                (this.numerator * inBound.denominator) - (inBound.numerator * this.denominator);
            this.denominator =
                (inBound.denominator * this.denominator);

            fractionSign = wholeNumber < 0 || numerator < 0 ? Sign.negative : Sign.positive;

            this.Reduce();
        }