using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Calculadora
{
  public partial class Form1 : Form
  {
    private enum Entrada
    {
      NINGUNA,
      DIGITO,
      OPERADOR,
      CE
    }
    private Entrada ultimaEntrada;
    private bool comaDecimal;
    private char operador;
    private byte numOperandos;
    private double operando1;
    private double operando2;
    public Form1()
    {
      InitializeComponent();
      ultimaEntrada = Entrada.NINGUNA;
      comaDecimal = false;
      operador = '\0';
      numOperandos = 0;
      operando1 = 0;
      operando2 = 0;
    }
       // A cada uno de los botones del 0 al 9 se les ha asignado un controlador de eventos
      // en la ventana de propiedades seleccionamos el evento Click y asignamos al controlador
      // al nombre btDigito_Click
    private void btDigito_Click(object sender, EventArgs e)
    {
      Button objButton = (Button)sender;
      if (ultimaEntrada != Entrada.DIGITO)
      {
        if (objButton.Text == "0") return;
        etPantalla.Text = "";
        ultimaEntrada = Entrada.DIGITO;
        comaDecimal = false;
      }
      etPantalla.Text += objButton.Text;
    }
    private void btComaDec_Click(object sender, EventArgs e)
    {
      if (ultimaEntrada != Entrada.DIGITO)
      {
        etPantalla.Text = "0,";
        ultimaEntrada = Entrada.DIGITO;
      }
      else if (comaDecimal == false)
        etPantalla.Text = etPantalla.Text + ",";
      comaDecimal = true;
    }