Drag and Drop from Sessions View into a DataGridView

3 posts, 1 answers
  1. Fuszenecker
    Fuszenecker avatar
    3 posts
    Member since:
    Mar 2014

    Posted 14 Sep 2014 Link to this post

    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. Answer
    Eric Lawrence
    Admin
    Eric Lawrence avatar
    833 posts

    Posted 15 Sep 2014 Link to this post

    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.

     
  3. Fuszenecker
    Fuszenecker avatar
    3 posts
    Member since:
    Mar 2014

    Posted 15 Sep 2014 Link to this post

    Thank you very much for the fast reply Eric, this is exactly what I needed!
Back to Top