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

Using connection tool to draw custom connection

3 Answers 157 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
Paolo
Top achievements
Rank 1
Paolo asked on 17 Sep 2015, 02:00 PM

Hi,

I implemented some custom connections, deriving them from RadDiagramConnection. My connections have their own properties and visual aspect (defined using styles). I'd like to use the Telerik connection tool to draw my custom connection: how can i set the custom connection type to the connection tool?

Thank you in advance

Paolo

3 Answers, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 18 Sep 2015, 02:20 PM
Hello Paolo,

In order to force the diagram to use a custom connection object you can override its GetConnectionContainerForItemOverride() method and return the custom connection. Here is an example for this.
public class CustomDiagram : RadDiagram
{
    protected override Telerik.Windows.Diagrams.Core.IConnection GetConnectionContainerForItemOverride(object item)
    {
        return new MyCustomConnection();
    }
}

Please give this approach a try and let me know if it works for you.

Regards,
Martin
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Paolo
Top achievements
Rank 1
answered on 21 Sep 2015, 01:16 PM

Thank you Martin,

the override works fine when drawing a connection after the tool activation by code:

 

var service = Diagram.ServiceLocator.GetService<IToolService>() as ToolService;
service.ActivateTool(ConnectionTool.ToolName);​

 

 If I start drawing from a shape connector, the connection tool steals the last drawn connection and the tool redraws the connection from the connector. Maybe I have to restore something else?

Regards

Paolo

0
Martin Ivanov
Telerik team
answered on 24 Sep 2015, 08:02 AM
Hi Paolo,

I wasn't able to reproduce anything unusual when using the approach from my last reply. This is why I attached a sample project demonstrating this approach. Can you please give it a try and let me know if I am missing something?

Regards,
Martin
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Diagram
Asked by
Paolo
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Paolo
Top achievements
Rank 1
Share this question
or