Exemplo n.º 1
0
        // Functions
        // All write there output into the UIOuput object
        // For example in iOS this would be a collection of beggining to end vc's for an expression.
        // Simply pop them off the stack and into the container vc
        public object UICreateNumber(string strValue)
        {
            // Create a number
            var x = new vcNumberContainer(strValue);

            // Create the number
            x.IsAnswer   = this.IsAnswer;
            x.IsFreeFrom = this.IsFreeForm;
            x.CreateNumber(false);
            x.IsReadOnly  = !this.IsAnswer;
            this.IsAnswer = false;
            return(x as object);
        }
        private void CreateFraction()
        {
            // Locals
            string[] _result;

            // SPLIT STRING
            // Split the denominator and numerator apart
            _result = this._strFractionExpression.Split(_delimiters, StringSplitOptions.RemoveEmptyEntries);
            // There should only ever be two
            if (_result.Length > 2)
            {
                // More then one delimitor.
                // TODO : Raise an error. This should never be any greater then two dimensions
            }
            // Set our values in fraction variables
            //this.NumeratorValue = Convert.ToDouble(_result[0].ToString());
            //this.DenominatorValue = Convert.ToDouble(_result[1].ToString());

            // PROCESS - BUILD NUMBER
            // Create a number box
            this._numberContainerNumerator   = new vcNumberContainer(_result[0].ToString());
            this._numberContainerDenominator = new vcNumberContainer(_result[1].ToString());

            // AnswerType
            this._numberContainerNumerator.IsAnswer   = this.IsAnswer;
            this._numberContainerDenominator.IsAnswer = this.IsAnswer;

            // Freeform?
            //this._numberContainerNumerator.IsFreeFrom = this.IsFreeFrom;
            //this._numberContainerDenominator.IsFreeFrom = this.IsFreeFrom;

            // Set the fraction container parent of num and den
            this._numberContainerNumerator.MyFractionParent   = this;
            this._numberContainerDenominator.MyFractionParent = this;
            // Immidiate parent for chaining
            this._numberContainerNumerator.MyImmediateParent   = this;
            this._numberContainerDenominator.MyImmediateParent = this;

            // Create the numbers
            this._numberContainerNumerator.CreateNumber(true);
            this._numberContainerDenominator.CreateNumber(true);

            // TODO: Should this be here? I havent yet told the fraciton if its freeform...LOGIC PROBLEM!
            if (!this._bIsAnswer)
            {
                this._strOriginalValue = HelperFunctions.DoubleToFraction((double)this.FractionToDecimal);
            }

            // Event hooks

            // Numerator
            this._numberContainerNumerator.eValueChanged += this.OnValueChange;

            // Denominator
            this._numberContainerDenominator.eValueChanged += this.OnValueChange;

            // Grab the width - we need the largest.
            // Math.Max returns the largest or if equal, the value of the variables inputed
            this.SizeClass.CurrentWidth = Math.Max((float)this._numberContainerNumerator.NumberContainerSize.CurrentWidth, (float)this._numberContainerDenominator.SizeClass.CurrentWidth) + (2 * this.SizeClass.GlobalSizeDimensions.FractionNumberPadding);

            // Set the NumberContainers to be centered "horizontally" inside the fraction control
            this._numberContainerNumerator.NumberContainerSize.SetCenterRelativeParentViewPosX   = true;
            this._numberContainerDenominator.NumberContainerSize.SetCenterRelativeParentViewPosX = true;

            // Grab the vertical drop for denominator
            var _ypos =
                this._numberContainerNumerator.NumberContainerSize.CurrentHeight +
                (this.SizeClass.GlobalSizeDimensions.FractionNumberPadding * 2) +
                this.SizeClass.GlobalSizeDimensions.FractionDividerHeight;

            // Set the number padding
            this._numberContainerNumerator.NumberContainerSize.SetViewPosition
            (
                this.SizeClass.CurrentWidth,
                this.SizeClass.GlobalSizeDimensions.FractionNumberPadding
            );
            // ****
            this._numberContainerDenominator.NumberContainerSize.SetViewPosition
            (
                this.SizeClass.CurrentWidth,
                (_ypos + this.SizeClass.GlobalSizeDimensions.NumberBorderWidth)
            );

            //this.AddAndDisplayController(this._numberContainerNumerator);
            //this.AddAndDisplayController(this._numberContainerDenominator);
        }