Ejemplo n.º 1
0
        private void majPropriete(Forme_simple forme)
        {//Affiche les propriétes de la forme dans la partie DROITE de l'application
            if (forme != null)
            {
                textBox_nom.Text        = forme.Nom;                     //Nom
                panel_couleur.BackColor = Color.FromArgb(forme.Couleur); //Couleur
                //Groupe
                listBoxGroupesLiés.Items.Clear();
                listBoxGroupesLiés.Items.Add("Aucun");
                listBoxGroupesLiés.SetSelected(listBoxGroupesLiés.Items.IndexOf("Aucun"), true);
                //Groupe lié à la forme_active
                Forme_composee GroupeLiéDirectement = this.ListGroupes.Find(groupe => groupe.Id == this.forme_active.IdGroupe);
                if (GroupeLiéDirectement != null)
                {   //Recherche de tous les sous groupes liés directement ou indirectement au groupe forme_active.IdGroupe et les affiche dans listBoxGroupesLiés
                    this.chercheSousGroupes(GroupeLiéDirectement);

                    //Selectionne le groupe lié directement
                    listBoxGroupesLiés.SetSelected(listBoxGroupesLiés.Items.IndexOf(GroupeLiéDirectement.Nom), true);
                }



                //if (forme.IdGroupe == -1)//Groupe
                //{
                //    listBoxGroupesLiés.Items.Clear();
                //    listBoxGroupesLiés.Items.Add("Aucun");
                //    listBoxGroupesLiés.SetSelected(listBoxGroupesLiés.Items.IndexOf("Aucun"), true);
                //}
                //else
                //{
                //    listBoxGroupesLiés.Items.Add(this.ListGroupes.Find(item => item.Id == forme.IdGroupe).Nom);
                //    listBoxGroupesLiés.SetSelected(listBoxGroupesLiés.Items.IndexOf(this.ListGroupes.Find(item => item.Id == forme.IdGroupe).Nom), true);
                //}
            }
        }
Ejemplo n.º 2
0
 private void ellipseToolStripMenuItem_Click(object sender, EventArgs e) //attaché à l'item Dessin Ellipse
 {
     textBox_nom.Clear();
     this.forme_active = new Ellipse(id, "Ellipse " + id, panel_couleur.BackColor.ToArgb(), new Point(0, 0), 0, 0, -1);
     this.id++;
     activer_dessin();
 }
Ejemplo n.º 3
0
        public void refreshPanel()
        {
            g2.Clear(Color.White);
            panel1.Invalidate();



            //#################
            //DESSIN DU CONTOUR
            //#################

            //SOUS GROUPES
            if (this.forme_active != null)
            {
                //Contour des sous groupes du groupe séléctionné
                List <Forme_composee> ListSousGroupesLiés = this.ListGroupes.FindAll(groupe => groupe.IdGroupe != -1 && groupe.IdGroupe == this.forme_active.IdGroupe);
                foreach (Forme_composee groupe_lié in ListSousGroupesLiés)
                {
                    foreach (Forme f in groupe_lié.Liste_formes)
                    {
                        Forme_simple copie = (Forme_simple)f;
                        D1.contourSelection(copie, g2, Color.FromArgb(255, 0, 255, 0));
                    }
                }

                //Contour des SUPER groupe du groupe séléctionné
                List <Forme_composee> ListSuperGroupesLiés = this.ListGroupes.FindAll(groupe => groupe.IdGroupe != -1 && groupe.Id == this.forme_active.IdGroupe);
                foreach (Forme_composee groupe_lié in ListSuperGroupesLiés)
                {
                    foreach (Forme f in groupe_lié.Liste_formes)
                    {
                        Forme_simple copie = (Forme_simple)f;
                        D1.contourSelection(copie, g2, Color.FromArgb(255, 0, 255, 0));
                    }
                }
            }

            //GROUPE et FORME ACTIVE
            foreach (Forme_simple forme in ListFormes)
            {
                if (this.forme_active != null)
                {
                    if (forme_active.IdGroupe == forme.IdGroupe && forme.IdGroupe != -1)
                    {
                        //cas des formes du meme groupe (autre que -1)
                        D1.contourSelection(forme, g2, Color.FromArgb(255, 0, 255, 0));
                    }

                    if (forme_active == forme)
                    {
                        //cas forme active (nécéssaire d'etre déssiné après le groupe)
                        D1.contourSelection(forme, g2, Color.Red);
                    }
                }
                //dessine toutes les formes
                D1.dessiner(forme, g2);
            }
            panel1.Invalidate();
        }
Ejemplo n.º 4
0
 private void polygoneToolStripMenuItem_Click(object sender, EventArgs e)    //attaché à l'item Dessin Polygone
 {
     this.forme_active = new Polygone(id, "Polygone " + id, panel_couleur.BackColor.ToArgb(), tabcoord, -1);
     this.id++;
     label10.Visible         = true;
     textBoxNbPoints.Visible = true;
     textBoxNbPoints.Focus();
 }
Ejemplo n.º 5
0
 private void triangleToolStripMenuItem_Click(object sender, EventArgs e)    //attaché à l'item Dessin Triangle
 {
     this.nb_points_poly = 3;
     this.tabcoord       = new Point[this.nb_points_poly];
     this.forme_active   = new Triangle(id, "Triangle " + id, panel_couleur.BackColor.ToArgb(), tabcoord, -1);
     this.id++;
     activer_dessin();
 }
Ejemplo n.º 6
0
 public override void createorupdate(Forme_simple entry)
 {
     Type t = typeof(Segment);
     Type t2 = entry.GetType();
     if (t.Equals(t2))
     {
         base.createorupdate(entry);
     }
     else if (successor != null)
     {
         successor.createorupdate(entry);
     }
 }
Ejemplo n.º 7
0
 public override void delete(Forme_simple entry)
 {
     Type t = typeof(Polygone);
     Type t2 = entry.GetType();
     if (t.Equals(t2))
     {
         base.delete(entry);
     }
     else if (successor != null)
     {
         successor.delete(entry);
     }
 }
