private void alignmentComboBox_SelectedIndexChanged(object sender, System.EventArgs e) { if (alignmentComboBox.SelectedItem == null) { return; } if (EventsHandlingPaused) { return; } // get the selected shape NShape shape = view.Selection.AnchorNode as NShape; if (shape == null || shape.Ports == null) { return; } PauseEventsHandling(); // alter the alignment of a bounds or rotated bounds port NBoundsPort boundsPort = shape.Ports.DefaultInwardPort as NBoundsPort; if (boundsPort != null) { boundsPort.Alignment = new NContentAlignment((ContentAlignment)alignmentComboBox.SelectedItem); } else { NRotatedBoundsPort rotatedBoundsPort = (shape.Ports.DefaultInwardPort as NRotatedBoundsPort); if (rotatedBoundsPort != null) { rotatedBoundsPort.Alignment = new NContentAlignment((ContentAlignment)alignmentComboBox.SelectedItem); } } ResumeEventsHandling(); document.SmartRefreshAllViews(); }
private void CreateShapeWithBoundsPort() { // create a shape with one bounds port NRectangleShape shape = new NRectangleShape(base.GetGridCell(1, 1)); shape.Name = "Shape with Bounds Port"; shape.CreateShapeElements(ShapeElementsMask.Ports); NBoundsPort port = new NBoundsPort(shape.UniqueId, ContentAlignment.TopLeft); shape.Ports.AddChild(port); shape.Ports.DefaultInwardPortUniqueId = port.UniqueId; // connect it with the center shape document.ActiveLayer.AddChild(shape); ConnectShapes(centerShape, shape); // describe it NTextShape text = new NTextShape("Shape with Bounds Port", base.GetGridCell(1, 2, 0, 1)); document.ActiveLayer.AddChild(text); }