Drop Event of RadDiagram is not working

17 posts, 0 answers
  1. Ambit
    Ambit avatar
    13 posts
    Member since:
    Apr 2012

    Posted 04 May 2012 Link to this post

    Hi,
    I have implemented a demo code of Design Tool Box & created a drop event of Rad Diagram.
    So when I am dropping shapes from Toolbox, why this event is not fired?
    Is there any other event for dropping of shapes on Diagram?
  2. Francois Vanderseypen
    Francois Vanderseypen avatar
    46 posts
    Member since:
    Oct 2009

    Posted 04 May 2012 Link to this post


    If you look closely at and mimic the code from the samples you should be fine. On a more technical level, the RadDiagram control doesn't use the standard drag-drop mechanism but relies on the Telerik DragDropManager internally. Have a look at the docs of this control, it basically amounts to

    DragDropManager.AddDropHandler(YourRadDiagramControl, YourOnDropHandler);

    Are you trying to reuse the shapes toolbox or you want to implement a custom drop mechanism?

    Hope this helps, Fr.


  3. DevCraft banner
  4. Ambit
    Ambit avatar
    13 posts
    Member since:
    Apr 2012

    Posted 04 May 2012 Link to this post

    Thanks for Reply,
    DragDropManager works for drop event but I am not getting dropped shape in this event.

     DragDropManager.AddDropHandler(this.diagram, diagram_Drop);
     
     private void diagram_Drop(object sender, Telerik.Windows.DragDrop.DragEventArgs e)
     {      
     }

    I have to use dropped shape for creating connection with another shape.
    Someone has already discuss about Creating connection on drop on this forum
    http://www.telerik.com/community/forums/silverlight/diagram/drag-the-shape-create-connection-between-shapes.aspx
    Something like this, I am also trying.

    Thanks
  5. Francois Vanderseypen
    Francois Vanderseypen avatar
    46 posts
    Member since:
    Oct 2009

    Posted 04 May 2012 Link to this post

    Assuming your XAML looks somewhat like this:

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <Rectangle x:Name="rec" Fill="Orange" Width="50" Height="30" />
        <telerik:RadDiagram x:Name="diagram" Grid.Row="1"  />
    </Grid>

    (but any type of visual can be used to drop content onto the surface).
    You can access the data and the position on the surface as follows:

    public MainWindow()
    {
        InitializeComponent();
                 
        rec.SetValue(DragDropManager.AllowDragProperty, true);
        DragDropManager.AddDragInitializeHandler(this, this.OnDragInitialized);
        DragDropManager.AddDropHandler(this, OnDropItem);
        diagram.AllowDrop = true;
    }
     
    private void OnDragInitialized(object sender, DragInitializeEventArgs e)
    {
        var shape = new RadDiagramShape { Geometry = ShapeFactory.GetShapeGeometry(CommonShapeType.Star5Shape), Width = 50, Height = 50 };
        e.DragVisualOffset = new Point(e.RelativeStartPoint.X - 25, e.RelativeStartPoint.Y - 25);
        var dragDropInfo = shape;
        e.Data =  dragDropInfo;
        e.AllowedEffects=DragDropEffects.All;
        e.Handled = true;
    }
     
    private void OnDropItem(object sender, DragEventArgs e)
    {
        e.Handled = true;
        var dataObject = e.Data as DataObject;
        var formats = dataObject.GetFormats().ToList();
        if (formats.Contains(typeof(RadDiagramShape).FullName) )
        {
            var shape = new RadDiagramShape { Geometry = ShapeFactory.GetShapeGeometry(CommonShapeType.Star5Shape), Width = 50, Height = 50 };
            var p = e.GetPosition(diagram);
     
            diagram.AddShape(shape, position: diagram.GetTransformedPoint(p));
        }
    }

    The precise logic depends on the actual application you aim for and the functional behavior you are looking for, of course.

    Hope this helps, Fr.
  6. Shrikant
    Shrikant avatar
    38 posts
    Member since:
    Jul 2011

    Posted 04 May 2012 Link to this post

    Hi,
    I am getting error on OnDropItem event
    at line
    var formats = dataObject.GetFormats().ToList(); --> (Object reference not set to an instance of an object.)

    And for your information I have DesignToolBox Sample code on my project.
    & I am dropping shapes from ToolBox.

    Please let me know If I am doing something wrong.

    Thanks
  7. Ambit
    Ambit avatar
    13 posts
    Member since:
    Apr 2012

    Posted 04 May 2012 Link to this post

    Hi Francois,
    Thanks for Reply here,
    I am also having the same problem with your suggested code.
    I have used Toolbox for dropping Shapes on Diagram.


    Thanks Again.
  8. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 04 May 2012 Link to this post

    Hello Ambit and Shrikant,

     You can find attached the code sample from Francois. Please let us know if you need further assistance.

    Regards,
    Petar Mladenov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  9. Ambit
    Ambit avatar
    13 posts
    Member since:
    Apr 2012

    Posted 07 May 2012 Link to this post

    Hi Petar,
    Your Sample of WPF is working but when I move this code to Silverlight ,I am still facing the same error.
    Please use ToolBox feature with sample, I want to know how this drop event will work with ToolBox.

    Thanks
  10. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 10 May 2012 Link to this post

    Hello Ambit,

     I am attaching the full DesignToolBox Demo code.

    Kind regards,
    Petar Mladenov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  11. Yogendra
    Yogendra avatar
    17 posts
    Member since:
    Aug 2013

    Posted 06 Sep 2013 Link to this post

    Hi Petar,

    Can you suggest me , How can fired Drag and drop event of diagram in silverlight?

    Thanks

    Regrads 
    Yogendra
  12. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 10 Sep 2013 Link to this post

    Hello Yogendra,

    You can use the OnDrop of the Diagram or DragDropmanager.DragInitialize. However, if this question is related to ToolBox issues, you can check DrawingDemo which demonstrates the Events DiagramSerializationService.ItemSerializing and Diagram.ShapeDeserialized which fires when shape is dragged and then when it is dropped in diagram. You can use these events to save custom properties, like the Geometry property in the Drawing sample.

    Regards,
    Petar Mladenov
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  13. Ajay
    Ajay avatar
    9 posts
    Member since:
    Feb 2012

    Posted 07 Jan 2014 Link to this post

    Hi ,
    I am using Rad diagram but while using diagrams while selecting or deselecting a diagram sometimes selection hangs on one only.

    Please let me me know how I can overcome this.

    Regards
    Ajay Negi
  14. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 10 Jan 2014 Link to this post

    Hi Ajay,

    Could you please elaborate more on your particular scenario ? What type of selection do you perform - programmatically , with mouse click , or with mouse rectangle selection ? What is the number of shapes / connections that you select ? Is it possible for you to send us a captured video of this issue which can help us better investigate it ? This will be highly appreciated and we will be better able to advice you.
    Thank you in advance for your cooperation.

    Regards,
    Petar Mladenov
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  15. Ajay
    Ajay avatar
    9 posts
    Member since:
    Feb 2012

    Posted 10 Jan 2014 Link to this post

      With the selection of rectangle click some time the selection sticks on one and we are not able select any other. PFA screenshot
  16. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 15 Jan 2014 Link to this post

    Hello Ajay,

    We tried to reproduce such issue on our side but we did not succeed. That is why we want to ask you if you are able to reproduce it in a sample project, for example in our Diagrams First Look Demo (SL or WPF).  We want to investigate this further because performance issues are usually of high importance 
    but we will definitely need a starting point to look at. On the other hand, can you please also confirm that you are using our latest Release - Q3 2013 or Q3 2013 SP ?

    Regards,
    Petar Mladenov
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  17. Ajay
    Ajay avatar
    9 posts
    Member since:
    Feb 2012

    Posted 24 Mar 2014 Link to this post

     
     var gh = diagram.Shapes;
    foreach (RadDiagramShape row in gh)
                    {  row.ShapeDoubleClick+= ShapeDoubleClicked}

    how to do this.
    I want to double click each shape of RadDiagramShape through c#
    to call function
    diagram_ShapeDoubleClicked(object sender, ShapeRoutedEventArgs e)


  18. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 25 Mar 2014 Link to this post

    Hi Ajay,

    Could you please elaborate a bit more on your scenario ? This way we would be better able to advice you.
    Basically, the RadDiagram.ShapeDoubleClicked event which will fire on every double click performed on RadDiagramShapes.

    Regards,
    Petar Mladenov
    Telerik
     

    Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.

     
Back to Top
DevCraft banner