Beispiel #1
0
        public IUpdateUIState CharacterEnteredOrAppendedToTextboxTwo
            (ObservableCollection <string> IntegerStrings,
            string IntegerTotal)
        {
            FormulaStrings = IntegerStrings;

            var Textbox1Text = FormulaStrings[0];
            var Textbox2Text = FormulaStrings[1];

            CurrentUIState = GetExceptionState
                                 (Textbox1Text,
                                 Textbox2Text);

            if (CurrentUIState != null)
            {
                //Have Exception:
                return(CurrentUIState);
            }

            CurrentUIState = GetEnabledState
                                 (Textbox1Text,
                                 Textbox2Text,
                                 IntegerTotal);

            return(CurrentUIState);
        }
Beispiel #2
0
 public IUpdateUIState TextboxOneValueErased
     (string Textbox1Text,
     string Textbox2Text)
 {
     CurrentUIState = TextBoxOneHasValueState;
     return(CurrentUIState);
 }
Beispiel #3
0
        private void OnTextBoxTwoTextChanged(string Textbox2Text)
        {
            if (ClearFlag == false)
            {
                TextBoxTwoText = Textbox2Text;
            }

            ResetUserInterface();

            IntegerStrings.Clear();
            IntegerStrings.Add(TextBoxOneText);
            IntegerStrings.Add(TextBoxTwoText);

            IntegerTotal = TextBoxTotalText;

            CurrentUIState = UIModel.TextBox1And2HaveValuesState(IntegerStrings, IntegerTotal);

            StatusTextboxText  = CurrentUIState.StatusText;
            FormulaTextboxText = CurrentUIState.FormulaText;

            TextBox1Exception           = CurrentUIState.TextBox1ExceptionState;
            TextBox2Exception           = CurrentUIState.TextBox2ExceptionState;
            TextBox1HasValue            = CurrentUIState.TextBox1HasValueState;
            TextBox1AndTextbox2HasValue = CurrentUIState.TextBox1AndTextBox2HasValueState;
            BothTextBoxesBlankOrClear   = CurrentUIState.BothTextBoxesBlankOrClearState;
        }
        public IUpdateUIState TextBox1And2HaveValuesState
            (ObservableCollection <string> IntegerStrings,
            string IntegerTotal)
        {
            CurrentState = UpdateUI.CharacterEnteredOrAppendedToTextboxTwo
                               (IntegerStrings,
                               IntegerTotal);

            return(CurrentState);
        }
Beispiel #5
0
        private void OnClearButtonClick()
        {
            ClearFlag = true;

            TextBoxOneText   = "";
            TextBoxTwoText   = "";
            TextBoxTotalText = "";

            ResetUserInterface();
            CurrentUIState            = UIModel.ClearUI();
            BothTextBoxesBlankOrClear = CurrentUIState.BothTextBoxesBlankOrClearState;

            ClearFlag = false;
        }
Beispiel #6
0
        private IUpdateUIState GetExceptionState
            (string Textbox1Text,
            string Textbox2Text)
        {
            Textbox1ValidationResult = ValidateTextboxText(Textbox1Text);
            Textbox2ValidationResult = ValidateTextboxText(Textbox2Text);

            if (Textbox1Text != null &&
                Textbox1Text.Length > 0 &&
                Textbox2Text != null &&
                Textbox2Text.Length > 0)
            {
                if (Textbox1ValidationResult == false &&
                    Textbox2ValidationResult == false)
                {
                    CurrentUIState            = TextBoxOneAndTwoExceptionState;
                    CurrentUIState.StatusText = ExceptionResult.ExceptionText;

                    return(CurrentUIState);
                }
            }

            if (Textbox1Text != null &&
                Textbox1Text.Length > 0)
            {
                if (Textbox1ValidationResult == false)
                {
                    CurrentUIState            = TextBoxOneExceptionState;
                    CurrentUIState.StatusText = ExceptionResult.ExceptionText;
                    return(CurrentUIState);
                }
            }

            if (Textbox2Text != null &&
                Textbox2Text.Length > 0)
            {
                if (Textbox2ValidationResult == false)
                {
                    CurrentUIState            = TextBoxTwoExceptionState;
                    CurrentUIState.StatusText = ExceptionResult.ExceptionText;
                    return(CurrentUIState);
                }
            }
            return(null);
        }