Ejemplo n.º 8
0
        public override void delete(Forme_simple entry)
        {
            Type t  = typeof(Polygone);
            Type t2 = entry.GetType();

            if (t.Equals(t2))
            {
                base.delete(entry);
            }
            else if (successor != null)
            {
                successor.delete(entry);
            }
        }
Ejemplo n.º 9
0
        public override void createorupdate(Forme_simple entry)
        {
            Type t  = typeof(Triangle);
            Type t2 = entry.GetType();

            if (t.Equals(t2))
            {
                base.createorupdate(entry);
            }
            else if (successor != null)
            {
                successor.createorupdate(entry);
            }
        }
Ejemplo n.º 10
0
 public override void contourSelection(Forme_simple forme, Graphics g, Color couleur)
 {
     Type t = typeof(Rectangle);
     Type t2 = forme.GetType();
     if (t.Equals(t2))
     {
         Rectangle e = (Rectangle)forme;
         Pen pen = new Pen(couleur, 10); //Couleur de selection
         g.DrawRectangle(pen, e.Point1.X, e.Point1.Y, e.Largeur, e.Hauteur);
     }
     else if (successor != null)
     {
         successor.contourSelection(forme, g, couleur);
     }
 }
Ejemplo n.º 11
0
 public override void dessiner(Forme_simple entry, Graphics g)
 {
     Type t = typeof(Rectangle);
     Type t2 = entry.GetType();
     if (t.Equals(t2))
     {
         Rectangle r = (Rectangle)entry;
         SolidBrush brush = new SolidBrush(Color.FromArgb(entry.Couleur));
         g.FillRectangle(brush, r.Point1.X, r.Point1.Y, r.Largeur, r.Hauteur);
     }
     else if (successor != null)
     {
         successor.dessiner(entry, g);
     }
 }
Ejemplo n.º 12
0
 public override void dessiner(Forme_simple entry, Graphics g)
 {
     Type t = typeof(Segment);
     Type t2 = entry.GetType();
     if (t.Equals(t2))
     {
         Segment s = (Segment)entry;
         Pen pen = new Pen(Color.FromArgb(entry.Couleur), 4);
         g.DrawLine(pen, s.Point1.X, s.Point1.Y, s.Point2.X, s.Point2.Y);
     }
     else if (successor != null)
     {
         successor.dessiner(entry, g);
     }
 }
Ejemplo n.º 13
0
 public override void contourSelection(Forme_simple forme, Graphics g, Color couleur)
 {
     Type t = typeof(Triangle);
     Type t2 = forme.GetType();
     if (t.Equals(t2))
     {
         Triangle tr = (Triangle)forme;
         Pen pen = new Pen(couleur, 10); //Couleur de selection
         g.DrawPolygon(pen, tr.Tableau_points);
     }
     else if (successor != null)
     {
         successor.contourSelection(forme, g, couleur);
     }
 }
Ejemplo n.º 14
0
 public override void dessiner(Forme_simple entry, Graphics g)
 {
     Type t = typeof(Triangle);
     Type t2 = entry.GetType();
     if (t.Equals(t2))
     {
         Triangle tr = (Triangle)entry;
         SolidBrush brush = new SolidBrush(Color.FromArgb(entry.Couleur));
         g.FillPolygon(brush, tr.Tableau_points);
     }
     else if (successor != null)
     {
         successor.dessiner(entry, g);
     }
 }
Ejemplo n.º 15
0
 public override void contourSelection(Forme_simple forme, Graphics g, Color couleur)
 {
     Type t = typeof(Segment);
     Type t2 = forme.GetType();
     if (t.Equals(t2))
     {
         Segment s = (Segment)forme;
         Pen pen = new Pen(couleur, 10); //Couleur de selection
         g.DrawLine(pen, s.Point1.X, s.Point1.Y, s.Point2.X, s.Point2.Y);
     }
     else if (successor != null)
     {
         successor.contourSelection(forme, g, couleur);
     }
 }
Ejemplo n.º 16
0
        public override void dessiner(Forme_simple entry, Graphics g)
        {
            Type t  = typeof(Rectangle);
            Type t2 = entry.GetType();

            if (t.Equals(t2))
            {
                Rectangle  r     = (Rectangle)entry;
                SolidBrush brush = new SolidBrush(Color.FromArgb(entry.Couleur));
                g.FillRectangle(brush, r.Point1.X, r.Point1.Y, r.Largeur, r.Hauteur);
            }
            else if (successor != null)
            {
                successor.dessiner(entry, g);
            }
        }
Ejemplo n.º 17
0
        public override void dessiner(Forme_simple entry, Graphics g)
        {
            Type t  = typeof(Polygone);
            Type t2 = entry.GetType();

            if (t.Equals(t2))
            {
                Polygone   p     = (Polygone)entry;
                SolidBrush brush = new SolidBrush(Color.FromArgb(entry.Couleur));
                g.FillPolygon(brush, p.Tableau_points);
            }
            else if (successor != null)
            {
                successor.dessiner(entry, g);
            }
        }
Ejemplo n.º 18
0
        public override void contourSelection(Forme_simple forme, Graphics g, Color couleur)
        {
            Type t  = typeof(Polygone);
            Type t2 = forme.GetType();

            if (t.Equals(t2))
            {
                Polygone e   = (Polygone)forme;
                Pen      pen = new Pen(couleur, 10); //Couleur de selection
                g.DrawPolygon(pen, e.Tableau_points);
            }
            else if (successor != null)
            {
                successor.contourSelection(forme, g, couleur);
            }
        }
Ejemplo n.º 19
0
        public override void contourSelection(Forme_simple forme, Graphics g, Color couleur)
        {
            Type t  = typeof(Rectangle);
            Type t2 = forme.GetType();

            if (t.Equals(t2))
            {
                Rectangle e   = (Rectangle)forme;
                Pen       pen = new Pen(couleur, 10); //Couleur de selection
                g.DrawRectangle(pen, e.Point1.X, e.Point1.Y, e.Largeur, e.Hauteur);
            }
            else if (successor != null)
            {
                successor.contourSelection(forme, g, couleur);
            }
        }
