I have a simple diagram and I want to distinguish between two types of connections. I thought to create two styles of the arrows.
Is there a component of striped arrow? or any other possibility to create something like this? - - - - - - ->
or something similar? any style of arrow? (but not differences in colors)
You can set the Link’s Pen.DashStyle and the Link’s ToArrow property.
Pen pen1 = new Pen(Color.Black);
pen1.DashStyle = DashStyle.Dot;
link1.Pen = pen1;
link1.ToArrow = true;
Thank you very much! It’s exactly what I need.
but there is a problem with it. When I do a check and change the style of one arrow all the arrows in the schema get the new style and I need different types of arrows for some types of nodes.
What should I do? Is it familiar problem? or only in my project? (If yes I will search the problem by myself but if not maybe someone have a solution.)
Can you post the link initialization code and also the code that changes the style of one arrow that isn’t working? Thanks.
Yes, of course. thanks!
I have a class "DeviceLink". This class inherits from "GoLabeledLink".
I try to change the style in this function:
(The function is activated in loop when I load the schema (for all the saved links) and when the user creates new link.)
private void AddLinkToSite(InterConnectionDS.TBL_INTERCONNECTIONRow connection, GoView view)
{
string fromDevName = _dsDeviceDS.TBL_NETWORK_ELEMENT.FindByNETWORK_ELEMENT_ID(connection.SOURCE_NODE_ID).NETWORK_ELEMENT_NAME;
string toDevName = _dsDeviceDS.TBL_NETWORK_ELEMENT.FindByNETWORK_ELEMENT_ID(connection.DESTINATION_NODE_ID).NETWORK_ELEMENT_NAME;
DeviceNode fromDev = (DeviceNode)view.Document.FindNode(fromDevName);
DeviceNode toDev = (DeviceNode)view.Document.FindNode(toDevName);
DeviceLink mtnlink2 = new DeviceLink();
if (toDev.DeviceType == EDeviceType.IR || toDev.DeviceType == EDeviceType.UP)
{
mtnlink2.Pen.DashStyle = DashStyle.Dash;
}
else
{
mtnlink2.Pen.DashStyle = DashStyle.Solid;
}
mtnlink2.FromPort = fromDev.FromPort;
mtnlink2.ToPort = toDev.ToPort;
view.Document.LinksLayer.Add(mtnlink2);
}
but it also happend when I use simple GoLabeledLink in the event:
private void goView1_LinkCreated(object sender, GoSelectionEventArgs e)
{
GoObject obj = e.GoObject;
GoLabeledLink link = obj as GoLabeledLink;
if(..............)
{
link.Pen.DashStyle = DashStyle.Dash;
}
else
{
link.Pen.DashStyle = DashStyle.Solid;
}
}
When a new link is created there is a check and if its DashStyle is changed all the existing links in the schema get the new style.
You can’t change Pen attributes for a pen already in use.
Create a "new" Pen and set link.Pen to that.