Beispiel #7
0
        public SubtractTwoViewModel
            (IEventAggregator EventAggregator,
            UpdateSubtractUIModel UIModel,
            IUpdateUIState CurrentUIState,
            SubtractTwoModel SubtractIntegers,
            IDescription Description,
            DescriptionResult DescriptionResult)
        {
            if (EventAggregator != null)
            {
                this.EventAggregator = EventAggregator;
            }

            if (UIModel != null)
            {
                this.UIModel = UIModel;
            }

            if (SubtractIntegers != null)
            {
                this.SubtractIntegers = SubtractIntegers;
            }

            if (Description != null)
            {
                this.Description = Description;
            }

            if (DescriptionResult != null)
            {
                this.DescriptionResult = DescriptionResult;
            }

            SetDescriptionText();
            SetHeaderValues();
            ResetUserInterface();

            TAB_LOADED_COMMAND = new DelegateCommand(OnTabLoad);
            TEXT_BOX_ONE_TEXT_CHANGED_COMMAND = new DelegateCommand <string>(OnTextBoxOneTextChanged);
            TEXT_BOX_TWO_TEXT_CHANGED_COMMAND = new DelegateCommand <string>(OnTextBoxTwoTextChanged);
            CLEAR_BUTTON_CLICK_COMMAND        = new DelegateCommand(OnClearButtonClick);
            CALCULATE_BUTTON_CLICK_COMMAND    = new DelegateCommand(OnCalculateButtonClick);
        }
Beispiel #8
0
        private IUpdateUIState GetEnabledState
            (string Textbox1Text,
            string Textbox2Text,
            string TextboxTotalText)
        {
            if (Textbox1Text != null &&
                Textbox1Text.Length <= 0 &&
                Textbox2Text != null &&
                Textbox2Text.Length <= 0)
            {
                CurrentUIState = Textbox1And2BlankOrClearState;
                return(CurrentUIState);
            }

            if (Textbox1Text != null &&
                Textbox1Text.Length > 0 &&
                Textbox2Text != null &&
                Textbox2Text.Length > 0)
            {
                CurrentUIState = TextBoxOneAndTwoHaveValuesState;
            }
            else
            {
                CurrentUIState = TextBoxOneHasValueState;
            }

            CurrentUIState.StatusText = OkStatus.GetStatus();

            FormulaText = Formula.GenerateFormula
                              (FormulaStrings,
                              TextboxTotalText);

            CurrentUIState.FormulaText = FormulaText.Trim();

            return(CurrentUIState);
        }
Beispiel #9
0
        public UpdateUserInterface
            (IUpdateUIState Textbox1And2BlankOrClear,
            [Dependency("TextBoxOneHasValue")] IUpdateUIState TextBoxOneHasValue,
            [Dependency("TextBoxOneAndTwoHaveValues")] IUpdateUIState TextBoxOneAndTwoHaveValues,
            [Dependency("TextBoxOneException")] IUpdateUIState TextBoxOneException,
            [Dependency("TextBoxTwoException")] IUpdateUIState TextBoxTwoException,
            [Dependency("TextBoxOneAndTwoException")] IUpdateUIState TextBoxOneAndTwoException,
            IValidateInteger Validate32BitInteger,
            IntegerValidationResult IntegerValidationResult,
            ExceptionResult ExceptionResult,
            IStatus OkStatus,
            IFormula Formula)
        {
            if (Textbox1And2BlankOrClear != null)
            {
                Textbox1And2BlankOrClearState = Textbox1And2BlankOrClear;
            }

            if (TextBoxOneHasValue != null)
            {
                TextBoxOneHasValueState = TextBoxOneHasValue;
            }

            if (TextBoxOneAndTwoHaveValues != null)
            {
                TextBoxOneAndTwoHaveValuesState = TextBoxOneAndTwoHaveValues;
            }

            if (TextBoxOneException != null)
            {
                TextBoxOneExceptionState = TextBoxOneException;
            }

            if (TextBoxTwoException != null)
            {
                TextBoxTwoExceptionState = TextBoxTwoException;
            }

            if (TextBoxOneAndTwoException != null)
            {
                TextBoxOneAndTwoExceptionState = TextBoxOneAndTwoException;
            }

            if (Validate32BitInteger != null)
            {
                this.Validate32BitInteger = Validate32BitInteger;
            }

            if (IntegerValidationResult != null)
            {
                this.IntegerValidationResult = IntegerValidationResult;
            }

            if (ExceptionResult != null)
            {
                this.ExceptionResult = ExceptionResult;
            }

            if (OkStatus != null)
            {
                this.OkStatus = OkStatus;
            }

            if (Formula != null)
            {
                this.Formula = Formula;
            }
        }
Beispiel #10
0
 public IUpdateUIState ClearButtonClicked()
 {
     CurrentUIState = Textbox1And2BlankOrClearState;
     return(CurrentUIState);
 }
Beispiel #11
0
 public void SetState(IUpdateUIState State)
 {
     CurrentUIState = State;
 }
 public IUpdateUIState ClearUI()
 {
     CurrentState = UpdateUI.ClearButtonClicked();
     return(CurrentState);
 }
Beispiel #13
0
 private void OnTabLoad()
 {
     ResetUserInterface();
     CurrentUIState            = UIModel.ClearUI();
     BothTextBoxesBlankOrClear = CurrentUIState.BothTextBoxesBlankOrClearState;
 }