Quantcast
Channel: Visual Studio Integrate forum
Viewing all articles
Browse latest Browse all 4410

SDK Package:How to monitor build action changed in property window

$
0
0

How to monitor build action changed in property window.

1. when I changed the build action and the event did not fire.

I used code below but did not work:

    HierarchyEvents hierarchyEvent = new HierarchyEvents(pHierarchy);
            uint cookie;
            pHierarchy.AdviseHierarchyEvents(hierarchyEvent, out cookie);

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio;
using System.Windows.Forms;
using Microsoft.VisualStudio.Shell.Interop;
using EnvDTE;

namespace xxxx
{
  public  class HierarchyEvents : Microsoft.VisualStudio.Shell.Interop.IVsHierarchyEvents
    {
        public IVsHierarchy IVsHierarchy { get; set; }
        public HierarchyEvents()
        {
            
        }
        public HierarchyEvents(IVsHierarchy hierarchy)
        {
            this.IVsHierarchy = hierarchy;        
        }
        #region IVsHierarchyEvents Members

        public int OnInvalidateIcon(IntPtr hicon)
        {
            return VSConstants.S_OK;
        }

        public int OnInvalidateItems(uint itemidParent)
        {
            return VSConstants.S_OK;
        }

        public int OnItemAdded(uint itemidParent, uint itemidSiblingPrev, uint itemidAdded)
        {
            return VSConstants.S_OK;
        }

        public int OnItemDeleted(uint itemid)
        {
            return VSConstants.S_OK;
        }

        public int OnItemsAppended(uint itemidParent)
        {
            return VSConstants.S_OK;
        }
    
        public int OnPropertyChanged(uint itemid, int propid, uint flags)
        {
            //MessageBox.Show("changed"+itemid+ " "+propid+" "+flags);

            try
            {
                object ppObject;
                if (IVsHierarchy.GetProperty(itemid, (int)__VSHPROPID.VSHPROPID_ExtObject, out ppObject) == VSConstants.S_OK)
                {
                    if (ppObject is ProjectItem)
                    {
                        MessageBox.Show(("Hierarchy->OnPropertyChanged: " + ((ProjectItem)ppObject).Name));
                    }
                }
                if (IVsHierarchy.GetProperty(itemid, (int)__VSHPROPID.VSHPROPID_Name, out ppObject) == VSConstants.S_OK)
                {
                    int nop = 0;
                }
            }
            catch (Exception ex)
            {
                int nop = 0;
            }
           
            return VSConstants.S_OK;
        }

        #endregion
    }
}


文文小星



Viewing all articles
Browse latest Browse all 4410

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>