This is a migrated thread and some comments may be shown as answers.

How to create a custom connection class?

2 Answers 64 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
Ruslan
Top achievements
Rank 1
Ruslan asked on 16 Apr 2012, 06:53 PM
I need to replace the RadDiagramConnection to the inherits class of RadDiagramConnection.

2 Answers, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 18 Apr 2012, 06:42 AM
Hello Ruslan,

 We are not sure we understand you correctly. Could you please elaborate more on your desired scenario ? Why do you need to inherit the RadDiagramConnection ? What do you need to customize exactly ?

Greetings,
Petar Mladenov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Hans
Top achievements
Rank 1
answered on 14 Mar 2014, 11:39 AM
Hello,

Perhaps I can ellaborate on why one would override the RadDiagramConnection. I noticed that there is no information explaining how to do this, neither in the Telerik documentation or in the forums.

First of all, my reason for overriding the RadDiagramConnection is because I need additional properties on the connection. We have developed a way to execute diagrams containing business logic, and the connection needs properties as IsPaused and IsCanceled to indicate if the diagram can continue to the next shape or not.

If you wish to use a different connection class, you must also inherit from the RadDiagram. The RadDiagram contains a number of methods that will allow you to provide your custom connection class when the diagram mechanism requires a connection:

public abstract class ExecutableDiagramBase : RadDiagram, IExecutableDiagram
{
    #region Constructors & Destructors
    protected ExecutableDiagramBase()
    {
    #region Connection Management
    protected override IConnection GetConnectionContainerForItemOverride(object item)
    {
        return new ExecutableConnection();
    }
 
    protected override void PrepareConnectionContainerForItemOverride(FrameworkElement container, object item)
    {
        base.PrepareConnectionContainerForItemOverride(container, item);
    }
 
    protected override bool IsItemItsOwnConnectionContainerOverride(object item)
    {
        return base.IsItemItsOwnConnectionContainerOverride(item);
    }
    #endregion
}

Please note that the ExecutableConnection class is a custom connection class, inheriting from RadDiagramConnection.

I hope this helps someone.

Kind regards,
Beijerinc
Tags
Diagram
Asked by
Ruslan
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
Hans
Top achievements
Rank 1
Share this question
or