locked
VSPackage: itemAdded event in project sub type RRS feed

  • Question

  • HI

    I created a web sub project type.I want a specific html content rather the default html template when added to add item dialog.Can i override default project item template in my sub project. I implemented using mpf project sub type example given in vs2010 sdk samples.

    Or

    Can i do it programatically?Can I subscribe to any item added event for my project sub type.I tried to register for EnvDTE.ProjectItemsEvent.itemAdded event but it is not capturing the events.

    I tried CSharprProjectItemEvents ,WebsiteItemEvents but found that are do not fire events in my case.

    Does anyone has any idea about any interfaces or classes through which i can track addition of files into project ,can edit the content in it.

    Please provide any suggestions if possible.


    Abhiram

    Thursday, August 2, 2012 4:02 PM

All replies

  • Hi Abhiram,

    You can add a child node to a project type node in the New Project dialog box.  For example, for the SimpleProject project type, you could have child nodes for console applications, window applications, web applications, and so on.

    More information you can refer to:

    http://msdn.microsoft.com/en-us/library/cc826178.aspx

    Best regards,


    Ego [MSFT]
    MSDN Community Support | Feedback to us

    Friday, August 3, 2012 9:35 AM
  • For EnvDte events, you need to keep a local reference to the event, for instance : 

    private DocumentEvents _documentEvents;
    
    public Constructor(){
    this._documentEvents = this.dte.Events.DocumentEvents;
                this._documentEvents.DocumentSaved += new _dispDocumentEvents_DocumentSavedEventHandler(this.OnDocumentSaved);
    }

    It is the same for all other envdte events.

    But, if i understand your problem, you should use an item template to define a specific html file that contains what you need

    Friday, August 3, 2012 1:56 PM
  • HI mathias,

    Thanks for your reply.I need to test it.

    I found the solution to it.I have the projectItemevents event handlers defined in FlavoredProjectBase class as given in example CSVSIXProjectSubType sample in VS2010 sdk samples.I just implemented itemAdded event callback and got it done.

    For project template i created it and added to the vsix package along with my project for item template do i need to do the same?Does it show a new item template among the existing list?But I need the default html page selected by user to have my content.So,implementing event handler is fine I suppose.Please let me know suggestions if any.

    Thanks for the reply


    Abhiram

    Saturday, August 4, 2012 9:20 AM
  • Idon't know how to, but have a look to this thread.
    Saturday, August 4, 2012 9:26 AM