Pan without Ctrl being pressed and deselect all items on mouse click

4 posts, 0 answers
  1. Ciro
    Ciro avatar
    11 posts
    Member since:
    Nov 2013

    Posted 29 Apr 2015 Link to this post

    Hi,

     

    I want to use Pan without press Ctrl. I have reach this result using the advice from the following thread

     http://www.telerik.com/forums/pan-without-ctrl-being-pressed

    Now, I want to improve this functionality and when I select one or more shapes and/or connections I want  to deselect them when I click out of the select area. Is there a way to reach this result?

    Thanks 

     Ciro

  2. Martin
    Admin
    Martin avatar
    1101 posts

    Posted 30 Apr 2015 Link to this post

    Hi Ciro,

    When the default tool (PointerTool) is set as ActiveTool the desired functionality is provided out of the box. However, when the ActiveTool is the PanTool this behavior is not presented and you will need to implement it with custom code. Basically, you can subscribe for the MouseLeftButtonDown event of RadDiagram and inside its handler, if there is not item under the mouse, clear the selection. Here is an example in code:
    this.diagram.ActiveTool = Telerik.Windows.Diagrams.Core.MouseTool.PanTool;
    this.diagram.AddHandler(RadDiagram.MouseLeftButtonDownEvent, new MouseButtonEventHandler(diagram_MouseLeftButtonDown), true);
     
    .....
     
    private void diagram_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
    {
        var hitTestService = this.diagram.ServiceLocator.GetService<IHitTestService>() as HitTestService;
        if (this.diagram.SelectedItem != null && hitTestService.ItemUnderMouse == null)
        {
            var selectionService = this.diagram.ServiceLocator.GetService<ISelectionService<IDiagramItem>>() as SelectionService;
            selectionService.ClearSelection();
        }
    }

    Please let me know if this helps.

    Regards,
    Martin
    Telerik
     

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

     
  3. UI for WPF is Visual Studio 2017 Ready
  4. Ciro
    Ciro avatar
    11 posts
    Member since:
    Nov 2013

    Posted 30 Apr 2015 Link to this post

    OK, this solution work for me.

     

    I have another question about cursor on RadDiagram when I set ActiveTool = PanTool, in this case I want to use Arrow cursor for each operation.

    I have tried to set the Cursor property of the RadDiagram but when I click with the mouse on the RadDiagram area my cursor is overwritten and I see the default cursor for PanTool.

    However, in general I would like to use only the Arrow cursor.

     

    How can I solve this?

     

    Thank you

    Ciro

  5. Martin
    Admin
    Martin avatar
    1101 posts

    Posted 30 Apr 2015 Link to this post

    Hello Ciro,

    The diagram control uses a static DiagramCursors class to store and get its cursors. In order to replace the pan tool's cursor with the arrow cursor you can change the value of the DiagramCursors.Panning property before the InitializeComponent() call. 
    public MainWindow()
    {
        DiagramCursors.Panning = DiagramCursors.Pointer;
        InitializeComponent();
    }

    I hope this helps.

    Regards,
    Martin
    Telerik
     

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

     
Back to Top