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

RadDiagramConnection updates point collection on group selection

6 Answers 180 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
Michał
Top achievements
Rank 1
Michał asked on 23 Jul 2015, 09:43 AM
Hello,

I have a problem with ConnectionPoints collection in RadDiagramConnection.
As I've mentioned in thread title, RadDiagramConnection updates geometry on group selection (it only appears when two or more RadDiagramConnetion has been selected). As a result of geometry update, connection points on RadDiagramConnection are re-added (reset event and then add one by one).
I did not identify that problem when only one RadDiagramConnection is selected.

It lead's to problem in my scenario because I'm subscribing CollectionChanged event ​on that collection, so I got false info about points change (but it doesn't).
Could you please tell me how can I fix it? How can disable that geometry update on group RadDiagramConnection select?

Thanks in advance!

6 Answers, 1 is accepted

Sort by
0
Kiril Vandov
Telerik team
answered on 27 Jul 2015, 08:54 AM
Hello Michał,

I am not sure that I understand your scenario entirely. That is why I would like to ask you for more information about your scenario:
- are you using Xaml defined diagram or you are using MVVM approach?
- if I understand you correctly you are defining shapes/connection and the you are adding some ConnectionPoints. And the steps after that are not clear: do you select the RadDiagramConnection and the reset is made or you first Group the shapes and the connection and then making the selection?
- to which collection change you are subscribing  (Items, ConnectionPoints .. e.t.) and how?
- do you have custom diagram ?

Also if you could provide us with a sample project reproducing the issue will help us better understand and provide you with best possible solution for you scenario.

Looking forward to hearing from you.

Kind regards,
Kiril Vandov
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
Michał
Top achievements
Rank 1
answered on 27 Jul 2015, 10:28 AM

Hi,
Thanks for your reply.
Maybe you're right, I didn't declare my scenario correctly. 

  1. [quote]Kiril Vandov said:
    - are you using Xaml defined diagram or you are using MVVM approach? 
    [/quote]
    I'm using MVVM approach. 

  2. [quote]Kiril Vandov said:
    - if I understand you correctly you are defining shapes/connection and the you are adding some ConnectionPoints. And the steps after that are not clear: do you select the RadDiagramConnection and the reset is made or you first Group the shapes and the connection and then making the selection?
    [/quote]

    2.1 In my scenario i would like to have ability to manipulate connection points (adding, removing, moving), because I'm handling serialization/deserialization of models by myself (e.g. link models with points). I'm using build in feature to add point (ctrl+left mouse click).

    2.2. To select links i'm using mouse on diagram, steps:
    - select only one link -> no CollectionPoints collectionchanged event fired [
    behavior is OK, file: single link selection.PNG]
    - select two or more links -> CollectionPoints collectionchanged event is fired (reset, then add points one by one) [behavior causes the problem -> got "false" info about change, file: multiple links selection.PNG]

    2.3 No selection is made in "code behind" or in ViewModel.

  3. [quote]Kiril Vandov said:
    - to which collection change you are subscribing  (Items, ConnectionPoints .. e.t.) and how? 
    [/quote]
    I'm subscribing RadDiagramConnection.ConnectionPoints with solution based on ones Fabrizio mentioned (RadDiagramConnectionBehavior class) in http://www.telerik.com/forums/how-to-bind-a-collection-connection-points-in-a-connection

  4. [quote]Kiril Vandov said:
    - do you have custom diagram ? 
    [/quote]
    No.

Also, if you need more info, I could provide sample project next week.

0
Kiril Vandov
Telerik team
answered on 29 Jul 2015, 01:31 PM
Hello Michał,

Thank you for the detailed information.
I have tried to reproduce the issue with the updated information but with no success. However I have tested my solution with our official Q2 2015 release and our latest binaries. Could you please let us know the version of the binaries that you are using to try and reproduce it with them.

Looking forward to hearing from you.

Kind regards,
Kiril Vandov
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
Michał
Top achievements
Rank 1
answered on 05 Aug 2015, 04:23 PM

Hello,

First of all, sorry for that long wait for my response.

  1. [quote]I have tried to reproduce the issue with the updated information but with no success. However I have tested my solution with our official Q2 2015 release and our latest binaries. Could you please let us know the version of the binaries that you are using to try and reproduce it with tchem.[/quote]  
    I'm using same version 2015 Q2.
  2. I do not have enough time right now to reproduce problem with sample project, but I've digged deeper into a problem and 2015 Q2 source code and found out that:
    - UpdateGeometry is called by RefreshIsSelected, RefreshIsSelected is called by UpdateSelectedItemsProperty etc ... (detailed call stack visualization by code map, file: callstack - code map.png)
    - main problem may be in: Telerik.Windows.Controls.RadDiagram class in UpdateSelectedItemsProperty method
    It's in file:
    Telerik\2015.2\source\Diagrams\Diagrams\RadDiagram.IGraphInternal.cs
    fragment (lines 726 - 730):
    this.SelectionService.SelectedItems.OfType<RadDiagramItem>().ForEach(i =>    
    {        
      i.RefreshIsSelectedInGroup();        
      i.UpdateVisualStates();    
    });

     especially fragment i.RefreshIsSelectedInGroup(); which causes update if IsSelectedInGroup state occured. Update couses this.UpdateGeometryOverride() and so on... to lines 1121 and 1222 - RadDiagramConnection:

this.ConnectionPoints.Clear();
route.Points.ForEach(point => this.ConnectionPoints.Add(point));

 

Two points I should have cleared earlier:

  • using same AStarRouter with wall optimization for all routers (Router, FreeRouter, ReflexiveRouter)
  • My diagram constans
    DiagramConstants.ConnectorActivationRadius = 15;
    DiagramConstants.ConnectorHitTestRadius = 10;
    DiagramConstants.RoutingGridSize = 11;
    DiagramConstants.RouterInflationValue = 11;
    DiagramConstants.ContainerMargin = 11;
    DiagramConstants.MaximumZoom = 5;
    DiagramConstants.MinimumZoom = 0.1;
  • using RadDiagramNavigationPane
  • My Diargam look like this // Bindings to view models and style selectors are removed

<telerik:RadDiagram x:Name="Diagram"
                    IsRotationEnabled="False"
                    IsInformationAdornerVisible="False"
                    primitives:BackgroundGrid.CellSize="23,23"
                    primitives:BackgroundPageGrid.IsGridVisible="False"
                    SnapX="23"
                    SnapY="23"
                    RouteConnections="True"
                    ConnectionBridge="Bow"
                    ScrollViewer.HorizontalScrollBarVisibility="Visible"
                    ScrollViewer.VerticalScrollBarVisibility="Visible"
                    />

  • My RadDiagramConnection style have and seter for connection binding as I've mentioned previously
    <Setter Property="IsConnectorsManipulationEnabled" Value="True" />

Best regards,
Michał

 

0
Accepted
Petar Mladenov
Telerik team
answered on 10 Aug 2015, 12:02 PM
Hi Michał,

Thank you for the additional information.

You can try the following code which should suppress the updating of connection before selection. Than it will return the normal behavior after selection is performed.

this.diagram.PreviewSelectionChanged += diagram_PreviewSelectionChanged;
           this.diagram.SelectionChanged += diagram_SelectionChanged;
       }
 
       void diagram_SelectionChanged(object sender, SelectionChangedEventArgs e)
       {
           this.diagram.Connections.ForEach(x => RadDiagramConnection.SetIsAutoUpdateSuppressed(x as RadDiagramConnection, false));          
       }
 
       void diagram_PreviewSelectionChanged(object sender, SelectionChangedEventArgs e)
       {
           this.diagram.Connections.ForEach(x => RadDiagramConnection.SetIsAutoUpdateSuppressed(x as RadDiagramConnection, true));
       }



Regards,
Petar Mladenov
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
Michał
Top achievements
Rank 1
answered on 14 Aug 2015, 07:33 AM

Hello,
Thank you for your reply.

 

​I've managed to implement your sample and it works great. 

My problem is solved. Thank you again.

 

Best regards,
Michał

Tags
Diagram
Asked by
Michał
Top achievements
Rank 1
Answers by
Kiril Vandov
Telerik team
Michał
Top achievements
Rank 1
Petar Mladenov
Telerik team
Share this question
or