private void Initialize()
 {
     this._vcChild = (vcDecimalText)this.ParentContainer;
 }
Example #2
0
        public void CreateNumber(bool _bIsFraction)
        {
            // Locals
            int _sig   = 0;
            int _insig = 0;

            //int _loopCount = 0;

            string[] _result;
            this._bHasDecimal            = false;
            this._sizeClass.CurrentWidth = 0.0f;

            // Tens allocation
            _result = _strOriginalValue.Split(_delimiters, StringSplitOptions.RemoveEmptyEntries);
            // Honestly, this thing can only ever have two array members...
            // hard to have more than one decimal place in a number?
            _sig = _result[0].Length;
            if (_result.Length > 1)
            {
                this._intMultiNumberTotalInSigCount = _result[1].Length;
            }
            this._intMultiNumberTotalSigCount = _result[0].Length;
            this._intMultiNumberTotalCount    = _strOriginalValue.Length;

            // Main creation loop
            for (int i = 0; i < this._intMultiNumberTotalCount; i++)
            {
                // The Amazing Conversion Of Doctor Parasis!
                var ch = _strOriginalValue[i].ToString();
                // Check if its a dot
                if (ch != ".")
                {
                    // The Amazing Conversion Of Doctor Parasis!
                    double dblCh = Convert.ToDouble(ch);
                    // PROCESS - BUILD NUMBER
                    // Create a number box
                    vcNumberText newnumber = new vcNumberText(dblCh);
                    newnumber.IsAnswer            = this.IsAnswer;
                    newnumber.MyNumberParent      = this;
                    newnumber.MyImmediateParent   = this;
                    newnumber.MutliNumberPosition = (this._intMultiNumberTotalCount - (this._intMultiNumberTotalCount - (i + 1)));
                    if (_bIsFraction)
                    {
                        newnumber.MyFractionParent     = this.MyFractionParent;
                        newnumber.SizeClass.IsFraction = true;
                    }
                    if (this._intMultiNumberTotalSigCount > 1 || this._intMultiNumberTotalSigCount > 1)
                    {
                        newnumber.NumberSize.IsMultiNumberText = true;
                        newnumber.IsMultiNumberedText          = true;
                    }

                    #region Set Tens Units Positions

                    if (this._bHasDecimal)
                    {
                        // We are now looking at insignificant numbers
                        _insig++;
                        newnumber.Significance             = G__Significance.InSignificant;
                        newnumber.TensUnit                 = (G__UnitPlacement)_insig;
                        newnumber.MutliNumberInSigPosition = _insig;
                        newnumber.MutliNumberInSigTotal    = this._intMultiNumberTotalInSigCount;
                        newnumber.MutliNumberSigTotal      = this._intMultiNumberTotalSigCount;
                    }
                    else
                    {
                        newnumber.Significance           = G__Significance.Significant;
                        newnumber.TensUnit               = (G__UnitPlacement)_sig;
                        newnumber.MutliNumberSigPosition = _sig;
                        newnumber.MutliNumberInSigTotal  = this._intMultiNumberTotalInSigCount;
                        newnumber.MutliNumberSigTotal    = this._intMultiNumberTotalSigCount;
                        _sig--;
                    }

                    #endregion

                    // Add our numbers to our internal list counter.
                    this._lsNumbers.Add(newnumber);
                    this._lsNumbersOnly.Add(newnumber);
                    // This is used to find
                    newnumber.IndexNumber = this._lsNumbersOnly.Count;


                    // I was whacking in a border height and width but at this level its not important.
                    //var _width = (this._sizeClass.CurrentWidth + (this._sizeClass.GlobalSizeDimensions.NumberBorderWidth * 1));
                    var _width  = (this._sizeClass.CurrentWidth);
                    var _height = 0.0f;

                    // Sizing
                    // "Ill turn off the gravity"- Stimpy (Ren And Stimpy 1992)
                    // Set our current width - and shorten if there is more then one number
                    if ((_lsNumbers.Count > 1) || (_result.Length > 1))
                    {
                        newnumber.NumberSize.SetViewPosition(new CGSize(_width, _height));
                    }
                    else
                    {
                        newnumber.NumberSize.SetViewPosition(new CGSize(_width, _height));
                    }

                    this._sizeClass.CurrentWidth += (newnumber.NumberSize.CurrentWidth);

                    // Event Hooks
                    // Value and selection changes
                    newnumber.eValueChanged += this.OnValueChange;
                    // Resizing
                    this.eSizeChanged        += newnumber.OnSizeChange;
                    this.SizeClass.eResizing += newnumber.SizeClass.OnResize;

                    // Add control
                    this.AddAndDisplayController(newnumber);
                }
                else
                {
                    //_hitDecimal = true;
                    this._bHasDecimal = true;
                    // PROCESS - BUILD DECIMAL
                    // Create a decimal box
                    var newdecimal = new vcDecimalText();
                    newdecimal.IsAnswer = this.IsAnswer;
                    // Decimal UI
                    newdecimal.BorderWidth = 0.0f;

                    // Add our numbers to our internal list counter.
                    _lsNumbers.Add(newdecimal);
                    // Sizing
                    // The Space Madness!
                    newdecimal.DecimalSize.SetViewPosition(new CGSize(this.SizeClass.CurrentWidth, 0.0f));
                    // Set our current width
                    this.SizeClass.CurrentWidth += newdecimal.SizeClass.CurrentWidth;

                    // Event Hooks
                    // Selection changes
                    // Resizing
                    this.eSizeChanged        += newdecimal.OnSizeChange;
                    this.SizeClass.eResizing += newdecimal.SizeClass.OnResize;

                    this.AddAndDisplayController(newdecimal, newdecimal.View.Frame);
                }
            }

            // Set totals for logical processing later
            //for (int i = 0; i < _lsNumbersOnly.Count; i++)
            //{
            //    _lsNumbersOnly[i].MutliNumberInSigTotal = _insig;
            //    _lsNumbersOnly[i].MutliNumberSigTotal = this._intMultiNumberTotalSigCount;
            //}

            // Set our current height
            if (this.MyFractionParent == null)
            {
                this.SizeClass.CurrentHeight = (this.SizeClass.GlobalSizeDimensions.NumberContainerHeight);
            }
            else
            {
                this.SizeClass.CurrentHeight = (this.SizeClass.GlobalSizeDimensions.FractionNumberHeight);
            }
        }