private void CreateDiagram() { foreach (var dataObject in DataObjects) { var shape = new DiagramShapeEx { Shape = BasicShapes.Rectangle, Size = new Size(150, 100), DatabaseObjectID = dataObject.ID, Content = dataObject.Content }; diagramControl1.Items.Add(shape); if (dataObject.ParentID != dataObject.ID) { diagramControl1.Items.Add(new DiagramConnector { BeginItem = diagramControl1.Items.First(x => x is DiagramShapeEx && ((DiagramShapeEx)x).DatabaseObjectID == dataObject.ParentID), EndItem = shape }); } } diagramControl1.ApplyTreeLayout(Direction.Right); }
void RegisterStencil() { var stencil = new DevExpress.Diagram.Core.DiagramStencil("CustomStencil", "Custom Shapes"); var itemTool = new FactoryItemTool("CustomShape", () => "Custom Shape", diagram => { DiagramShapeEx customShape = new DiagramShapeEx() { Width = 100, Height = 50 }; return(customShape); }, new System.Windows.Size(100, 50), false); stencil.RegisterTool(itemTool); DevExpress.Diagram.Core.DiagramToolboxRegistrator.RegisterStencil(stencil); DiagramControl.ItemTypeRegistrator.Register(typeof(DiagramShapeEx)); }