예제 #1
0
        /// <summary>
        /// Puts the digits into their initial states, We expand the total number of
        /// digits if the amount present is not enough
        /// </summary>
        private void UpdateInitialValue()
        {
            double val          = this.InitialValue;
            double neededDigits = (Math.Log10(this.InitialValue) + 1) / Math.Log10(10);

            if (this.Digits < neededDigits)
            {
                this.digits.Clear();
                this.Digits = neededDigits;
                this.UpdateDigits();
            }

            for (int i = this.digits.Count; i > 0; i--)
            {
                double        d  = val % 10;
                OdometerDigit dg = this.digits[i - 1];
                dg.SetInitialValue((int)d);
                val = val / 10;
            }
        }
예제 #2
0
        /// <summary>
        /// Set up the digits, we only do this if the digits are set before the
        /// value. If the value is set first we infer the number of digits from
        /// the value
        /// </summary>
        private void UpdateDigits()
        {
            if (this.digits.Count == 0)
            {
                _stack.Children.Clear();
                OdometerDigit lastDigit = null;
                for (int i = 0; i < (int)this.Digits; i++)
                {
                    OdometerDigit digit = new OdometerDigit();
                    if (lastDigit != null)
                    {
                        digit.DecadePlus  += new EventHandler <EventArgs>(lastDigit.LowerOrderDigitDecadePlus);
                        digit.DecadeMinus += new EventHandler <EventArgs>(lastDigit.LowerOrderDigitDecadeMinus);
                    }

                    lastDigit = digit;
                    this.digits.Add(digit);
                    _stack.Children.Add(digit);
                }
            }
        }
예제 #3
0
        /// <summary>
        /// Set up the digits, we only do this if the digits are set before the
        /// value. If the value is set first we infer the number of digits from
        /// the value
        /// </summary>
        private void UpdateDigits()
        {
            if (this.digits.Count == 0)
            {
                _stack.Children.Clear();
                OdometerDigit lastDigit = null;
                for (int i = 0; i < (int)this.Digits; i++)
                {
                    OdometerDigit digit = new OdometerDigit();
                    if (lastDigit != null)
                    {
                        digit.DecadePlus += new EventHandler<EventArgs>(lastDigit.LowerOrderDigitDecadePlus);
                        digit.DecadeMinus += new EventHandler<EventArgs>(lastDigit.LowerOrderDigitDecadeMinus);
                    }

                    lastDigit = digit;
                    this.digits.Add(digit);
                    _stack.Children.Add(digit);
                }
            }
        }