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

How can i get a grouptilebox destination after a event dragdrop

1 Answer 50 Views
Panorama
This is a migrated thread and some comments may be shown as answers.
Cleber
Top achievements
Rank 1
Cleber asked on 08 Aug 2013, 08:13 PM
When i move a tileElement from the group A to a group B or Group C... how can i know what group the tileElement went? but just after i release the tileElement in the group. 

i've tried this code:

public Form1()
{
    InitializeComponent();
    this.radPanorama1.PanoramaElement.DragDropService.Stopping += new EventHandler<Telerik.WinControls.RadServiceStoppingEventArgs>(DragDropService_Stopping);
}
 
void DragDropService_Stopping(object sender, Telerik.WinControls.RadServiceStoppingEventArgs e)
{
    if (e.Commit)
    {
        RadTileElement tile = this.radPanorama1.PanoramaElement.DragDropService.Context as RadTileElement;
    }
}
and then i tried to get tile.parent.parent... but doing this i get the source group... not the destination....
thanks

1 Answer, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 13 Aug 2013, 10:33 AM
Hi Cleber,

Thank you for writing.

To identify the group you have dropped a tile to, you can use the PreviewDragDrop event of the DragDropService:
void DragDropService_PreviewDragDrop(object sender, RadDropEventArgs e)
{
    TileGroupElement group = GetTargetGroup(new RectangleF(e.DropLocation, ((RadTileElement)e.DragInstance).Size));
 
    if (group != null)
    {
       //this is the target group
    }
}
 
protected virtual TileGroupElement GetTargetGroup(RectangleF tileRectangle)
{
    TileGroupElement result = null;
    float maxIntersection = 0;
 
    foreach (TileGroupElement group in radPanorama1.PanoramaElement.Groups)
    {
        if (tileRectangle.IntersectsWith(group.ControlBoundingRectangle))
        {
            RectangleF intersection = tileRectangle;
            intersection.IntersectsWith(group.ControlBoundingRectangle);
            float surface = intersection.Width * intersection.Height;
            if (surface > maxIntersection)
            {
                maxIntersection = surface;
                result = group;
            }
        }
    }
 
    return result;
}

I hope that you find this information useful. Let us know if you have any other questions.
 

Regards,
Stefan
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
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 >>
Tags
Panorama
Asked by
Cleber
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Share this question
or