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

Drop Event of RadDiagram is not working

16 Answers 394 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
Ambit
Top achievements
Rank 1
Ambit asked on 04 May 2012, 06:15 AM
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?

16 Answers, 1 is accepted

Sort by
0
Francois Vanderseypen
Top achievements
Rank 2
answered on 04 May 2012, 07:25 AM

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.


0
Ambit
Top achievements
Rank 1
answered on 04 May 2012, 07:48 AM
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
0
Francois Vanderseypen
Top achievements
Rank 2
answered on 04 May 2012, 11:45 AM
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.
0
Shrikant
Top achievements
Rank 1
answered on 04 May 2012, 12:49 PM
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
0
Ambit
Top achievements
Rank 1
answered on 04 May 2012, 01:14 PM
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.
0
Petar Mladenov
Telerik team
answered on 04 May 2012, 02:26 PM
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 >>

0
Ambit
Top achievements
Rank 1
answered on 07 May 2012, 07:45 AM
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
0
Petar Mladenov
Telerik team
answered on 10 May 2012, 06:57 AM
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 >>

0
Yogendra
Top achievements
Rank 1
answered on 06 Sep 2013, 12:16 PM
Hi Petar,

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

Thanks

Regrads 
Yogendra
0
Petar Mladenov
Telerik team
answered on 10 Sep 2013, 09:06 AM
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 >>
0
Ajay
Top achievements
Rank 1
answered on 07 Jan 2014, 11:08 AM
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
0
Petar Mladenov
Telerik team
answered on 10 Jan 2014, 08:28 AM
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 >>
0
Ajay
Top achievements
Rank 1
answered on 10 Jan 2014, 10:41 AM
  With the selection of rectangle click some time the selection sticks on one and we are not able select any other. PFA screenshot
0
Petar Mladenov
Telerik team
answered on 15 Jan 2014, 07:09 AM
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 >>
0
Ajay
Top achievements
Rank 1
answered on 24 Mar 2014, 11:21 AM
 
 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)


0
Petar Mladenov
Telerik team
answered on 25 Mar 2014, 01:27 PM
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.

 
Tags
Diagram
Asked by
Ambit
Top achievements
Rank 1
Answers by
Francois Vanderseypen
Top achievements
Rank 2
Ambit
Top achievements
Rank 1
Shrikant
Top achievements
Rank 1
Petar Mladenov
Telerik team
Yogendra
Top achievements
Rank 1
Ajay
Top achievements
Rank 1
Share this question
or