Ejemplo n.º 20
0
        public override void contourSelection(Forme_simple forme, Graphics g, Color couleur)
        {
            Type t  = typeof(Segment);
            Type t2 = forme.GetType();

            if (t.Equals(t2))
            {
                Segment s   = (Segment)forme;
                Pen     pen = new Pen(couleur, 10); //Couleur de selection
                g.DrawLine(pen, s.Point1.X, s.Point1.Y, s.Point2.X, s.Point2.Y);
            }
            else if (successor != null)
            {
                successor.contourSelection(forme, g, couleur);
            }
        }
Ejemplo n.º 21
0
        public override void dessiner(Forme_simple entry, Graphics g)
        {
            Type t  = typeof(Segment);
            Type t2 = entry.GetType();

            if (t.Equals(t2))
            {
                Segment s   = (Segment)entry;
                Pen     pen = new Pen(Color.FromArgb(entry.Couleur), 4);
                g.DrawLine(pen, s.Point1.X, s.Point1.Y, s.Point2.X, s.Point2.Y);
            }
            else if (successor != null)
            {
                successor.dessiner(entry, g);
            }
        }
Ejemplo n.º 22
0
 public override void contourSelection(Forme_simple forme, Graphics g, Color couleur)
 {
     Type t = typeof(Ellipse);
     Type t2 = forme.GetType();
     if (t.Equals(t2))
     {
         Ellipse e = (Ellipse)forme;
         //Pen pen = new Pen(Color.FromArgb(255, 0, 255, 0), 10); //Couleur de selection
         Pen pen = new Pen(couleur, 10); //Couleur de selection
         g.DrawEllipse(pen, e.Point1.X, e.Point1.Y, e.Largeur, e.Hauteur);
     }
     else if (successor != null)
     {
         successor.contourSelection(forme, g, couleur);
     }
 }
Ejemplo n.º 23
0
        public override void create(Forme_simple entry)
        {
            Type t  = typeof(Ellipse);
            Type t2 = entry.GetType();

            if (t.Equals(t2))
            {
                base.create(entry);
                Ellipse e = (Ellipse)entry;

                //Données membres
                this._command.Parameters.AddWithValue("@x1", e.Point1.X);
                this._command.Parameters.AddWithValue("@y1", e.Point1.Y);
                this._command.Parameters.AddWithValue("@hauteur", e.Hauteur);
                this._command.Parameters.AddWithValue("@largeur", e.Largeur);

                //Définition des requetes
                String[] tabRequete = new String[] {
                    //ellipse
                    @"INSERT INTO ellipse(id, hauteur, largeur) VALUES (@id, @hauteur, @largeur);",
                    //point
                    @"INSERT INTO point(id, ordre, x, y) VALUES (@id, 1, @x1, @y1);"
                };


                foreach (String r in tabRequete)
                {
                    //Définition de la requete
                    this._command.CommandText = r;

                    try
                    {
                        //Execution de la requete
                        this._command.ExecuteNonQuery();
                    }
                    catch (MySqlException ex)
                    {
                        Console.WriteLine("Error: {0}", ex.ToString());
                        throw ex;
                    }
                }
            }
            else if (successor != null)
            {
                successor.create(entry);
            }
        }
Ejemplo n.º 24
0
        public override void contourSelection(Forme_simple forme, Graphics g, Color couleur)
        {
            Type t  = typeof(Ellipse);
            Type t2 = forme.GetType();

            if (t.Equals(t2))
            {
                Ellipse e = (Ellipse)forme;
                //Pen pen = new Pen(Color.FromArgb(255, 0, 255, 0), 10); //Couleur de selection
                Pen pen = new Pen(couleur, 10); //Couleur de selection
                g.DrawEllipse(pen, e.Point1.X, e.Point1.Y, e.Largeur, e.Hauteur);
            }
            else if (successor != null)
            {
                successor.contourSelection(forme, g, couleur);
            }
        }
Ejemplo n.º 25
0
        public override void update(Forme_simple entry)
        {
            Type t  = typeof(Ellipse);
            Type t2 = entry.GetType();

            if (t.Equals(t2))
            {
                base.update(entry);
                Ellipse e = (Ellipse)entry;
                //Données membres
                this._command.Parameters.AddWithValue("@x1", e.Point1.X);
                this._command.Parameters.AddWithValue("@y1", e.Point1.Y);
                this._command.Parameters.AddWithValue("@hauteur", e.Hauteur);
                this._command.Parameters.AddWithValue("@largeur", e.Largeur);

                //Définition des requetes
                String[] tabRequete = new String[] {
                    //ellipse
                    @"UPDATE ellipse SET hauteur = @hauteur, largeur = @largeur WHERE id = @id;",
                    //point
                    @"UPDATE point SET x = @x1, y = @y1 WHERE id = @id AND ordre = 1;"
                };


                foreach (String r in tabRequete)
                {
                    //Définition de la requete
                    this._command.CommandText = r;

                    try
                    {
                        //Execution de la requete
                        this._command.ExecuteNonQuery();
                    }
                    catch (MySqlException ex)
                    {
                        Console.WriteLine("Error: {0}", ex.ToString());
                        throw ex;
                    }
                }
            }
            else if (successor != null)
            {
                successor.update(entry);
            }
        }
