We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Detecting when a link has been added or removed

Thread ID:

Created:

Updated:

Platform:

Replies:

97785 Jan 7,2011 05:11 PM Jan 19,2011 09:35 AM Windows Forms 3
loading
Tags: Diagram
Christine Cipriani
Asked On January 7, 2011 05:11 PM

We are currently upgrading from 4.1.0.62 to 8.4.0.10. We are working our way through all of the many implementation changes. Can you please provide an updated code snippet showing how to detect when a link has been added or removed? The following example from your documentation still uses the older, obsolete implementation: http://help.syncfusion.com/ug_83/User%20Interface/Windows%20Forms/Diagram/default.htm?turl=Documents%2Fhowtodetectwhetheranewlinkhasbeenaddedremovedfromadiagram.htm

Thanks in advance for your help.

Chris


Bala Murugan A.S [Syncfusion]
Replied On January 10, 2011 12:48 AM

Hi ChrisC,

Thanks for using Syncfusion Products.

How To Detect Whether a New Link Has Been Added / Removed From a Diagram:

You can use the Diagram.Model.EventSink.NodeCollectionChanged and Diagram.Model.EventSink.ConnectionsChanged events to detect whether a new link has been added / removed from a diagram and detect whether the link has been added or removed from symbols.

The following code snippet illustrates how to detect a new link that has been added to the diagram, and the symbols connected by the new link.

[C#]

void EventSink_NodeCollectionChanged(CollectionExEventArgs evtArgs)
{
Node n = evtArgs.Element as Node;
if (n is Syncfusion.Windows.Forms.Diagram.ConnectorBase || n is Syncfusion.Windows.Forms.Diagram.LineBase)
{
Trace.WriteLine("New link added to the diagram");
}

}
void EventSink_ConnectionsChanged(CollectionExEventArgs evtArgs)
{
if (evtArgs.ChangeType == CollectionExChangeType.Insert)
{
MessageBox.Show("Connnection Added");

}
if (evtArgs.ChangeType == CollectionExChangeType.Remove)
{
MessageBox.Show("Connection Removed");
}
}

[VB]

Private Sub EventSink_NodeCollectionChanged(ByVal evtArgs As CollectionExEventArgs)
Dim n As Node = TryCast(evtArgs.Element, Node)
If TypeOf n Is Syncfusion.Windows.Forms.Diagram.ConnectorBase OrElse TypeOf n Is Syncfusion.Windows.Forms.Diagram.LineBase Then
Trace.WriteLine("New link added to the diagram")
End If
End Sub

Private Sub EventSink_ConnectionsChanged(ByVal evtArgs As CollectionExEventArgs)
If evtArgs.ChangeType = CollectionExChangeType.Insert Then
MessageBox.Show("Connnection Added")
End If
If evtArgs.ChangeType = CollectionExChangeType.Remove Then
MessageBox.Show("Connection Removed")
End If
End Sub


We have created a simple sample to demonstrate this and the same can be downloaded from the below link.
AddRemoveLink-1717800105.zip

Please let me know if you have any concerns.

Regards,
Bala Murugan A.S



Christine Cipriani
Replied On January 12, 2011 04:37 PM

I have a few more questions as we continue upgrading from 4.1.0.62 to the latest version:

1) The Port class used to have a Visible property so you could show/hide individual ports. That property does not exist in the ConnectionPoint class. Is there a way to do this?

2) We also used the SetPropertyValue to add additional properties to the property container. How can this be done with the latest version?

Thanks in advance for your help.

Chris


Bala Murugan A.S [Syncfusion]
Replied On January 19, 2011 09:35 AM

Hi Christine Cipriani,

Thanks for the update,

Sorry for the delay in getting back to you.

1) The Port class used to have a Visible property so you could show/hide individual ports. That property does not exist in the ConnectionPoint class. Is there a way to do this?

Currently the feature is not available in diagram for 'Show/Hide Individual Ports'. we have consider this as a feature request. Please create an DT incident for your query so that we can update with the fix for this feature.

You can create the DT incident from the following link.
http://www.syncfusion.com/account/dashboard

In the interests of maintaining confidentiality, we have a policy of not sharing patches or otherwise proprietary customer specific information in the public Forum.


2) We also used the SetPropertyValue to add additional properties to the property container. How can this be done with the latest version?

Sorry for the inconvenience caused. In the latest version we don't have a property called SetProprtyValue() for creating custom property. So we suggest you to create custom property for the symbol.Please refer the below code snippet to achieve this,

[C#]

[Serializable()]
[TypeConverter(typeof(GLEConverter))]
public partial class MySymbol : Group
{

public string myProperty = @"MyChildControlProperty";
public string m_symbolDescription = @"My UserControl";

public MySymbol()
{
Syncfusion.Windows.Forms.Diagram.Rectangle rect = new Syncfusion.Windows.Forms.Diagram.Rectangle(100, 100, 100, 100);
rect.FillStyle.Color = Color.BlueViolet;
this.AppendChild(rect);
}

public MySymbol(MySymbol src)
: base(src)
{
}

//Clones this instance.
public override object Clone()
{
return new MySymbol(this);
}


#region Symbol properties for property editor

[
Browsable(true),
Category("MyProperty"),
Description("Custom Property"),
DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)
]
public string MyProperty
{
get { return myProperty; }
set
{
myProperty = value;
}
}
[
Browsable(true),
Category("MyProperty"),
Description("My Property for Symbol"),
DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)
]
public string Description
{
get
{
return this.m_symbolDescription;
}
set
{
this.m_symbolDescription = value;
}
}

#endregion

private void button1_Click(object sender, EventArgs e)
{

}
}
public class GLEConverter : TypeConverter
{
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
{
return base.ConvertTo(context, culture, value, destinationType);
}

public override bool GetPropertiesSupported(ITypeDescriptorContext context)
{
return true;
}

public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
{
Attribute[] attrs = new Attribute[]
{
new BrowsableAttribute(true)
};

PropertyDescriptor[] props = null;
Type type = value.GetType();
switch (type.Name)
{
case "MySymbol":
props = new PropertyDescriptor[3];
props[0] = TypeDescriptor.CreateProperty(typeof(MySymbol), "MyProperty", typeof(string), attrs);
props[1] = TypeDescriptor.CreateProperty(typeof(MySymbol), "Description", typeof(string), attrs);
props[2] = TypeDescriptor.CreateProperty(typeof(MySymbol), "Size", typeof(SizeF), attrs);
break;

default:
break;

}
return new PropertyDescriptorCollection(props);
}
}

we have created a simple sample to demonstrate this and the same can be downloaded from the below link,

http://www.syncfusion.com/uploads/redirect.aspx?team=support&file=SymbolProperty708434951.zip

Please let me know if you have any concerns.

Regards,
Bala Murugan A.S




CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;