private void cmdShowTableInDiagram(string arg) { Table tbl = SelectedObject as Table; Diagram d = new Diagram(); d.Name = tbl.Name + " diagram"; d.conn = Provider.ActiveConnection; List<Table> list = new List<Table>(); list.Add(tbl); List<Table> parents = tbl.ReferenceTables.Except(list).ToList(); foreach (Table t in parents) if (!list.Contains(t)) list.Add(t); List<Table> children = tbl.ReferencedByTables.Except(list).ToList(); foreach (Table t in children) if (!list.Contains(t)) list.Add(t); DiagramEditor de = addDiagram(d); de.AddTablesToSchema(list, true); for (int i = 0; i < parents.Count; i++) d.GetTableView(parents[i].Name).Position = new Point(de.Width / 4 - Diagram.Def_TableWidth/2, de.Height / (parents.Count + 1) * (i + 1)); TableView tv = d.GetTableView(tbl.Name); tv.Position = new Point(de.Width / 2 - Diagram.Def_TableWidth / 2, (de.Height - tv.Size.Height) / 2); tv.ShowFull = true; for (int i = 0; i < children.Count; i++) d.GetTableView(children[i].Name).Position = new Point(de.Width / 4 * 3 - Diagram.Def_TableWidth / 2, de.Height / (children.Count + 1) * (i + 1)); d.CorrectConnectionLinesPositions(); de.Invalidate(); }