Ejemplo n.º 26
0
        public override void create(Forme_simple entry)
        {
            Type t  = typeof(Segment);
            Type t2 = entry.GetType();

            if (t.Equals(t2))
            {
                base.create(entry);
                Segment s = (Segment)entry;
                this._command.Parameters.AddWithValue("@x1", s.Point1.X);
                this._command.Parameters.AddWithValue("@y1", s.Point1.Y);
                this._command.Parameters.AddWithValue("@x2", s.Point2.X);
                this._command.Parameters.AddWithValue("@y2", s.Point2.Y);

                //Définition des requetes
                String[] tabRequete = new String[] {
                    //segment
                    @"INSERT INTO segment(id) VALUES (@id);",
                    //point
                    @"INSERT INTO point(id, ordre, x, y) VALUES (@id, 1, @x1, @y1);",
                    @"INSERT INTO point(id, ordre, x, y) VALUES (@id, 2, @x2, @y2);"
                };


                foreach (String r in tabRequete)
                {
                    //Définition de la requete
                    this._command.CommandText = r;

                    try
                    {
                        //Execution de la requete
                        this._command.ExecuteNonQuery();
                    }
                    catch (MySqlException ex)
                    {
                        Console.WriteLine("Error: {0}", ex.ToString());
                        throw ex;
                    }
                }
            }
            else if (successor != null)
            {
                successor.create(entry);
            }
        }
Ejemplo n.º 27
0
        public override void create(Forme_simple entry)
        {
            Type t = typeof(Ellipse);
            Type t2 = entry.GetType();
            if (t.Equals(t2))
            {
                base.create(entry);
                Ellipse e = (Ellipse)entry;

                //Données membres
                this._command.Parameters.AddWithValue("@x1", e.Point1.X);
                this._command.Parameters.AddWithValue("@y1", e.Point1.Y);
                this._command.Parameters.AddWithValue("@hauteur", e.Hauteur);
                this._command.Parameters.AddWithValue("@largeur", e.Largeur);

                //Définition des requetes
                String[] tabRequete = new String[] {
                    //ellipse
                    @"INSERT INTO ellipse(id, hauteur, largeur) VALUES (@id, @hauteur, @largeur);",
                    //point
                    @"INSERT INTO point(id, ordre, x, y) VALUES (@id, 1, @x1, @y1);"
                };

                foreach (String r in tabRequete)
                {
                    //Définition de la requete
                    this._command.CommandText = r;

                    try
                    {
                        //Execution de la requete
                        this._command.ExecuteNonQuery();
                    }
                    catch (MySqlException ex)
                    {
                        Console.WriteLine("Error: {0}", ex.ToString());
                        throw ex;
                    }
                }
            }
            else if (successor != null)
            {
                successor.create(entry);
            }
        }
Ejemplo n.º 28
0
        public override void create(Forme_simple entry)
        {
            Type t = typeof(Segment);
            Type t2 = entry.GetType();
            if (t.Equals(t2))
            {
                base.create(entry);
                Segment s = (Segment)entry;
                this._command.Parameters.AddWithValue("@x1", s.Point1.X);
                this._command.Parameters.AddWithValue("@y1", s.Point1.Y);
                this._command.Parameters.AddWithValue("@x2", s.Point2.X);
                this._command.Parameters.AddWithValue("@y2", s.Point2.Y);

                //Définition des requetes
                String[] tabRequete = new String[] {
                    //segment
                    @"INSERT INTO segment(id) VALUES (@id);",
                    //point
                    @"INSERT INTO point(id, ordre, x, y) VALUES (@id, 1, @x1, @y1);",
                    @"INSERT INTO point(id, ordre, x, y) VALUES (@id, 2, @x2, @y2);"
                };

                foreach (String r in tabRequete)
                {
                    //Définition de la requete
                    this._command.CommandText = r;

                    try
                    {
                        //Execution de la requete
                        this._command.ExecuteNonQuery();
                    }
                    catch (MySqlException ex)
                    {
                        Console.WriteLine("Error: {0}", ex.ToString());
                        throw ex;
                    }
                }
            }
            else if (successor != null)
            {
                successor.create(entry);
            }
        }
Ejemplo n.º 29
0
        public override void update(Forme_simple entry)
        {
            Type t  = typeof(Segment);
            Type t2 = entry.GetType();

            if (t.Equals(t2))
            {
                base.update(entry);
                Segment s = (Segment)entry;
                this._command.Parameters.AddWithValue("@x1", s.Point1.X);
                this._command.Parameters.AddWithValue("@y1", s.Point1.Y);
                this._command.Parameters.AddWithValue("@x2", s.Point2.X);
                this._command.Parameters.AddWithValue("@y2", s.Point2.Y);

                //Définition des requetes
                String[] tabRequete = new String[] {
                    //point
                    @"UPDATE point SET x = @x1, y = @y1 WHERE id = @id AND ordre = 1;",
                    @"UPDATE point SET x = @x2, y = @y2 WHERE id = @id AND ordre = 2;"
                };


                foreach (String r in tabRequete)
                {
                    //Définition de la requete
                    this._command.CommandText = r;

                    try
                    {
                        //Execution de la requete
                        this._command.ExecuteNonQuery();
                    }
                    catch (MySqlException ex)
                    {
                        Console.WriteLine("Error: {0}", ex.ToString());
                        throw ex;
                    }
                }
            }
            else if (successor != null)
            {
                successor.update(entry);
            }
        }
Ejemplo n.º 30
0
        public override void create(Forme_simple entry)
        {
            Type t  = typeof(Polygone);
            Type t2 = entry.GetType();

            if (t.Equals(t2))
            {
                base.create(entry);
                Polygone p = (Polygone)entry;

                //Définition des requetes
                List <String> tabRequete_poly = new List <String>();
                //polygone
                tabRequete_poly.Add(@"INSERT INTO polygone(id) VALUES (@id);");
                //point
                for (int i = 1; i <= p.Tableau_points.Length; i++)
                {
                    tabRequete_poly.Add(@"INSERT INTO point(id, ordre, x, y) VALUES (@id, " + i + ", " + p.Tableau_points[i - 1].X + ", " + p.Tableau_points[i - 1].Y + ");");
                }

                foreach (String r in tabRequete_poly)
                {
                    //Définition de la requete
                    this._command.CommandText = r;

                    try
                    {
                        //Execution de la requete
                        this._command.ExecuteNonQuery();
                    }
                    catch (MySqlException ex)
                    {
                        Console.WriteLine("Error: {0}", ex.ToString());
                        throw ex;
                    }
                }
            }
            else if (successor != null)
            {
                successor.create(entry);
            }
        }
