Пример #1
0
        // Calculator_KeyPress: Checks for user input through KeyPresses and performs
        // the corresponding Click-event for the appropriate button.
        // Pre: -
        // Post: The KeyPress-event has been handled and, if there's a match, the appropriate
        // buttons Click-event has been fired.
        private void Calculator_KeyPress(object sender, KeyPressEventArgs e)
        {
            switch (e.KeyChar)
            {
            case '1': OneButton.PerformClick(); break;

            case '2': TwoButton.PerformClick(); break;

            case '3': ThreeButton.PerformClick(); break;

            case '4': FourButton.PerformClick(); break;

            case '5': FiveButton.PerformClick(); break;

            case '6': SixButton.PerformClick(); break;

            case '7': SevenButton.PerformClick(); break;

            case '8': EightButton.PerformClick(); break;

            case '9': NineButton.PerformClick(); break;

            case '0': ZeroButton.PerformClick(); break;

            case '/': DivideButton.PerformClick(); break;

            case '*': MultiplyButton.PerformClick(); break;

            case '-': SubtractButton.PerformClick(); break;

            case '+': AddButton.PerformClick(); break;

            case ',': CommaButton.PerformClick(); break;

            case 'C': ClearButton.PerformClick(); break;

            case 'c': ClearButton.PerformClick(); break;
            }
            e.Handled = true;
        }
Пример #2
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            Button0.SetCommand(_viewModel.Button0Action);
            Button1.SetCommand(_viewModel.Button1Action);
            Button2.SetCommand(_viewModel.Button2Action);
            Button3.SetCommand(_viewModel.Button3Action);
            Button4.SetCommand(_viewModel.Button4Action);
            Button5.SetCommand(_viewModel.Button5Action);
            Button6.SetCommand(_viewModel.Button6Action);
            Button7.SetCommand(_viewModel.Button7Action);
            Button8.SetCommand(_viewModel.Button8Action);
            Button9.SetCommand(_viewModel.Button9Action);
            LeftButton.SetCommand(_viewModel.LeftButtonAction);
            CommaButton.SetCommand(_viewModel.CommaButtonAction);
            RightButton.SetCommand(_viewModel.RightButtonAction);
            AddRecordButton.SetCommand(_viewModel.AddRecordAction);
            DeleteButton.SetCommand(_viewModel.DeleteButtonAction);
            IncomeButton.SetCommand(_viewModel.IncomeButtonAction);
            ExpensesButton.SetCommand(_viewModel.ExpensesButtonAction);
            TransferButton.SetCommand(_viewModel.TransferButtonAction);

            _bindings.Add(this.SetBinding(() => _viewModel.SignText, () => SignLabel.Text));
            _bindings.Add(this.SetBinding(() => _viewModel.LeftButtonText, () => LeftButtonText));
            _bindings.Add(this.SetBinding(() => _viewModel.RightButtonText, () => RightButtonText));
            _bindings.Add(this.SetBinding(() => _viewModel.AmountLabelText, () => AmountLabel.Text));
            _bindings.Add(this.SetBinding(() => _viewModel.IncomeButtonColor, () => IncomeButton.BackgroundColor).ConvertSourceToTarget(x => x.ToNative()));
            _bindings.Add(this.SetBinding(() => _viewModel.TransButtonColor, () => TransferButton.BackgroundColor).ConvertSourceToTarget(x => x.ToNative()));
            _bindings.Add(this.SetBinding(() => _viewModel.ExpensesButtonColor, () => ExpensesButton.BackgroundColor).ConvertSourceToTarget(x => x.ToNative()));

            HolderView.ApplyStyle(_viewModel.MainStyling);
            TemplatesButton.ApplyStyle(_viewModel.MainStyling);
            RightButton.ApplyStyle(_viewModel.MainStyling);
            LeftButton.ApplyStyle(_viewModel.MainStyling);
            MiddleImageView.ApplyStyle(_viewModel.MainStyling);
        }