BoldSignEasily embed eSignatures in your .NET applications. Free sandbox with native SDK available.
//Custom SfDiagram
public class customdiagram : SfDiagram
{
protected override void SetTool(SetToolArgs args)
{
if (args.Source is IPort)
{
//Specifies the Action to perform
args.Action = ActiveTool.Draw;
}
else
{
base.SetTool(args);
}
}
}
//Here you can draw if you click and drag a port. |
S.No |
Query |
Response |
1. |
I have tried the way you have mentioned and changed default tool to 'draw'. However, I am still not able to draw connection between the ports.
|
Constraints should have connectable to enable connection.
Code Example:
Me.Constraints = NodeConstraints.Selectable Or NodeConstraints.Draggable Or NodeConstraints.Connectable
'Here Me represents the class AutxComponent that is derived from NodeViewModel
Documentation Link: https://help.syncfusion.com/wpf/sfdiagram/constraints#node-constraints
|
2. |
is there a way to make ports visible always ? |
By default, PortVisibility is set as MouseOver the Node. We can change this by assign the PortVisibility as Visible. We have attached the code example below.
Code Example:
Me.PortVisibility = PortVisibility.Visible
'Here Me represents the class AutxComponent that is derived from NodeViewModel
|
.TargetNodeID = _component2.ID, .SourcePortID = _port1.ID, .TargetPortID = _port2.ID})
S.No |
Queries |
Response |
1. |
When I am trying to connect ports programatically like below, it isn't reflecting on the design surface. However, when I set SourcePort and TargetPort directly I see a proper connection. Any idea why I am unable to connect ports using source and target Port IDs ?
_activity.Connections.Add(New AutxConnection With {.SourceNodeID = _component1.ID, |
ID’s will not be generated on its own. We have to specify a values explicitly. We have modified the sample based on your requirement. |
2. |
Is there a way to restrict creating connections only between ports and not between the nodes ? |
We have to disable the Connectable Constraints from Node and enable Connectable Constraints only for the Port. We have modified the sample based on your requirement.
Code Example :
'Here Me represents the class AutxComponent that is derived from NodeViewModel
Me.Constraints = Not NodeConstraints.Connectable
'Here Me represents the class AutxPort that Is derived from NodePortViewModel
Me.Constraints = PortConstraints.Connectable
|
|
Before resize |
After Resize |
Absolute position
UpdateInportPosition(inport);
UpdateOutportPosition(outport); |
|
|
Relative Position
UpdateInportPositionrelative(inport, node);
UpdateOutportPositionrelative(outport, node); |
|
|
Port is not a part of diagram layer, it does not participate in printing, exporting, zooming. Port is just an indication of connecting point, where user can interactively connect. If you want a visual object added in place of port, please use annotation which is a part of diagram and it will be included in printing, exporting and zooming. Port and annotation takes similar alignment properties, please refer documentation.
Link: https://help.syncfusion.com/wpf/sfdiagram/annotation
We have provided the sample to differentiate the port and annotation with two nodes and provided the screenshot. Please refer to them as below.
Screenshot:
Sample Link: http://www.syncfusion.com/downloads/support/forum/130254/ze/Basic_Sample_for_requirement868684643
Regards,
KarkuvelRajan.S
Element |
No scale(100%) |
More than 100% |
Port |
|
|
Annotation |
|
|
Port and Annotation |
|