menu

Blazor

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class ConnectorSegment - Blazor API Reference | Syncfusion

    Show / Hide Table of Contents

    Class ConnectorSegment

    Represents the segment of the connector. This class is a fundamental part of the connector structure used to visualize connections between diagram nodes.

    Inheritance
    System.Object
    DiagramObject
    ConnectorSegment
    OrthogonalSegment
    StraightSegment
    Implements
    IDiagramObject
    System.ICloneable
    Inherited Members
    DiagramObject.GetParent()
    DiagramObject.OnPropertyChanged(String, Object, Object, IDiagramObject)
    Namespace: Syncfusion.Blazor.Diagram
    Assembly: Syncfusion.Blazor.dll
    Syntax
    public class ConnectorSegment : DiagramObject, IDiagramObject, ICloneable
    Remarks

    This class is essential for handling the structural segments of a connector, typically used in diagram components to connect different nodes or points in a diagram. It supports various segment types, such as straight lines or complex paths.

    Each segment can be customized by setting properties such as the segment type, whether it allows dragging, and the specific points it connects.

    Examples
    <SfDiagramComponent Connectors="@connectors">
    </SfDiagramComponent>
    @code
    {
        public DiagramObjectCollection<Connector> connectors = new DiagramObjectCollection<Connector>();
        protected override void OnInitialized()
        {
            Connector connector = new Connector()
            {
                ID = "straight",
                SourcePoint = new DiagramPoint() { X = 100, Y = 200 },
                TargetPoint = new DiagramPoint() { X = 300, Y = 200 },
                Segments = new DiagramObjectCollection<ConnectorSegment>()
                {
                    // Create a new straight segment 
                    new StraightSegment() { Point = new DiagramPoint(420, 300) },
                }
            };
            connectors.Add(connector);
        }
    }

    Constructors

    ConnectorSegment()

    Initializes a new instance of the ConnectorSegment.

    Declaration
    public ConnectorSegment()

    ConnectorSegment(ConnectorSegment)

    Creates a new instance of the ConnectorSegment from the given ConnectorSegment.

    Declaration
    public ConnectorSegment(ConnectorSegment src)
    Parameters
    Type Name Description
    ConnectorSegment src

    The source ConnectorSegment to clone.

    Properties

    AllowDrag

    Gets or sets a value indicating whether the orthogonal segment thumb can be dragged.

    Declaration
    public bool AllowDrag { get; set; }
    Property Value
    Type Description
    System.Boolean

    A System.Boolean indicating the drag permission for the orthogonal segment thumb. The default value is true.

    Remarks

    This property applies only to orthogonal connectors. Enabling this allows users to drag the thumb to adjust the segment's position.

    Examples

    The following example demonstrates how to enable dragging for an orthogonal segment thumb:

    @code {
      protected override void OnInitialized()
      {
          Connector connector = new Connector()
          {
              ID = "orthogonal",
              Type = ConnectorSegmentType.Orthogonal,
              SourcePoint = new DiagramPoint() { X = 500, Y = 200 },
              TargetPoint = new DiagramPoint() { X = 600, Y = 300 },
              Constraints = ConnectorConstraints.Default | ConnectorConstraints.DragSegmentThumb,
              Segments = new DiagramObjectCollection<ConnectorSegment>()
              {
                  // Create a new orthogonal segment with dragging enabled
                  new OrthogonalSegment() { Length = 100, AllowDrag = true }
              }
          };
          connectors.Add(connector);
      }
    }

    Type

    Gets or sets the type of the ConnectorSegment. This property defines how the segment will be drawn in the diagram.

    Declaration
    public ConnectorSegmentType Type { get; set; }
    Property Value
    Type Description
    ConnectorSegmentType

    A ConnectorSegmentType indicating the type of segment. The default value is Straight.

    Remarks

    The Type property is critical to defining the visual representation of the connector segment. Different segment types, such as straight lines, bezier lines or orthogonal lines, can be set to visualize various connection styles.

    Examples
    <SfDiagramComponent Connectors="@connectors">
    </SfDiagramComponent>
    @code
    {
      public DiagramObjectCollection<Connector> connectors = new DiagramObjectCollection<Connector>();
      protected override void OnInitialized()
      {
        Connector connector = new Connector()
        {
           ID="straight",
            Type = ConnectorSegmentType.Straight,
           SourcePoint = new DiagramPoint() { X = 100, Y = 200 },
           TargetPoint = new DiagramPoint() { X = 300, Y = 200 },
           Segments = new DiagramObjectCollection<ConnectorSegment>()
           {
               //Create a new straight segment 
               new StraightSegment(){Point=new DiagramPoint(420,300)},
            }
        };
       connectors.Add(connector);
      }
     }

    Methods

    Clone()

    Creates a new ConnectorSegment that is a copy of the current segment.

    Declaration
    public override object Clone()
    Returns
    Type Description
    System.Object

    A new instance of ConnectorSegment that is a duplicate of the current segment.

    Overrides
    DiagramObject.Clone()

    Implements

    IDiagramObject
    System.ICloneable
    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved