private NShape CreateLabelShape(string text) { NShape labelShape = new NShape(); // Configure shape labelShape.SetBounds(0, 0, 100, 30); labelShape.SetProtectionMask(ENDiagramItemOperationMask.All); labelShape.CanSplit = false; labelShape.GraphPart = false; labelShape.RouteThroughHorizontally = true; labelShape.RouteThroughVertically = true; // Set text and make text block resize to text labelShape.Text = text; ((NTextBlock)labelShape.TextBlock).ResizeMode = ENTextBlockResizeMode.TextSize; // Set text background and border labelShape.TextBlock.BackgroundFill = new NColorFill(NColor.White); labelShape.TextBlock.Border = NBorder.CreateFilledBorder(NColor.Black); labelShape.TextBlock.BorderThickness = new NMargins(1); labelShape.TextBlock.Padding = new NMargins(2); // Add a port to the shape labelShape.Ports.Add(new NPort(0.5, 0.5, true)); return(labelShape); }