private void addMember_Click(object sender, EventArgs e) { AddMemberInfoDlg infoDlg = new AddMemberInfoDlg(diagram1.Model.Nodes); if (infoDlg.ShowDialog(this) == DialogResult.OK) { Node memSym = CreateMember(infoDlg.MemberName, infoDlg.Title); Node parentNode = diagram1.Model.Nodes.FindNodeByName(infoDlg.ParentName.ToString()); if (infoDlg.MemberName != string.Empty && infoDlg.Title != string.Empty) { this.diagram1.Model.AppendChild(memSym); } else { MessageBox.Show("Please Enter Name and Role"); memSym = null; } if (parentNode != null && memSym != null) { ConnectNodes(parentNode, memSym); } HierarchicLayoutManager hlyt = new HierarchicLayoutManager(this.diagram1.Model, ((HierarchicLayoutManager)this.diagram1.LayoutManager).RotationAngle, float.Parse(txtVSpacing.Text), float.Parse(txtHSpacing.Text)); hlyt.LeftMargin = float.Parse(txtLMarigin.Text); hlyt.TopMargin = float.Parse(txtTMarigin.Text); this.diagram1.LayoutManager = hlyt; Layouting(); diagram1.View.SelectionList.Clear(); } }
/// <summary> /// Apply Layout to the Diagram /// </summary> private void SetLayout() { HierarchicLayoutManager hierarchicalLayout = new HierarchicLayoutManager(diagram1.Model, 0, 100, 20); hierarchicalLayout.HorizontalSpacing = 20; hierarchicalLayout.VerticalSpacing = 100; hierarchicalLayout.LeftMargin = 10; hierarchicalLayout.TopMargin = 20; diagram1.LayoutManager = hierarchicalLayout; diagram1.LayoutManager.UpdateLayout(null); }
private void Form1_Load(object sender, EventArgs e) { diagram1.BeginUpdate(); DataTable table = new DataTable(); table.Columns.Add("ID", typeof(String)); table.Columns.Add("Title", typeof(String)); table.Columns.Add("ParentID", typeof(String)); table.Columns.Add("Designation", typeof(String)); //' //' Here we add five DataRows. //' table.Rows.Add("1", "John Smith", String.Empty, "CEO"); table.Rows.Add("2", "Joe Robert", "1", "Manager SLS"); table.Rows.Add("3", "Jack Kent", "1", "Manager Mkt"); table.Rows.Add("4", "Ravi Kumar", "2", "Engineer"); table.Rows.Add("5", "Sue Raymond", "2", "Engineer"); table.Rows.Add("6", "Lisa simpson", "4", "Junior Engineer"); table.Rows.Add("7", "Bob Woley", "5", "Junior Engineer"); table.Rows.Add("8", "Ron Jones", "3", "CSR"); table.Rows.Add("9", "Dave Mason", "3", "CSR"); table.Rows.Add("10", "John Williams", "3", "CSR"); dataGridView1.DataSource = table; PopulateFields(table); diagram1.Model.LineStyle.LineColor = Color.Transparent; HierarchicLayoutManager orgchartLayout = new HierarchicLayoutManager(diagram1.Model, 0, 40, 20); orgchartLayout.HorizontalSpacing = 40; orgchartLayout.VerticalSpacing = 70; orgchartLayout.LeftMargin = 20; orgchartLayout.TopMargin = 60; diagram1.LayoutManager = orgchartLayout; diagram1.LayoutManager.UpdateLayout(null); DiagramAppearance(); diagram1.EndUpdate(); }
public Form1() { InitializeComponent(); diagram1.BeginUpdate(); this.diagram1.Model.BoundaryConstraintsEnabled = false; comboLytDirection.SelectedIndex = 0; PopulateFields(SetDataSource()); DiagramAppearance(); hierarchicalLayout = new HierarchicLayoutManager(this.diagram1.Model, 0, 70, 40); hierarchicalLayout.LeftMargin = 50; hierarchicalLayout.TopMargin = 50; this.diagram1.LayoutManager = hierarchicalLayout; this.diagram1.LayoutManager.UpdateLayout(null); txtHSpacing.Text = hierarchicalLayout.HorizontalSpacing.ToString(); txtVSpacing.Text = hierarchicalLayout.VerticalSpacing.ToString(); txtLMarigin.Text = hierarchicalLayout.LeftMargin.ToString(); txtTMarigin.Text = hierarchicalLayout.TopMargin.ToString(); chkAutoLayout.Checked = hierarchicalLayout.AutoLayout; diagram1.EndUpdate(); }