/// <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; }