Retain shape grouping after Layout

8 posts, 0 answers
  1. Hans-Henrik
    Hans-Henrik avatar
    5 posts
    Member since:
    Feb 2015

    Posted 19 Mar 2015 Link to this post

    Hi,

    I have a diagram where i group some shapes together. At some point, I want the user to be able to do a Layout of what they have drawn, but I want grouped shapes to stay together how they are grouped.

    The default Layout method rearranges shapes within a group, and in my case, that ens up being really messy. How can I implement a Layout method that honours the grouped shapes as one item?

    /HH
  2. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 19 Mar 2015 Link to this post

    Hello Hans-Henrick,

    You can try the following trick:
    - place the different groups of shapes in DiagramContainerShapes
    - perform the Layout
    - on DiagramLayoutComplete event, remove the previously created containers.

    Please let us know if this helps you move forward.


    Regards,
    Petar Mladenov
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for WPF is Visual Studio 2017 Ready
  4. Hans-Henrik
    Hans-Henrik avatar
    5 posts
    Member since:
    Feb 2015

    Posted 19 Mar 2015 in reply to Petar Mladenov Link to this post

    Any example code (C#) I can look at at any chance?
  5. Hans-Henrik
    Hans-Henrik avatar
    5 posts
    Member since:
    Feb 2015

    Posted 20 Mar 2015 in reply to Petar Mladenov Link to this post

    Hhm.. other options? This actually creates issues, as the project I have inherited, has a bunch of specialized (overrides) code, expecting certain types of shapes to be added.. unable to add a DiagramContainerShape right away.. to chenge all that would keep me busy for quite some time.

    Could routing be a solution?
  6. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 20 Mar 2015 Link to this post

    Hi Hans,

    You can check the attached project in which the suggested approach is implemented in button click handler. In the captured video you can see how I group shapes 1-2-3 and then the layout keeps this configuration. What can be improved in this solution is a specific style for the container shape - so that the Layout will not take into account the hight of the container's Header - this way the group 1-2-3 will be vertically aligned with shapes 4 and 5.

    Another solution could be to preserve some shapes' positions (relative or absolute) in a Dictionary, Layout and in DiagramLayoutComplete event - re-create the relative positions of the shapes from a particular group. However, this seems more complicated task and I would suggest using the ContainerShapes' approach - it gives a built-in groping which separates a group of shapes from the entire diagram Layout.

    Regards,
    Petar Mladenov
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  7. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 07 May 2015 Link to this post

    Hello Hans,

    We want to suggest another solution you might consider. The TreeLayoutSettings and SugiyamaSettings classes provide IgnoreInvisible property. This means you can set some shapes collapsed, use this property set to True and on DiagramLayoutComplete return the collapsed shapes to Visible.

    Regards,
    Petar Mladenov
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
  8. Hans-Henrik
    Hans-Henrik avatar
    5 posts
    Member since:
    Feb 2015

    Posted 18 May 2015 in reply to Petar Mladenov Link to this post

    OK. I have not gotten to try this out yet. But, the functionality I am after, would be that I have a shape, and grouped with this shape, is a number of text objects. Now, I want to arrange the shapes, but I want the texts to keep with the shapes....
  9. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 20 May 2015 Link to this post

    Hi Hans,

    How are these text objects represented in RadDiagram ? Aren't they RadDiagramTextShapes ? If not, have you considered so ?


    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
Back to Top
UI for WPF is Visual Studio 2017 Ready