예제 #1
0
파일: Form1.cs 프로젝트: AngelSalas/Figuras
 private void Form1_MouseClick(object sender, MouseEventArgs e)
 {
     if (MouseButtons.Right == e.Button)
     {
         contextMenuStrip1.Show(this, e.X, e.Y);
     }
     if (MouseButtons.Left == e.Button && circuloToolStripMenuItem.Checked == true)
     {
         Circulo c = new Circulo(e.X, e.Y);
         c.Dibuja(this);
         figuras.Add(c);
     }
     else if (MouseButtons.Left == e.Button && rectanguloToolStripMenuItem.Checked == true)
     {
         Rectangulo r = new Rectangulo(e.X, e.Y);
         r.Dibuja(this);
         figuras.Add(r);
     }
 }
예제 #2
0
        private void Form1_MouseClick(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left) //Dibujar Rectangulo al dar click izquierdo
            {
                Graphics   g = CreateGraphics();
                Rectangulo r = new Rectangulo(e.X, e.Y);
                r.Dibuja(g);
                figuras.Add(r);

                if (this.azulToolStripMenuItem.Checked == true)
                {
                    r.ColoreaAzul(g);
                }
                else if (this.verdeToolStripMenuItem.Checked == true)
                {
                    r.ColoreaVerde(g);
                }
                else if (this.rojoToolStripMenuItem.Checked == true)
                {
                    r.ColoreaRojo(g);
                }
                else if (this.amarilloToolStripMenuItem.Checked == true)
                {
                    r.ColoreaAmarillo(g);
                }
            }
            else if (e.Button == MouseButtons.Right) //Dibujar Elipse al dar click Derecho
            {
                Graphics g    = CreateGraphics();
                Elipse   elip = new Elipse(e.X, e.Y);
                elip.Dibuja(g);
                figuras.Add(elip);

                if (this.azulToolStripMenuItem.Checked == true)
                {
                    elip.ColoreaAzul(g);
                }
                else if (this.verdeToolStripMenuItem.Checked == true)
                {
                    elip.ColoreaVerde(g);
                }
                else if (this.rojoToolStripMenuItem.Checked == true)
                {
                    elip.ColoreaRojo(g);
                }
                else if (this.amarilloToolStripMenuItem.Checked == true)
                {
                    elip.ColoreaAmarillo(g);
                }
            }

            else //Mostrar menú al dar botón de enmedio
            {
                contextMenuStrip1.Show(this, e.X, e.Y);
            }

            //Contador de Figuras
            int contador = figuras.Count();

            lblFiguras.Text = "Numero de dibujos:" + contador;
        }