protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.tip_calculator);

            Toolbar = FindViewById <Toolbar>(Resource.Id.toolbar);
            if (Toolbar != null)
            {
                SetSupportActionBar(Toolbar);
                SupportActionBar.SetDisplayHomeAsUpEnabled(true);
                SupportActionBar.SetHomeButtonEnabled(false);
            }

            Calculate  = FindViewById <Button>(Resource.Id.calculate);
            BillAmount = FindViewById <EditText>(Resource.Id.bill_amount);
            TipAmount  = FindViewById <TextView>(Resource.Id.tip_amount);

            Calculate.Click += (s, e) =>
            {
                var amount = Convert.ToDecimal(BillAmount.Text);
                TipAmount.Text = _tipCalculator.Calculate(amount).ToString("C2");
            };

            Calculate.Enabled       = false;
            BillAmount.TextChanged += (s, e) => Calculate.Enabled = !string.IsNullOrEmpty(BillAmount.Text);
        }
Exemplo n.º 2
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            Title = "TipCalc";

            Calculate.TouchUpInside += (s, e) =>
            {
                var amount = Convert.ToDecimal(BillAmount.Text);
                TipAmount.Text = _tipCalculator.Calculate(amount).ToString("C2");
            };

            Calculate.Enabled = false;
            BillAmount.AddTarget((s, e) => Calculate.Enabled = !string.IsNullOrEmpty(BillAmount.Text),
                                 UIControlEvent.EditingChanged);
        }
Exemplo n.º 3
0
 private void Calculate() => TipAmount = _tipCalculator.Calculate(BillAmount);