Ejemplo n.º 31
0
        public override void update(Forme_simple entry)
        {
            Type t  = typeof(Triangle);
            Type t2 = entry.GetType();

            if (t.Equals(t2))
            {
                base.update(entry);
                Triangle tr = (Triangle)entry;

                //Définition des requetes
                List <String> tabRequete_triangle = new List <String>();

                //point
                for (int i = 1; i <= tr.Tableau_points.Length; i++)
                {
                    tabRequete_triangle.Add(@"UPDATE point SET x = " + tr.Tableau_points[i - 1].X + ", y = " + tr.Tableau_points[i - 1].Y + " WHERE id = @id AND ordre = " + i + ";");
                }

                foreach (String r in tabRequete_triangle)
                {
                    //Définition de la requete
                    this._command.CommandText = r;

                    try
                    {
                        //Execution de la requete
                        this._command.ExecuteNonQuery();
                    }
                    catch (MySqlException ex)
                    {
                        Console.WriteLine("Error: {0}", ex.ToString());
                        throw ex;
                    }
                }
            }
            else if (successor != null)
            {
                successor.update(entry);
            }
        }
Ejemplo n.º 32
0
        public override void create(Forme_simple entry)
        {
            Type t = typeof(Polygone);
            Type t2 = entry.GetType();
            if (t.Equals(t2))
            {
                base.create(entry);
                Polygone p = (Polygone)entry;

                //Définition des requetes
                List<String> tabRequete_poly = new List<String>();
                //polygone
                tabRequete_poly.Add(@"INSERT INTO polygone(id) VALUES (@id);");
                //point
                for (int i = 1; i <= p.Tableau_points.Length; i++)
                {
                    tabRequete_poly.Add(@"INSERT INTO point(id, ordre, x, y) VALUES (@id, " + i + ", " + p.Tableau_points[i - 1].X + ", " + p.Tableau_points[i - 1].Y + ");");
                }

                foreach (String r in tabRequete_poly)
                {
                    //Définition de la requete
                    this._command.CommandText = r;

                    try
                    {
                        //Execution de la requete
                        this._command.ExecuteNonQuery();
                    }
                    catch (MySqlException ex)
                    {
                        Console.WriteLine("Error: {0}", ex.ToString());
                        throw ex;
                    }
                }
            }
            else if (successor != null)
            {
                successor.create(entry);
            }
        }
Ejemplo n.º 33
0
        private void clearTouteLappli()
        {
            this.ListFormes.Clear();
            this.ListGroupes.Clear();

            refreshPanel();

            if (this.forme_active != null)
            {
                this.forme_active.IdGroupe = -1;
                this.forme_active          = null;
            }

            //Visuel partie droite
            textBox_nom.Clear();
            panel_couleur.BackColor = Color.Black;
            //labelNomGroupeActif.Text = "Aucun";
            //labelGroupeActif.Text = "Groupe Inactif";

            //Visuel Listes de groupe
            majListeAjoutGroupes();
            majListeSupprGroupes();
        }
Ejemplo n.º 34
0
        private void clearTouteLappli()
        {
            this.ListFormes.Clear();
            this.ListGroupes.Clear();

            refreshPanel();

            if (this.forme_active != null)
            {
                this.forme_active.IdGroupe = -1;
                this.forme_active = null;
            }

            //Visuel partie droite
            textBox_nom.Clear();
            panel_couleur.BackColor = Color.Black;
            //labelNomGroupeActif.Text = "Aucun";
            //labelGroupeActif.Text = "Groupe Inactif";

            //Visuel Listes de groupe
            majListeAjoutGroupes();
            majListeSupprGroupes();
        }
Ejemplo n.º 35
0
        public override void update(Forme_simple entry)
        {
            Type t = typeof(Ellipse);
            Type t2 = entry.GetType();
            if (t.Equals(t2))
            {
                base.update(entry);
                Ellipse e = (Ellipse)entry;
                //Données membres
                this._command.Parameters.AddWithValue("@x1", e.Point1.X);
                this._command.Parameters.AddWithValue("@y1", e.Point1.Y);
                this._command.Parameters.AddWithValue("@hauteur", e.Hauteur);
                this._command.Parameters.AddWithValue("@largeur", e.Largeur);

                //Définition des requetes
                String[] tabRequete = new String[] {
                    //ellipse
                    @"UPDATE ellipse SET hauteur = @hauteur, largeur = @largeur WHERE id = @id;",
                    //point
                    @"UPDATE point SET x = @x1, y = @y1 WHERE id = @id AND ordre = 1;"
                };

                foreach (String r in tabRequete)
                {
                    //Définition de la requete
                    this._command.CommandText = r;

                    try
                    {
                        //Execution de la requete
                        this._command.ExecuteNonQuery();
                    }
                    catch (MySqlException ex)
                    {
                        Console.WriteLine("Error: {0}", ex.ToString());
                        throw ex;
                    }
                }
            }
            else if (successor != null)
            {
                successor.update(entry);
            }
        }
Ejemplo n.º 36
0
        public override void update(Forme_simple entry)
        {
            Type t = typeof(Segment);
            Type t2 = entry.GetType();
            if (t.Equals(t2))
            {
                base.update(entry);
                Segment s = (Segment)entry;
                this._command.Parameters.AddWithValue("@x1", s.Point1.X);
                this._command.Parameters.AddWithValue("@y1", s.Point1.Y);
                this._command.Parameters.AddWithValue("@x2", s.Point2.X);
                this._command.Parameters.AddWithValue("@y2", s.Point2.Y);

                //Définition des requetes
                String[] tabRequete = new String[] {
                    //point
                    @"UPDATE point SET x = @x1, y = @y1 WHERE id = @id AND ordre = 1;",
                    @"UPDATE point SET x = @x2, y = @y2 WHERE id = @id AND ordre = 2;"
                };

                foreach (String r in tabRequete)
                {
                    //Définition de la requete
                    this._command.CommandText = r;

                    try
                    {
                        //Execution de la requete
                        this._command.ExecuteNonQuery();
                    }
                    catch (MySqlException ex)
                    {
                        Console.WriteLine("Error: {0}", ex.ToString());
                        throw ex;
                    }
                }
            }
            else if (successor != null)
            {
                successor.update(entry);
            }
        }
