none
Drag 'n Drop From Action Pane RRS feed

  • Question

  • I have created a custom action pane for Power Point, essentially a tree view of some text items.  I would like to enable drag 'n drop such that a user can drag any tree view item onto the current slide, and when dropped it will create a new shape, with text to match the tree node's.  Is this very complicated, or are there any examples of how it can be done.


    Thursday, May 12, 2011 4:20 PM

Answers

  • Hi Wsmckenz,

    Thank you for posting.

    After reading your post, I did some research about your problem. I think it may possible to achieve your requirement, please take a look at this thread:

    http://social.msdn.microsoft.com/Forums/en-US/vsto/thread/59696fec-aab4-4853-8231-7161f52fd686/

    which contains the code snippet about dragging text to Excel, I think it could be applied to Powerpoint. You can take try about this.

    Hope this can give you the hint and feel free to follow up.

    Best Regards,


    Bruce Song [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Bruce Song Monday, May 30, 2011 9:04 AM
    Friday, May 13, 2011 1:24 PM
  • I think I'm still not making point my correctly.  What I want to control in code, is which type of Powerpoint object gets dropped.  I would like to be able to insert images, shapes, text, smart art, whatever based on the context of the node in my Tree view.  I could envision doing this one of two ways: 1) use an object model to create the exact powerpoint object i wanted and drop it, instead of just text; 2) somehow get hold of the simple text i dropped (perhaps through an event) and change this object to be what I want.  As near as I can tell, neither are possible with the Powerpoint object model.  It seems to be focused on runtime customization, not design time.
    • Marked as answer by wsmckenz Tuesday, May 31, 2011 12:46 PM
    Monday, May 30, 2011 9:20 PM

All replies

  • Hi Wsmckenz,

    Thank you for posting.

    After reading your post, I did some research about your problem. I think it may possible to achieve your requirement, please take a look at this thread:

    http://social.msdn.microsoft.com/Forums/en-US/vsto/thread/59696fec-aab4-4853-8231-7161f52fd686/

    which contains the code snippet about dragging text to Excel, I think it could be applied to Powerpoint. You can take try about this.

    Hope this can give you the hint and feel free to follow up.

    Best Regards,


    Bruce Song [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Bruce Song Monday, May 30, 2011 9:04 AM
    Friday, May 13, 2011 1:24 PM
  • Hi Wsmckenz,

    Have you resolved your problem yet, and does the suggestion help you? If you still have any concern on the thread, feel free to follow up.

    Best Regards,




    Bruce Song [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, May 18, 2011 10:50 AM
  • Hi Bruce,

    That example was helpful to some extent.  I can see how you allow the text to be dropped on the slide, but what is created is always a simple text box.  What I'm not sure of is how I can manipulate the object that is created based on the tree node.  For example, say my tree view is a list of vehicles. Each vehicle in the tree view is either a car, a truck or an SUV.  When I do the drop, I want to create a particular shape in the power point based on that type.  I either want to determine this shape prior to the drop, or have an event fire that would allow me to edit the shape after it is drawn.  I dont seem to be able to do either of those things.

    Thursday, May 19, 2011 3:32 PM
  • Hello,

     

    You can achieve that if before the line 

    this.treeView1.DoDragDrop(this.treeView1.SelectedNode.Text, DragDropEffects.Copy);

    you can analyze the node to see what it is, and after the line you cand continue inserting it. To not insert the text anymore, replace  this.treeView1.SelectedNode.Text with "".

     

    Best regards,

    Silviu.


    http://www.rosoftlab.net/
    • Proposed as answer by Bruce Song Wednesday, May 25, 2011 7:54 AM
    • Marked as answer by Bruce Song Monday, May 30, 2011 9:04 AM
    • Unmarked as answer by wsmckenz Monday, May 30, 2011 9:15 PM
    Friday, May 20, 2011 6:35 AM
  • Hi Wsmckenz,

    Does Silviu's suggestion help you or not?

    Best Regards,


    Bruce Song [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, May 25, 2011 7:55 AM
  • I think I'm still not making point my correctly.  What I want to control in code, is which type of Powerpoint object gets dropped.  I would like to be able to insert images, shapes, text, smart art, whatever based on the context of the node in my Tree view.  I could envision doing this one of two ways: 1) use an object model to create the exact powerpoint object i wanted and drop it, instead of just text; 2) somehow get hold of the simple text i dropped (perhaps through an event) and change this object to be what I want.  As near as I can tell, neither are possible with the Powerpoint object model.  It seems to be focused on runtime customization, not design time.
    • Marked as answer by wsmckenz Tuesday, May 31, 2011 12:46 PM
    Monday, May 30, 2011 9:20 PM
  • Hello,

     

    I will try to put into code what i previously said:

    ...
       void treeView1_MouseMove(object sender, MouseEventArgs e)
        {
          if (mouseIsDown && (this.treeView1.SelectedNode != null))
          {
            //analyze this.treeView1.SelectedNode to see what type of powerpoint element must be created
             this.treeView1.DoDragDrop("", DragDropEffects.All);
            // using the current selection in the powerpoint, it being the dropped position, create & insert the powerpoint element 
          }
          mouseIsDown = false;
        }
      }
    

     

    I addapted a little bit from the code found in the link specified by Bruce.

    PS: If you control does not have the DoDragDrop method, you can use the one found in the application:

    IDataObject dObject = new DataObject("");
    var resultDrag = DragDrop.DoDragDrop(this.treeView, dObject, DragDropEffects.All);
    

     

    Hope it helps,

    Silviu.


    http://www.rosoftlab.net/
    Tuesday, May 31, 2011 5:37 AM
  • OK, I think I understand my problem.  I was not catching the WindowSelectionChange event properly in my addin and I thought it wasn't firing at all.  Thanks for your patience.

    Tuesday, May 31, 2011 12:46 PM