private void Création(TypeSchéma type, Form parent, string texte) { InitializeComponent(); Text = texte; MdiParent = parent; typeSchéma = type; g = new Graph(noeuds, traits); foreach (string lt in System.Enum.GetNames(typeof(GraphLayoutType))) layoutComboBox.Items.Add(lt); option.Type_schéma = type; this.MouseWheel += DessinObjets_MouseWheel; vScroll.Minimum = 000; vScroll.Maximum = 800; vScroll.SmallChange = 4; vScroll.LargeChange = 50; hScroll.MouseWheel += hScroll_MouseWheel; déplacement.Checked = false; option.Origine_Zoom = new Point(this.Width / 2, this.Height / 2); homothétie.Text = "100%"; Option.Type_schéma = type; créeEntitéAssociationButton.Visible = false; créeRelationsBouton.Visible = false; versSQL.Visible = false; applySql.Visible = false; parcoursSQL.Visible = false; switch (option.Type_schéma) { case TypeSchéma.Graphe: separatorRelation.Visible = false; separatorEntité.Visible = false; break; case TypeSchéma.SqlReverse: case TypeSchéma.Relationnel: versSQL.Visible = true; applySql.Visible = true; parcoursSQL.Visible = true; créeEntitéAssociationButton.Visible = true; break; case TypeSchéma.EntitéAssociation: créeRelationsBouton.Visible = true; separatorEntité.Visible = false; break; } InitialisationRessources(); }
/// <summary> /// Méthode statique de Layout /// </summary> /// <param name="graphe">Graphe entrée</param> /// <param name="rectangle">Zone de dessin</param> /// <param name="layout">Type de layout</param> /// <returns>Le graphe repositionné</returns> public static Graph LayoutGraph(Graph graphe, Rectangle rectangle, GraphLayoutType layout) { Microsoft.Chung.Core.Graph mcg = new Microsoft.Chung.Core.Graph(); #region Copy the graph foreach (Noeud n in graphe.Noeuds) { if (!n.Supprimé) { Microsoft.Chung.Core.Vertex v = new Microsoft.Chung.Core.Vertex(); v.SetValue("ID", n.ID); v.Name = n.Texte; mcg.Vertices.Add(v); } } foreach (Trait e in graphe.Traits) { Microsoft.Chung.Core.IVertex vs; Microsoft.Chung.Core.IVertex vt; mcg.Vertices.Find(e.Source.Texte, out vs); mcg.Vertices.Find(e.Destination.Texte, out vt); if ((vs != null) && (vt != null)) { Microsoft.Chung.Core.Edge mce = new Microsoft.Chung.Core.Edge(vs, vt, true); mcg.Edges.Add(mce); } } #endregion ILayout fr = ChooseLayout(layout); rectangle = new Rectangle(100, 100, rectangle.Width - 150, rectangle.Height - 150); LayoutContext t = new LayoutContext(rectangle, gd); fr.LayOutGraph(mcg, t); gd.Layout = fr; #region Update initialgraph foreach (Noeud n in graphe.Noeuds) { lock (graphe) { Microsoft.Chung.Core.IVertex vs; mcg.Vertices.Find(n.Texte, out vs); n.Déplace(new Point((int)vs.Location.X, (int)vs.Location.Y)); } } #endregion return graphe; }