Ejemplo n.º 37
0
 private void rectangleToolStripMenuItem_Click(object sender, EventArgs e)   //attaché à l'item Dessin Rectangle
 {
     this.forme_active = new Rectangle(id, "Rectangle " + id, panel_couleur.BackColor.ToArgb(), new Point(0, 0), 0, 0, -1);
     this.id++;
     activer_dessin();
 }
 public abstract void contourSelection(Forme_simple forme, Graphics g, Color couleur);
Ejemplo n.º 39
0
 //attaché à l'item Dessin Segment
 private void segmentToolStripMenuItem_Click(object sender, EventArgs e)
 {
     this.forme_active = new Segment(id, "Segment " + id, panel_couleur.BackColor.ToArgb(), new Point(0, 0), new Point(0, 0), -1);
     this.id++;
     activer_dessin();
 }
 public abstract void dessiner(Forme_simple entry, Graphics g);
Ejemplo n.º 41
0
        private void majPropriete(Forme_simple forme)
        {
            //Affiche les propriétes de la forme dans la partie DROITE de l'application
            if (forme != null)
            {
                textBox_nom.Text = forme.Nom;//Nom
                panel_couleur.BackColor = Color.FromArgb(forme.Couleur);//Couleur
                //Groupe
                listBoxGroupesLiés.Items.Clear();
                listBoxGroupesLiés.Items.Add("Aucun");
                listBoxGroupesLiés.SetSelected(listBoxGroupesLiés.Items.IndexOf("Aucun"), true);
                //Groupe lié à la forme_active
                Forme_composee GroupeLiéDirectement = this.ListGroupes.Find(groupe => groupe.Id == this.forme_active.IdGroupe);
                if (GroupeLiéDirectement != null)
                {   //Recherche de tous les sous groupes liés directement ou indirectement au groupe forme_active.IdGroupe et les affiche dans listBoxGroupesLiés
                    this.chercheSousGroupes(GroupeLiéDirectement);

                    //Selectionne le groupe lié directement
                    listBoxGroupesLiés.SetSelected(listBoxGroupesLiés.Items.IndexOf(GroupeLiéDirectement.Nom), true);
                }

                //if (forme.IdGroupe == -1)//Groupe
                //{
                //    listBoxGroupesLiés.Items.Clear();
                //    listBoxGroupesLiés.Items.Add("Aucun");
                //    listBoxGroupesLiés.SetSelected(listBoxGroupesLiés.Items.IndexOf("Aucun"), true);
                //}
                //else
                //{
                //    listBoxGroupesLiés.Items.Add(this.ListGroupes.Find(item => item.Id == forme.IdGroupe).Nom);
                //    listBoxGroupesLiés.SetSelected(listBoxGroupesLiés.Items.IndexOf(this.ListGroupes.Find(item => item.Id == forme.IdGroupe).Nom), true);
                //}
            }
        }
Ejemplo n.º 42
0
        //attaché à panel de dessin
        private void panel1_MouseDown(object sender, MouseEventArgs e)
        {
            point_depart = e.Location;
            labelNom.Focus();   //enleve le focus à textBoxNom

            if (e.Button == MouseButtons.Left && this.PeutDessiner)
            {
                //######
                //DESSIN
                //######
                bouton_Mouse_left = true;
                listBoxGroupesLiés.Items.Clear();
                listBoxGroupesLiés.Items.Add("Aucun");
                listBoxGroupesLiés.SetSelected(listBoxGroupesLiés.Items.IndexOf("Aucun"), true);

                if (forme_active != null)
                {
                    if ( !(this.forme_active is Triangle) && !(this.forme_active is Polygone) )
                    {
                        //Dessin de Segments, Ellipse, Rectangle
                        this.forme_active.maj(point_depart, point_depart);
                        ListFormes.Add(this.forme_active);
                        majPropriete(this.forme_active);
                    }
                    else
                    {   //Dessin de Triangle/Polygone
                        if (i == this.nb_points_poly - 1)
                        {
                            tabcoord[i] = point_depart;
                            forme_active.maj(tabcoord);
                            ListFormes.Add(this.forme_active);
                            this.i = 0;
                            this.PeutDessiner = false;
                            panel1.Cursor = System.Windows.Forms.Cursors.Default;

                            this.refreshPanel();
                            majListeAjoutGroupes();
                        }
                        else
                        {
                            tabcoord[i] = point_depart;
                            this.i++;
                        }
                    }
                }
            }
            else if (e.Button == MouseButtons.Left && !this.PeutDessiner)
            {
                //#########
                //SELECTION
                //#########
                bouton_Mouse_left = true;
                //Selectionne une forme
                foreach (Forme_simple forme in ListFormes)
                {
                    if (forme.recuperer(point_depart.X, point_depart.Y))
                    {
                        this.selected = true;
                        this.forme_active = forme;
                        break;
                    }
                }
                if(this.forme_active != null)
                    majPropriete(forme_active);

            }
        }
