RadDiagramConnection updates point collection on group selection

7 posts, 1 answers
  1. Michał
    Michał avatar
    6 posts
    Member since:
    Jul 2015

    Posted 23 Jul 2015 Link to this post

    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!
  2. Kiril Vandov
    Admin
    Kiril Vandov avatar
    324 posts

    Posted 27 Jul 2015 Link to this post

    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
  3. UI for WPF is Visual Studio 2017 Ready
  4. Michał
    Michał avatar
    6 posts
    Member since:
    Jul 2015

    Posted 27 Jul 2015 in reply to Kiril Vandov Link to this post

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

    1. Kiril Vandov said:
      - are you using Xaml defined diagram or you are using MVVM approach? 

      I'm using MVVM approach. 

    2. 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?


      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. Kiril Vandov said:
      - to which collection change you are subscribing  (Items, ConnectionPoints .. e.t.) and how? 

      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. Kiril Vandov said:
      - do you have custom diagram ? 

      No.

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

  5. Kiril Vandov
    Admin
    Kiril Vandov avatar
    324 posts

    Posted 29 Jul 2015 Link to this post

    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
  6. Michał
    Michał avatar
    6 posts
    Member since:
    Jul 2015

    Posted 05 Aug 2015 Link to this post

    Hello,

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

    1. 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.
        
      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ł

     

  7. Answer
    Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 10 Aug 2015 Link to this post

    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
  8. Michał
    Michał avatar
    6 posts
    Member since:
    Jul 2015

    Posted 14 Aug 2015 in reply to Petar Mladenov Link to this post

    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ł

Back to Top
UI for WPF is Visual Studio 2017 Ready