Is there an RadDiagramShape.IsSelectable property

6 posts, 1 answers
  1. Alexander
    Alexander avatar
    77 posts
    Member since:
    Apr 2013

    Posted 02 Sep 2014 Link to this post

    Hello,
    I want to extend the diagram functionality to have a Template, containing a set of write-protected shapes which can be inserted into multiple diagrams.

    Is there a way to separate the template shapes (which should be not editable) from the user-added shapes (which are editable)?

    Alex
  2. Alexander
    Alexander avatar
    77 posts
    Member since:
    Apr 2013

    Posted 03 Sep 2014 in reply to Alexander Link to this post

    The fact that I can select items that are marked as not editable is not so important. Indeed, this way I can create connectors from the write-protected items. However, my main problem now is: even if I set IsEditable and the other corresponding properties to false, some sorts of manipulations are still possible.

    IsEditable = false;
    IsDraggingEnabled = false;
    IsResizingEnabled = false;
    IsRotationEnabled = false;
    IsManipulationAdornerVisible = false;

    For most manipulation types, I found a workaround:
    - allow to select only a single template shape, removing all others in the SelectionChanged event
    - binding the SettingsPane visibility to SelectedItem.IsEnabled
    - intercept delete key and ctrl-x when template shape is selected
    - remove all template shapes before serialization, readd them after serializing

    However, I'm still wondering if there would be a more convenient way...

    Alex
  3. UI for WPF is Visual Studio 2017 Ready
  4. Martin
    Admin
    Martin avatar
    1101 posts

    Posted 03 Sep 2014 Link to this post

    Hi Alex,

    RadDiagramShape doesn't expose IsSelectable property but you can cancel the selection in the diagram's PreviewSelectionChanged event handler.

    private void diagram_PreviewSelectionChanged(object sender, SelectionChangedEventArgs e)
    {
        if(the selection of the potentially selected shape is not allowed)
        {
            e.Handled = true;
        }
    }

    As for the allowed manipulations, can you please tell us what manipulations are still enabled after setting the listed properties (from your last reply)? Also, it would be helpful if you can provide us with an isolated project with simplified implementation of your scenario. This way we can think of an approach that you can use to disable them. 

    Thank you for any information you can provide.

    Regards,
    Martin
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
  5. Alexander
    Alexander avatar
    77 posts
    Member since:
    Apr 2013

    Posted 04 Sep 2014 in reply to Martin Link to this post

    Thank you for your answer.
    At the moment, I handle the SelectionChanged event and update the SelectedItems collection accordingly. This also seems to work, but anyway I will have a look at the PreviewSelectionChanged (it is more consequent).

    In the example, there is nothing special:

    <Window x:Class="RadDiagramTest.MainWindow"
            xmlns:primitives="clr-namespace:Telerik.Windows.Controls.Diagrams.Primitives;assembly=Telerik.Windows.Controls.Diagrams"
            Title="MainWindow" Height="350" Width="525">
     
        <telerik:RadDiagram x:Name="Diagram">
            <telerik:RadDiagramShape Width="100" Height="100" Background="Green"/>
     
            <telerik:RadDiagramShape X="200" Y="200" Width="100" Height="100" Background="Red"
                                     IsEditable="False" IsDraggingEnabled="False"
                                     IsResizingEnabled="False" IsRotationEnabled="False"
                                     IsManipulationAdornerVisible="False"/>
     
            <primitives:ItemInformationAdorner.AdditionalContent>
                <telerik:SettingsPane Diagram="{Binding ElementName=Diagram}"/>
            </primitives:ItemInformationAdorner.AdditionalContent>
        </telerik:RadDiagram>
    </Window>

    One shape is editable, the other is not. However, I can open the SettingsPane for both shapes and edit them. And if pressing the delete button or Ctrl+X, the write-protected shape is removed from the diagram.

    Alex
  6. Answer
    Martin
    Admin
    Martin avatar
    1101 posts

    Posted 08 Sep 2014 Link to this post

    Hi Alex,

    Thank you for the information.

    You can cancel opening of the settings pane for a specific shape if you subscribe for the RadDiagram's PreviewAdditionalContentActivated event. This event is fired when an additional content of the diagram (like the settings pane) is opening. Then inside its handler you can check if the shape is not editable, handle the event.

    private void diagram_PreviewAdditionalContentActivated(object sender, AdditionalContentActivatedEventArgs e)
    {
        var shape = e.ContextItems.First() as RadDiagramShape;
        if (shape != null && !shape.IsEditable)
        {
            e.Handled = true;
        }
    }

    As for disabling the cut command you can set the AllowPaste property of the shape.

    <telerik:RadDiagramShape AllowCut="False" />

    I hope this additional information will help you further with your implementation.

    Regards,
    Martin
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
  7. Alexander
    Alexander avatar
    77 posts
    Member since:
    Apr 2013

    Posted 08 Sep 2014 in reply to Martin Link to this post

    Thank you!
    I was missing the "Allow..." properties, as these have another naming convention.

    Alex
Back to Top
UI for WPF is Visual Studio 2017 Ready