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

Drag and Drop from Sessions View into a DataGridView

2 Answers 117 Views
Extensions and Customization
This is a migrated thread and some comments may be shown as answers.
Fuszenecker
Top achievements
Rank 1
Fuszenecker asked on 14 Sep 2014, 03:41 PM
Hello,

I am trying to create an extension for Fiddler, but my problem is that I cannot do drag and drops from the Session View into the DataGridView. 

When I implement the DragEnter method of the DataGridView I only see the dragged object as a DataObject and I cannot convert it to Session type and it does not contain any text.

I would like to access the URL of the session.

I could not find any documentation and no open-source plugins to check how its done in other extensions like the AutoResponder.

Could you please tell me how to do this?

Cheers,
Zsombor

2 Answers, 1 is accepted

Sort by
0
Accepted
Eric Lawrence
Telerik team
answered on 15 Sep 2014, 03:15 PM
Thanks for letting me know. The SAZClipboard extension used to include source code that showed how to do this, but I'm not sure what happened to it. You were probably getting thrown off by the fact that the drag/drop format is an array of Sessions.

private void lvSessionClip_DragEnter(object sender, DragEventArgs e)
{
     e.Effect = (e.Data.GetDataPresent("Fiddler.Session[]") ||                  
         e.Data.GetDataPresent(DataFormats.FileDrop)) ?
         DragDropEffects.Copy : e.Effect = DragDropEffects.None;
}

private void lvSessionClip_DragDrop(object sender, DragEventArgs e)
{
   Session[] oSessions = (Session[])e.Data.GetData("Fiddler.Session[]");
   if ((oSessions == null) || (oSessions.Length < 1)) { Debug.Assert(false,    "Unexpected drop type."); return; }
   foreach (Session oSession in oSessions)
   {
      ListViewItem oLVI = new ListViewItem(new string[] {
         oSession.oRequest.headers.HTTPMethod,
         oSession.oRequest.headers.UriScheme,
         oSession.host,
         oSession.oRequest.headers.RequestPath,
         oSession.GetRequestBodyAsString(),
         oSession.oFlags["ui-comments"]});
     oLVI.Tag = oSession;
     lvSessionClip.Items.Add(oLVI);
    }
}


Having said that, most Fiddler extensions don't use drag/drop and instead rely on the list of Sessions that are currently selected in the list via FiddlerApplication.UI.GetSelectedSessions()
Regards,
Eric Lawrence
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Fuszenecker
Top achievements
Rank 1
answered on 15 Sep 2014, 03:56 PM
Thank you very much for the fast reply Eric, this is exactly what I needed!
Tags
Extensions and Customization
Asked by
Fuszenecker
Top achievements
Rank 1
Answers by
Eric Lawrence
Telerik team
Fuszenecker
Top achievements
Rank 1
Share this question
or