public EditionContrainte(Contrainte c, Relation relationS, Relation relationD) { InitializeComponent(); contrainte = c; relationSource = relationS; relationDestination = relationD; foreach (Champ ch in relationSource.Champs) cléRelation1.Items.Add(ch.ToString()); foreach (Champ ch in relationDestination.Champs) cléRelation2.Items.Add(ch.ToString()); if (contrainte.Nom != null) { cléRelation1.Text = contrainte.ChampSource.Nom; cléRelation2.Text = contrainte.ChampDestination.Nom; NomRelation.Text = contrainte.Nom; } }
public EditionContrainte(Contrainte c, Relation relationS, Relation relationD) { InitializeComponent(); contrainte = c; relationSource = relationS; relationDestination = relationD; foreach (Champ ch in relationSource.Champs) { cléRelation1.Items.Add(ch.ToString()); } foreach (Champ ch in relationDestination.Champs) { cléRelation2.Items.Add(ch.ToString()); } if (contrainte.Nom != null) { cléRelation1.Text = contrainte.ChampSource.Nom; cléRelation2.Text = contrainte.ChampDestination.Nom; NomRelation.Text = contrainte.Nom; } }
private void ReverseEngineer(string baseSQL) { base_données = baseSQL; this.Text = baseSQL; AccèsSQL AccSQL = new AccèsSQL(baseSQL); Point point = new Point(10, 23); foreach (DataTable d in AccSQL.Tables) { if (d.TableName != "sysdiagrams") { Relation r = new Relation(point, option.Taille_Noeud, option.Couleur_Noeud, option.Épaisseur_Noeud, d); noeuds.Add(r); } } //foreach (DataTable d in AccSQL.ForeignKeys) //{ // Contrainte c = new //} Relation r1 = null, r2 = null; Champ chSource = null, chDest = null; for (int i = 0; i < AccSQL.ForeignKeys.Rows.Count; i++) { foreach(Relation r in noeuds) { if(r.Texte == AccSQL.ForeignKeys.Rows[i].ItemArray[2].ToString()) r1 = r; if(r.Texte == AccSQL.ForeignKeys.Rows[i].ItemArray[8].ToString()) r2 = r; } foreach(Champ ch in r1.Champs) { if(ch.Nom == AccSQL.ForeignKeys.Rows[i].ItemArray[3].ToString()) chSource = ch; } foreach(Champ ch in r2.Champs) { if(ch.Nom == AccSQL.ForeignKeys.Rows[i].ItemArray[9].ToString()) chDest = ch; } Contrainte c = new Contrainte(r1, r2, Color.Black, 2,chSource,chDest); traits.Add(c); } }
private void DessinObjets_MouseUp(object sender, MouseEventArgs e) { if (this.Bounds.Contains((e.Location))) { if (dessinTrait) { if (noeudCourant != null) { #region Création d'une arête Point pointInModel = ScreenToModel(e.Location); Noeud fin = TrouveNoeudCourant(pointInModel); Action subAction = null; if (fin == null) { fin = NoeudParDéfaut(pointInModel, Option.Type_schéma); subAction = new Action(Type_Action.Créer, new List<object>() { fin }); } Trait trait = null; Trait trait_1 = null; if (fin != null) { switch (Option.Type_schéma) { case TypeSchéma.Graphe: trait = new Trait(noeudCourant, fin, option.Couleur_Lien, option.Épaisseur_Lien); break; case TypeSchéma.Relationnel: trait = new Contrainte(noeudCourant, fin, option.Couleur_Lien, option.Épaisseur_Lien); EditionContrainte pa = new EditionContrainte((Contrainte)trait, (Relation)noeudCourant, (Relation)fin); pa.ShowDialog(); break; case TypeSchéma.EntitéAssociation: if (noeudCourant.GetType() != typeof(Association) && fin.GetType() != typeof(Association)) { Point pos = new Point(Math.Abs(noeudCourant.Position.X + fin.Position.X)/2, Math.Abs(noeudCourant.Position.Y + fin.Position.Y)/2); Association asso = new Association(pos, new Size(8, 8), option.Couleur_Lien, option.Épaisseur_Lien, (Entité)noeudCourant, (Entité)fin); trait = new Lien(noeudCourant, asso, option.Couleur_Lien, option.Épaisseur_Lien); trait_1 = new Lien(asso, fin, option.Couleur_Lien, option.Épaisseur_Lien); asso.LienSource = (Lien)trait; asso.LienDestination = (Lien)trait_1; EditionAssociation eA = new EditionAssociation(asso); if (eA.ShowDialog() == DialogResult.OK) { noeuds.Add(asso); } else { trait = null; //si on clique sur annuler, on ne veut plus ajouter le lien trait_1 = null; } } break; } } if (trait_1 != null) { traits.Add(trait_1); Action action = new Action(Type_Action.Créer, new List<object>() { trait_1 }); PushUndo(action); if (subAction != null) action.AddSubAction(subAction); } if (trait != null) { traits.Add(trait); Action action = new Action(Type_Action.Créer, new List<object>() { trait }); PushUndo(action); if (subAction != null) action.AddSubAction(subAction); } pointCourant = Point.Empty; Refresh(); dessinTrait = false; #endregion } } else { #region Déplacement Point pointInModel = ScreenToModel(e.Location); if (Déplacement_Simple) { #region Mode modification if (noeudCourant != null) { noeudCourant.Déplace(pointInModel); PushUndo(new Action(Type_Action.Déplacer, new List<object>() { noeudCourant, origineDéplacement, pointInModel })); } #endregion } else { if (sélection != Rectangle.Empty) { if (DéplacementMultipleEncours) { #region Déplacement_Bloc Action act = new Action(Type_Action.EnBloc, new List<object>()); foreach (Noeud n in noeuds) { if (n.IsSelected) { Point offset = new Point(e.Location.X - StartBlockMovement.X, e.Location.Y - StartBlockMovement.Y); n.DéplaceVers(offset); Point offsetGlobal = new Point(e.Location.X - origineDéplacement.X, e.Location.Y - origineDéplacement.Y); Action ac = new Action(Type_Action.EnBloc, new List<object>() { n, offsetGlobal }); act.AddSubAction(ac); } } PushUndo(act); annulerToolStripMenuItem.Enabled = true; sélection = new Rectangle(sélection.X + e.Location.X - StartBlockMovement.X, sélection.Y + e.Location.Y - StartBlockMovement.Y, sélection.Width, sélection.Height); StartBlockMovement = e.Location; #endregion } else { } } } #endregion } Déplacement_Simple = false; } else { pointCourant = Point.Empty; Refresh(); } }