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

Is there an RadDiagramShape.IsSelectable property

5 Answers 157 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
Alexander
Top achievements
Rank 1
Alexander asked on 02 Sep 2014, 04:03 PM
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

5 Answers, 1 is accepted

Sort by
0
Alexander
Top achievements
Rank 1
answered on 03 Sep 2014, 08:59 AM
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
0
Martin Ivanov
Telerik team
answered on 03 Sep 2014, 10:42 AM
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.
 
0
Alexander
Top achievements
Rank 1
answered on 04 Sep 2014, 02:57 PM
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
0
Accepted
Martin Ivanov
Telerik team
answered on 08 Sep 2014, 02:57 PM
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.
 
0
Alexander
Top achievements
Rank 1
answered on 08 Sep 2014, 03:23 PM
Thank you!
I was missing the "Allow..." properties, as these have another naming convention.

Alex
Tags
Diagram
Asked by
Alexander
Top achievements
Rank 1
Answers by
Alexander
Top achievements
Rank 1
Martin Ivanov
Telerik team
Share this question
or