locked
How would i go about extending the open file tabs and file list in visual studio 2010 RRS feed

  • Question

  • I have written some extensions before, but they generally involved creating a new menu item for an existing context menu.

    What I would like to do is make a change to the IDE that would resolve an issue that I have whenever I have too many files open.  I dont want to close every file, nor do I want to close all but 1. 

    My solution to this would be to edit the file list drop down (the downward pointing arrow on the right side of the open file tab list) so that each item has an "X".  Clicking on the "X" would close the file.  This would help because it is so much easier to see all of the files at once from this view than it is from the tab view.

    So my question is how should i go about this?  Do I need to create my own unique Window that would replace the existings tabs and drop down, or can I do it via a fairly simple extension?  I have looked through the DTE2 documentation pretty thoroughly and tried to find it at run time, it hasnt worked out so far.

    Could someone point me in the right direction?

    Thanks,

    Brian

     

    Friday, September 2, 2011 12:42 PM

Answers

  • Though a quick look (literally a 30 second look) shows that it appears you can multi-select document tabs with Ctrl + click.  So in theory you could add a command to the document tab context menu called something like "Close Selected" and, assuming the command handler could find the 'selected' tabs (not sure how, it seems we should expose this but I can't say where for sure) then it could call Close on all of their IVsWindowFrames, which should accomplish what you want.  But you couldn't modify the file list dropdown menu to have the behavior you describe above, that just isn't possible.

    Ryan

    • Marked as answer by bsayegh Wednesday, September 7, 2011 12:34 PM
    Friday, September 2, 2011 7:46 PM

All replies

  • You can't, at least not through any existing extensibility mechanisms.  The items on the menus represent VS commands, clicking on them executes the command.  The problem with this is that it sounds like you want it to execute a different command (i.e. not activate the file as it does today, but rather close it) + keep the menu open + remove the item from the displayed menu.

    VS doesn't work like that and doing this would simply not be possible.

    Ryan

    Friday, September 2, 2011 3:42 PM
  • Though a quick look (literally a 30 second look) shows that it appears you can multi-select document tabs with Ctrl + click.  So in theory you could add a command to the document tab context menu called something like "Close Selected" and, assuming the command handler could find the 'selected' tabs (not sure how, it seems we should expose this but I can't say where for sure) then it could call Close on all of their IVsWindowFrames, which should accomplish what you want.  But you couldn't modify the file list dropdown menu to have the behavior you describe above, that just isn't possible.

    Ryan

    • Marked as answer by bsayegh Wednesday, September 7, 2011 12:34 PM
    Friday, September 2, 2011 7:46 PM
  • Hello,

    Would you mind letting me know the result of the suggestions? If you need further assistance, feel free to let me know. I will be more than happy to be of assistance.

    Yi


    Yi Feng Li [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, September 7, 2011 5:22 AM
  • You can multi-select the tabs?  When I Ctrl + click on a tab it selects that document, but deselects the previous document.  It sounds like making changes to the document list is not possible, but maybe I could create a new with a list of open files.  When I click on them they fire the VS Command to close an open window.  If I understand correctly that command will fire off various other events that will close the tab, remove it from the file list, and so on.

    The biggest challenge I think with this would be know when a file has been opened or closed so that the list is always up to date.  There could be refresh button but ideally there would be an event I could listen for.  Does this sound plausible? 

    Wednesday, September 7, 2011 12:42 PM
  • No, I was mistaken sorry, you can't multi-select tabs. 

    You could create a new list of open files using a DynamicItemStart, that is what the shell does, the 'close' command doesn't do anything but close the frame, the fact it is removed from the list is a side effect of the frame closing (i.e. the next time we expand the DynamicItemStart item the frame enumerator simply doesn't return that item as it is no longer open, thus it doesn't appear in the list of items).

    Assuming the items showing come from you then the action undertaken on click is also up to you.  The items on the drop down list you speak of happen activate the document on click, but that is simply because that is what the window manager defines them to do.

    The sucky part about that specific drop down is it isn't using the standard VS commanding mechanism, so you can't extend that menu or override the behavior of the items on it as they aren't classical VS commands :(

    Ryan

    Wednesday, September 7, 2011 5:47 PM