Ejemplo n.º 43
0
        private void Form1_KeyDown(object sender, KeyEventArgs e)   //attaché au formulaire
        {
            /////Ctrl+HAUT (Controler le groupe du groupe de la forme active (son SUPERGROUPE))
            //if (e.KeyCode == Keys.Up && e.Modifiers == Keys.Control)
            //{
            //    if ((this.forme_active.IdGroupe != -1))
            //    {//groupe actif, on controle le SUPERGROUPE
            //        //labelGroupeActif.Text = "Groupe Actif";
            //        this.forme_active.IdGroupe = this.ListGroupes.Find(item => item.Id == this.forme_active.IdGroupe).IdGroupe;
            //        Console.WriteLine("Controle du SUPER GROUPE: (" + this.forme_active.IdGroupe);
            //        majPropriete(this.ListGroupes.Find(item => item.Id == this.forme_active.IdGroupe));
            //        majListeAjoutGroupes();
            //    }
            //}

            //Zoom
            if (e.KeyData == Keys.Up)
            {
                if (this.forme_active != null)
                {
                    if (forme_active.IdGroupe != -1)
                    {   //Homothetie sur une forme composée (tout le groupe actif)
                        this.ListGroupes.Find(item => item.Id == this.forme_active.IdGroupe).homothetie(1);

                        //Homothetie sur tous les groupes liés à cette forme composée (le groupe actif)
                        foreach (Forme_composee f in ListGroupes)
                        {
                            if (f.IdGroupe == this.forme_active.IdGroupe)
                            {//Si le groupe parcouru est lié au groupe actif
                                f.homothetie(1);
                            }
                        }
                    }
                    else
                    {
                        this.forme_active.homothetie(1);
                    }
                    this.refreshPanel();
                }
            }
            //Dezoom
            if (e.KeyData == Keys.Down)
            {
                if (this.forme_active != null)
                {
                    if (forme_active.IdGroupe != -1)
                    {
                        //Homothetie sur une forme composée (tout le groupe actif)
                        this.ListGroupes.Find(item => item.Id == this.forme_active.IdGroupe).homothetie(-1);

                        //Homothetie sur tous les groupes liés à cette forme composée (le groupe actif)
                        foreach (Forme_composee f in ListGroupes)
                        {
                            if (f.IdGroupe == this.forme_active.IdGroupe)
                            {//Si le groupe parcouru est lié au groupe actif
                                f.homothetie(-1);
                            }
                        }
                    }
                    else
                    {
                        //g2.Clear(Color.White);
                        this.forme_active.homothetie(-1);
                    }

                    this.refreshPanel();
                }
            }
            //Suppression d'une forme ou d'un groupe
            if (e.KeyData == Keys.Delete && this.forme_active != null && this.forme_active.IdGroupe == -1)
            {
                Console.WriteLine("Suppression d'une forme simple");
                this.ListFormes.Remove(this.forme_active);
                if (this.forme_active.IdGroupe != -1)
                {//Liée à un groupe
                    int MASTERgroupe = this.forme_active.IdGroupe;
                    while (MASTERgroupe != -1)
                    {                                                                                                  //Si il y a un MASTERgroupe
                        this.ListGroupes.Find(item => item.Id == MASTERgroupe).Liste_formes.Remove(this.forme_active); //suppresion de la liste du MASTERgroupe
                        MASTERgroupe = this.ListGroupes.Find(item => item.Id == MASTERgroupe).IdGroupe;                //si le groupe visité est lié
                    }
                }
                //VISUEL
                textBox_nom.Clear();//Nom
                listBoxGroupesLiés.Items.Clear();
                this.forme_active = null;
                this.refreshPanel();
            }
        }
Ejemplo n.º 44
0
 //attaché à l'item Dessin Triangle
 private void triangleToolStripMenuItem_Click(object sender, EventArgs e)
 {
     this.nb_points_poly = 3;
     this.tabcoord = new Point[this.nb_points_poly];
     this.forme_active = new Triangle(id, "Triangle " + id, panel_couleur.BackColor.ToArgb(), tabcoord, -1);
     this.id++;
     activer_dessin();
 }
Ejemplo n.º 45
0
 //attaché à l'item Dessin Polygone
 private void polygoneToolStripMenuItem_Click(object sender, EventArgs e)
 {
     this.forme_active = new Polygone(id, "Polygone " + id, panel_couleur.BackColor.ToArgb(), tabcoord, -1);
     this.id++;
     label10.Visible = true;
     textBoxNbPoints.Visible = true;
     textBoxNbPoints.Focus();
 }
Ejemplo n.º 46
0
 private void segmentToolStripMenuItem_Click(object sender, EventArgs e) //attaché à l'item Dessin Segment
 {
     this.forme_active = new Segment(id, "Segment " + id, panel_couleur.BackColor.ToArgb(), new Point(0, 0), new Point(0, 0), -1);
     this.id++;
     activer_dessin();
 }
 public abstract void dessiner(Forme_simple entry, Graphics g);
 public abstract void contourSelection(Forme_simple forme, Graphics g, Color couleur);
