void comboDirection_SelectedIndexChanged(object sender, EventArgs e) { OrgChartLayoutManager mgr = diagram1.LayoutManager as OrgChartLayoutManager; if (mgr != null) { if (comboDirection.SelectedIndex == 0) { mgr.RotateDirection = RotateDirection.TopToBottom; } if (comboDirection.SelectedIndex == 1) { mgr.RotateDirection = RotateDirection.BottomToTop; } if (comboDirection.SelectedIndex == 2) { mgr.RotateDirection = RotateDirection.LeftToRight; } if (comboDirection.SelectedIndex == 3) { mgr.RotateDirection = RotateDirection.RightToLeft; } mgr.UpdateLayout(null); } }
private void Form1_Load(object sender, EventArgs e) { diagram1.BeginUpdate(); this.diagram1.Controller.InPlaceEditing = false; this.dtLayoutMgr = new OrgChartLayoutManager(this.diagram1.Model, RotateDirection.TopToBottom, 40, 50, LayoutType.Waterfall, 1); dtLayoutMgr.LeftMargin = 10; dtLayoutMgr.TopMargin = 10; dtLayoutMgr.VerticalSpacing = 50; diagram1.LayoutManager = dtLayoutMgr; DiagramAppearance(); InitializeDiagramFromXMLData(); this.diagram1.View.SelectionList.Clear(); txtHSpacing.Text = dtLayoutMgr.HorizontalSpacing.ToString(); txtVSpacing.Text = dtLayoutMgr.VerticalSpacing.ToString(); txtLMarigin.Text = dtLayoutMgr.LeftMargin.ToString(); txtTMarigin.Text = dtLayoutMgr.TopMargin.ToString(); chkAutoLayout.Checked = dtLayoutMgr.AutoLayout; comboLytType.SelectedIndex = 0; comboBShape.SelectedIndex = 1; comboExpSymbol.SelectedIndex = 0; diagram1.EndUpdate(); comboBShape.SelectedIndexChanged += new EventHandler(comboBShape_SelectedIndexChanged); comboExpSymbol.SelectedIndexChanged += new EventHandler(comboExpSymbol_SelectedIndexChanged); apply.Click += new EventHandler(apply_Click); diagram1.MouseMove += new MouseEventHandler(diagram1_MouseMove); diagram1.EventSink.NodeMouseEnter += new Syncfusion.Windows.Forms.Diagram.NodeMouseEventHandler(EventSink_NodeMouseEnter); this.dtLayoutMgr.UpdateLayout(this); }
void apply_Click(object sender, EventArgs e) { this.diagram1.BeginUpdate(); dtLayoutMgr = new OrgChartLayoutManager(this.diagram1.Model, RotateDirection.TopToBottom, 20, 50, (LayoutType)Enum.Parse(typeof(LayoutType), this.comboLytType.SelectedItem.ToString(), true), 1, true); if (txtHSpacing.Text != string.Empty) { dtLayoutMgr.LeftMargin = float.Parse(txtLMarigin.Text); } if (txtVSpacing.Text != string.Empty) { dtLayoutMgr.TopMargin = float.Parse(txtTMarigin.Text); } if (txtLMarigin.Text != string.Empty) { dtLayoutMgr.HorizontalSpacing = float.Parse(txtHSpacing.Text); } if (txtTMarigin.Text != string.Empty) { dtLayoutMgr.VerticalSpacing = float.Parse(txtVSpacing.Text); } dtLayoutMgr.AutoLayout = chkAutoLayout.Checked; this.diagram1.LayoutManager = this.dtLayoutMgr; this.dtLayoutMgr.UpdateLayout(null); this.diagram1.EndUpdate(); this.diagram1.UpdateView(); }
/// <summary> /// Adding new Employee items /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void employee_Add(object sender, EventArgs e) { if (this.textBox1.Text != "") { employeeList.Add(new EmployeeClass(empCount++, Convert.ToInt32(this.comboBox1.SelectedValue), this.textBox1.Text)); OrgChartLayoutManager ltManager = new OrgChartLayoutManager(this.diagram1.Model, RotateDirection.TopToBottom, 40, 40); this.diagram1.LayoutManager = ltManager; ltManager.UpdateLayout(this); } }
/// <summary> /// Apply layout to the Diagram /// </summary> private void LayoutNodes() { diagram1.View.SelectionList.Clear(); OrgChartLayoutManager layout = new OrgChartLayoutManager(diagram1.Model, RotateDirection.TopToBottom, 30, 80); layout.LeftMargin = 10; layout.TopMargin = 50; diagram1.LayoutManager = layout; layout.AutoLayout = true; //diagram1.LayoutManager.AutoLayout = true; diagram1.LayoutManager.UpdateLayout(null); }
private void btnRemove_Click(object sender, EventArgs e) { //Removing an item from the list should explicitly call the RemoveNode to remove its node instance from the SourceListSetCollection and refreshing the Diagram control appropriately. It will also remove the node relation that is associated with the node instance. if (this.comboBox1.SelectedValue != null) { object empObj = GetEmployeeItemFromList((int)this.comboBox1.SelectedValue); if (empObj != null) { this.dEngineSelfRelation.SourceListSet.RemoveNode(this.dEngineSelfRelation.SourceListSet[0], empObj); this.dEngineSelfRelation.Diagram.Refresh(); this.employeeList.Remove((EmployeeClass)empObj); } } OrgChartLayoutManager ltManager = new OrgChartLayoutManager(this.diagram1.Model, RotateDirection.TopToBottom, 40, 40); this.diagram1.LayoutManager = ltManager; ltManager.UpdateLayout(this); }
public Form1() { InitializeComponent(); #region Self Relation Init dEngineSelfRelation = new DiagramDataBindingManager(this.diagram1); dEngineSelfRelation.ListenToRelationChanges = true; //List of data objects employeeList = new BindingList <EmployeeClass>(); employeeList.Add(new EmployeeClass(empCount++, -1, "Mark")); employeeList.Add(new EmployeeClass(empCount++, 0, "Spencer")); employeeList.Add(new EmployeeClass(empCount++, 0, "Carlos")); employeeList.Add(new EmployeeClass(empCount++, 1, "Elliot")); employeeList.Add(new EmployeeClass(empCount++, 1, "Benson")); employeeList.Add(new EmployeeClass(empCount++, 2, "Margaret")); employeeList.Add(new EmployeeClass(empCount++, 1, "Rodriguez")); employeeList.Add(new EmployeeClass(empCount++, 2, "Samuel")); employeeList.Add(new EmployeeClass(empCount++, 4, "Micheal")); employeeList.Add(new EmployeeClass(empCount++, 7, "Whitaker")); this.comboBox1.DataSource = employeeList; this.comboBox1.DisplayMember = "EmployeeName"; this.comboBox1.ValueMember = "Id"; OrgChartLayoutManager ltManager = new OrgChartLayoutManager(this.diagram1.Model, RotateDirection.TopToBottom, 40, 50); ltManager.LeftMargin = 10; ltManager.TopMargin = -20; this.diagram1.LayoutManager = ltManager; dEngineSelfRelation.NodeAdded += new NodeAddedEventHandler(dEngineSelfRelation_NodeAdded); //Adding the list collection to SourceListSet dEngineSelfRelation.SourceListSet.Add(new SourceListSetEntry("EmployeeList", employeeList)); dEngineSelfRelation.ProvideNodeConnectorInfo += new NodeConnectEventHandler(dEngineSelfRelation_ProvideNodeConnectorInfo); //Adding a self relation dEngineSelfRelation.Relations.Add(new NodeRelationDescriptor("Manager_Employee", "EmployeeList", "Id", "EmployeeList", "ManagerId", RelationType.SelfRelation)); #endregion #region ParentChild Init this.diagram2.LayoutManager = new OrgChartLayoutManager(this.diagram2.Model, RotateDirection.TopToBottom, 40, 40); dEngineParentChild = new DiagramDataBindingManager(this.diagram2); //dEngineParentChild.NodeRelationDescriptor.ListenToRelationChanges = true; dEngineParentChild.NodeAdded += new NodeAddedEventHandler(dEngineParentChild_NodeAdded); dEngineParentChild.ProvideNodeConnectorInfo += new NodeConnectEventHandler(dEngineParentChild_ProvideNodeConnectorInfo); InitFamilies(); //Adding self-relation to MatthewFamily dEngineParentChild.Relations.Add(new NodeRelationDescriptor("Matthew_Family", "MatthewFamily", "Id", "MatthewFamily", "ParentId", RelationType.SelfRelation)); //Adding self-relation to JohnsonFamily dEngineParentChild.Relations.Add(new NodeRelationDescriptor("Johnson_Family", "JohnsonFamily", "Id", "JohnsonFamily", "ParentId", RelationType.SelfRelation)); //Adding parentchild / masterdetail relation between both the families dEngineParentChild.Relations.Add(new NodeRelationDescriptor("Matthew_Johnson", "JohnsonFamily", "Id", "MatthewFamily", "Id", RelationType.ParentChild)); #endregion this.diagram1.View.Grid.GridStyle = GridStyle.Line; this.diagram1.View.Grid.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot; this.diagram1.View.Grid.Color = Color.LightGray; this.diagram1.View.Grid.VerticalSpacing = 15; this.diagram1.View.Grid.HorizontalSpacing = 15; this.diagram1.Model.BackgroundStyle.GradientCenter = 0.5f; this.diagram1.Model.BackgroundStyle.ForeColor = Color.Pink; this.diagram1.Model.BackgroundStyle.Color = Color.White; this.diagram1.View.HandleColor = Color.AliceBlue; this.diagram1.View.HandleOutlineColor = Color.SkyBlue; this.diagram1.View.BackgroundColor = Color.White; this.diagram1.Model.DocumentSize = new PageSize(800, 600); this.diagram1.View.Grid.Visible = false; this.diagram2.Model.DocumentSize = new PageSize(900, 600); this.diagram2.View.Grid.GridStyle = GridStyle.Line; this.diagram2.View.Grid.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot; this.diagram2.View.Grid.Color = Color.LightGray; this.diagram2.View.Grid.VerticalSpacing = 15; this.diagram2.View.Grid.HorizontalSpacing = 15; this.diagram2.View.HandleColor = Color.AliceBlue; this.diagram2.View.HandleOutlineColor = Color.SkyBlue; this.diagram1.View.SelectionList.Clear(); this.diagram2.View.SelectionList.Clear(); this.diagram2.View.Grid.Visible = false; this.diagram1.View.BackgroundColor = Color.White; this.diagram1.Model.RenderingStyle.SmoothingMode = SmoothingMode.HighQuality; this.diagram2.Model.RenderingStyle.SmoothingMode = SmoothingMode.HighQuality; diagram1.Model.LineStyle.LineWidth = 0; diagram2.Model.LineStyle.LineWidth = 0; ltManager.UpdateLayout(this); }
private void dialog_BeginLayout(OrgChartLayoutManager layout) { this.diagram1.LayoutManager = layout; LayoutNodes(); }