Example #1
0
        private void RefreshUI()
        {
            _suppressEvents = true;
            if (Model.CurrentItem == null)
            {
                Model.CreateDefaultCurrentItem();
                SetToDefault();
            }
            else if (!Model.Items.Contains(Model.CurrentItem))
            {
                SetToDefault();
            }
            else
            {
                var  currentItem        = Model.CurrentItem;
                bool isOperatorType     = currentItem.ValueType == CalculatorValueType.Operator;
                bool isNoneOperatorType = currentItem.OperatorType == CalculatorOperatorType.None;
                IsLastElement         = isOperatorType && isNoneOperatorType;
                SelectedOperatorType  = currentItem.OperatorType;
                SelectedValueType     = ValueTypes.FirstOrDefault(x => x.Value == currentItem.ValueType);
                SelectedCashFlow      = CashFlows.FirstOrDefault(x => x.Id == currentItem.ForeignId);
                SelectedCashFlowGroup = CashFlowGroups.FirstOrDefault(x => x.Id == currentItem.ForeignId);
                SelectedIncome        = Incomes.FirstOrDefault(x => x.Id == currentItem.ForeignId);
                SelectedSaving        = Savings.FirstOrDefault(x => x.Id == currentItem.ForeignId);
                UserValue             = currentItem.Value;
                UserText         = currentItem.Text;
                SelectedEquation = Equations.FirstOrDefault(x => x.Id == currentItem.ForeignId);
            }

            NotifyOfPropertyChange(() => IsNoneOperatorSelected);
            NotifyOfPropertyChange(() => IsOperatorElementVisible);
            NotifyOfPropertyChange(() => IsAddOperatorSelected);
            NotifyOfPropertyChange(() => IsSubstractOperatorSelected);
            NotifyOfPropertyChange(() => IsMultiplyOperatorSelected);
            NotifyOfPropertyChange(() => IsDivideOperatorSelected);

            Title           = string.Format("Składowe równania ({0}/{1})", Model.CurrentPageNumber, Model.TotalPagesNumber);
            _suppressEvents = false;
        }
Example #2
0
        private void SetToDefault()
        {
            SelectedValueType     = ValueTypes.FirstOrDefault();
            SelectedCashFlow      = CashFlows.FirstOrDefault();
            SelectedCashFlowGroup = CashFlowGroups.FirstOrDefault();
            SelectedIncome        = null;
            SelectedSaving        = null;
            UserValue             = null;
            UserText             = string.Empty;
            SelectedEquation     = null;
            SelectedOperatorType = CalculatorOperatorType.None;

            var  lastItem = Model.Items.LastOrDefault();
            bool isLastItemNotOperator = (lastItem != null) && (lastItem.ValueType != CalculatorValueType.Operator);

            IsLastElement = (Model.Items.Count > 2) && (isLastItemNotOperator);

            if (IsOperatorElementVisible)
            {
                IsAddOperatorSelected = true;
            }
        }