Ejemplo n.º 49
0
        //attaché au formulaire
        private void Form1_KeyDown(object sender, KeyEventArgs e)
        {
            /////Ctrl+HAUT (Controler le groupe du groupe de la forme active (son SUPERGROUPE))
            //if (e.KeyCode == Keys.Up && e.Modifiers == Keys.Control)
            //{
            //    if ((this.forme_active.IdGroupe != -1))
            //    {//groupe actif, on controle le SUPERGROUPE
            //        //labelGroupeActif.Text = "Groupe Actif";
            //        this.forme_active.IdGroupe = this.ListGroupes.Find(item => item.Id == this.forme_active.IdGroupe).IdGroupe;
            //        Console.WriteLine("Controle du SUPER GROUPE: (" + this.forme_active.IdGroupe);
            //        majPropriete(this.ListGroupes.Find(item => item.Id == this.forme_active.IdGroupe));
            //        majListeAjoutGroupes();
            //    }
            //}

            //Zoom
            if (e.KeyData == Keys.Up)
            {
                if (this.forme_active != null)
                {
                    if (forme_active.IdGroupe != -1)
                    {   //Homothetie sur une forme composée (tout le groupe actif)
                        this.ListGroupes.Find(item => item.Id == this.forme_active.IdGroupe).homothetie(1);

                        //Homothetie sur tous les groupes liés à cette forme composée (le groupe actif)
                        foreach (Forme_composee f in ListGroupes)
                        {
                            if (f.IdGroupe == this.forme_active.IdGroupe)
                            {//Si le groupe parcouru est lié au groupe actif
                                f.homothetie(1);
                            }
                        }
                    }
                    else
                    {
                        this.forme_active.homothetie(1);
                    }
                    this.refreshPanel();
                }
            }
            //Dezoom
            if (e.KeyData == Keys.Down)
            {
                if (this.forme_active != null)
                {
                    if (forme_active.IdGroupe != -1)
                    {
                        //Homothetie sur une forme composée (tout le groupe actif)
                        this.ListGroupes.Find(item => item.Id == this.forme_active.IdGroupe).homothetie(-1);

                        //Homothetie sur tous les groupes liés à cette forme composée (le groupe actif)
                        foreach (Forme_composee f in ListGroupes)
                        {
                            if (f.IdGroupe == this.forme_active.IdGroupe)
                            {//Si le groupe parcouru est lié au groupe actif
                                f.homothetie(-1);
                            }
                        }
                    }
                    else
                    {
                        //g2.Clear(Color.White);
                        this.forme_active.homothetie(-1);
                    }

                    this.refreshPanel();
                }
            }
            //Suppression d'une forme ou d'un groupe
            if (e.KeyData == Keys.Delete && this.forme_active != null && this.forme_active.IdGroupe == -1)
            {
                Console.WriteLine("Suppression d'une forme simple");
                this.ListFormes.Remove(this.forme_active);
                if (this.forme_active.IdGroupe != -1)
                {//Liée à un groupe
                    int MASTERgroupe = this.forme_active.IdGroupe;
                    while (MASTERgroupe != -1)
                    {//Si il y a un MASTERgroupe
                        this.ListGroupes.Find(item => item.Id == MASTERgroupe).Liste_formes.Remove(this.forme_active);   //suppresion de la liste du MASTERgroupe
                        MASTERgroupe = this.ListGroupes.Find(item => item.Id == MASTERgroupe).IdGroupe;//si le groupe visité est lié
                    }
                }
                //VISUEL
                textBox_nom.Clear();//Nom
                listBoxGroupesLiés.Items.Clear();
                this.forme_active = null;
                this.refreshPanel();
            }
        }
Ejemplo n.º 50
0
 //attaché à l'item Dessin Rectangle
 private void rectangleToolStripMenuItem_Click(object sender, EventArgs e)
 {
     this.forme_active = new Rectangle(id, "Rectangle " + id, panel_couleur.BackColor.ToArgb(), new Point(0, 0), 0, 0, -1);
     this.id++;
     activer_dessin();
 }
Ejemplo n.º 51
0
 //attaché à l'item Dessin Ellipse
 private void ellipseToolStripMenuItem_Click(object sender, EventArgs e)
 {
     textBox_nom.Clear();
     this.forme_active = new Ellipse(id, "Ellipse " + id, panel_couleur.BackColor.ToArgb(), new Point(0, 0), 0, 0, -1);
     this.id++;
     activer_dessin();
 }
Ejemplo n.º 52
0
        private void panel1_MouseDown(object sender, MouseEventArgs e)  //attaché à panel de dessin
        {
            point_depart = e.Location;
            labelNom.Focus();   //enleve le focus à textBoxNom

            if (e.Button == MouseButtons.Left && this.PeutDessiner)
            {
                //######
                //DESSIN
                //######
                bouton_Mouse_left = true;
                listBoxGroupesLiés.Items.Clear();
                listBoxGroupesLiés.Items.Add("Aucun");
                listBoxGroupesLiés.SetSelected(listBoxGroupesLiés.Items.IndexOf("Aucun"), true);

                if (forme_active != null)
                {
                    if (!(this.forme_active is Triangle) && !(this.forme_active is Polygone))
                    {
                        //Dessin de Segments, Ellipse, Rectangle
                        this.forme_active.maj(point_depart, point_depart);
                        ListFormes.Add(this.forme_active);
                        majPropriete(this.forme_active);
                    }
                    else
                    {   //Dessin de Triangle/Polygone
                        if (i == this.nb_points_poly - 1)
                        {
                            tabcoord[i] = point_depart;
                            forme_active.maj(tabcoord);
                            ListFormes.Add(this.forme_active);
                            this.i            = 0;
                            this.PeutDessiner = false;
                            panel1.Cursor     = System.Windows.Forms.Cursors.Default;

                            this.refreshPanel();
                            majListeAjoutGroupes();
                        }
                        else
                        {
                            tabcoord[i] = point_depart;
                            this.i++;
                        }
                    }
                }
            }
            else if (e.Button == MouseButtons.Left && !this.PeutDessiner)
            {
                //#########
                //SELECTION
                //#########
                bouton_Mouse_left = true;
                //Selectionne une forme
                foreach (Forme_simple forme in ListFormes)
                {
                    if (forme.recuperer(point_depart.X, point_depart.Y))
                    {
                        this.selected     = true;
                        this.forme_active = forme;
                        break;
                    }
                }
                if (this.forme_active != null)
                {
                    majPropriete(forme_active);
                }
            }
        }
Ejemplo n.º 53
0
        public override void update(Forme_simple entry)
        {
            Type t = typeof(Triangle);
            Type t2 = entry.GetType();
            if (t.Equals(t2))
            {
                base.update(entry);
                Triangle tr = (Triangle)entry;

                //Définition des requetes
                List<String> tabRequete_triangle = new List<String>();

                //point
                for (int i = 1; i <= tr.Tableau_points.Length; i++)
                {
                    tabRequete_triangle.Add(@"UPDATE point SET x = " + tr.Tableau_points[i - 1].X + ", y = " + tr.Tableau_points[i - 1].Y + " WHERE id = @id AND ordre = " + i + ";");
                }

                foreach (String r in tabRequete_triangle)
                {
                    //Définition de la requete
                    this._command.CommandText = r;

                    try
                    {
                        //Execution de la requete
                        this._command.ExecuteNonQuery();
                    }
                    catch (MySqlException ex)
                    {
                        Console.WriteLine("Error: {0}", ex.ToString());
                        throw ex;
                    }
                }
            }
            else if (successor != null)
            {
                successor.update(entry);
            }
        }