コード例 #1
0
        internal void CalculateBinaryOperation(object sender, EventArgs e)
        {
            var currentButton = sender as Button;

            if (!_view.IsResult || currentButton.Text == "=")   // произвести вычисление только если в текст-боксе не результат,
            {                                                   // или если в качестве операции передано "="
                _view.Number = _model.GetResult(_view.Number);
            }

            if (_model.BinaryOperationsList.Contains(currentButton.Text))   // сверить переданную операцию со списком операций,
            {                                                               // чтобы записать только существующее значение в поле текущей операции
                _view.CurrentOperation  = currentButton.Text;
                _model.CurrentOperation = currentButton.Text;
            }
        }
コード例 #2
0
        private void Cal()
        {
            try
            {
                if (InputText != welcome && InputText != string.Empty)
                {
                    calculator.GetResult();
                    ResultText = calculator.Result;
                }
            }
            catch (Exception e)
            {
                //Display = error + e.ToString();
                var dialog = new MessageDialog(e.ToString(), e.Message);

                dialog.Commands.Add(new UICommand("确定", cmd => { }, commandId: 0));
                dialog.Commands.Add(new UICommand("取消", cmd => { }, commandId: 1));

                //设置默认按钮,不设置的话默认的确认按钮是第一个按钮
                dialog.DefaultCommandIndex = 0;
                dialog.CancelCommandIndex  = 1;
            }
        }
コード例 #3
0
        public ActionResult Calculator(DateTime data)
        {
            try
            {
                CalculatorModel model = new CalculatorModel(data);

                string result = string.Format("A data inserida foi {0}. Este mês tem o dia {1} com sendo o seu quinto dia útil.", data.ToShortDateString(), model.GetResult());
                return(Ok(new { status = 200, result }));
            }
            catch (Exception ex)
            {
                return(BadRequest(new { message = new[] { "Não foi possível concluir a requisição.", ex.Message } }));
            }
        }