Özellik sayfaları ekleme ve kaldırma

Project Tasarım Aracı, Visual Studio'daki proje özelliklerini, ayarlarını ve kaynaklarını yönetmek için merkezi bir konum sağlar. Visual Studio tümleşik geliştirme ortamında (IDE) tek bir pencere olarak görünür ve sağda soldaki sekmelerden erişilen birkaç bölme içerir. Project Tasarım Aracı bölmeleri (genellikle özellik sayfaları olarak adlandırılır) proje türüne ve diline göre değişir. Project Tasarım Aracı, Proje menüsündeki Özellikler komutuyla erişilebilir.

Proje alt türünün project Tasarım Aracı sık sık ek özellik sayfaları görüntülemesi gerekir. Benzer şekilde, bazı proje alt türleri yerleşik özellik sayfalarının kaldırılmasını gerektirebilir. Bu işlemlerden birini yapmak için proje alt türünüzün arabirimini IVsHierarchy uygulaması ve yöntemini geçersiz kılması GetProperty gerekir. Bu yöntemi geçersiz kılarak ve sabit listesi değerlerinden birini içeren parametreyi __VSHPROPID2 kullanarak propId proje özelliklerini filtreleyebilir, ekleyebilir veya kaldırabilirsiniz. Örneğin, yapılandırmaya bağımlı özellik sayfalarına bir sayfa eklemeniz gerekebilir. Bunu yapmak için yapılandırmaya bağımlı özellik sayfalarını filtrelemeniz ve ardından var olan listeye yeni bir sayfa eklemeniz gerekir.

Project Tasarım Aracı özellik sayfaları ekleme ve kaldırma

Özellik sayfasını kaldırma

  1. GetProperty(uint itemId, int propId, out object property) Özellik sayfalarını filtrelemek ve bir clsids liste almak için yöntemini geçersiz kılın.

    protected override int GetProperty(uint itemId, int propId, out object property)
    {
        //Use propId to filter configuration-independent property pages.
        switch (propId)
        {
            . . . .
    
            case (int)__VSHPROPID2.VSHPROPID_PropertyPagesCLSIDList:
                {
                    //Get a semicolon-delimited list of clsids of the configuration-independent property pages
                    ErrorHandler.ThrowOnFailure(base.GetProperty(itemId, propId, out property));
                    string propertyPagesList = ((string)property).ToUpper(CultureInfo.InvariantCulture);
                    //Remove the property page here
                    . . . .
                }
             . . . .
         }
            . . . .
        return base.GetProperty(itemId, propId, out property);
    }
    
  2. Alınan clsids listeden Derleme Olayları sayfasını kaldırın.

    string buildEventsPageGuid = "{1E78F8DB-6C07-4D61-A18F-7514010ABD56}";
    int index = propertyPagesList.IndexOf(buildEventsPageGuid);
    if (index != -1)
    {
        // GUIDs are separated by ';' so if you remove the last GUID, also remove the last ';'
        int index2 = index + buildEventsPageGuid.Length + 1;
        if (index2 >= propertyPagesList.Length)
            propertyPagesList = propertyPagesList.Substring(0, index).TrimEnd(';');
        else
            propertyPagesList = propertyPagesList.Substring(0, index) + propertyPagesList.Substring(index2);
    }
    //New property value
    property = propertyPagesList;
    

Özellik sayfası ekleme

  1. Eklemek istediğiniz bir özellik sayfası oluşturun.

    class DeployPropertyPage : Form, Microsoft.VisualStudio.OLE.Interop.IPropertyPage
    {
        . . . .
        //Summary: Return a structure describing your property page.
        public void GetPageInfo(Microsoft.VisualStudio.OLE.Interop.PROPPAGEINFO[] pPageInfo)
        {
            PROPPAGEINFO info = new PROPPAGEINFO();
            info.cb = (uint)Marshal.SizeOf(typeof(PROPPAGEINFO));
            info.dwHelpContext = 0;
            info.pszDocString = null;
            info.pszHelpFile = null;
            info.pszTitle = "Deployment";  //Assign tab name
            info.SIZE.cx = this.Size.Width;
            info.SIZE.cy = this.Size.Height;
            if (pPageInfo != null && pPageInfo.Length > 0)
                pPageInfo[0] = info;
        }
    }
    
  2. Yeni özellik sayfanızı kaydedin.

    [MSVSIP.ProvideObject(typeof(DeployPropertyPage), RegisterUsing = RegistrationMethod.CodeBase)]
    
  3. GetProperty(uint itemId, int propId, out object property) Özellik sayfalarını filtrelemek, bir liste almak ve yeni bir clsids özellik sayfası eklemek için yöntemini geçersiz kılın.

    protected override int GetProperty(uint itemId, int propId, out object property)
    {
        //Use propId to filter configuration-dependent property pages.
        switch (propId)
        {
            . . . .
            case (int)__VSHPROPID2.VSHPROPID_CfgPropertyPagesCLSIDList:
                {
                    //Get a semicolon-delimited list of clsids of the configuration-dependent property pages.
                    ErrorHandler.ThrowOnFailure(base.GetProperty(itemId, propId, out property));
                    //Add the Deployment property page.
                    property += ';' + typeof(DeployPropertyPage).GUID.ToString("B");
                }
         }
            . . . .
        return base.GetProperty(itemId, propId, out property);
    }