how can i add a new icon to a Visual Studio 2010 extension?

点点圈 提交于 2019-12-06 15:05:18

First, add the bitmap and set its build action to Resource

Remember, shocking pink = transparent (damn you, old school!)

Then, in your vsct file, add the image to the bitmaps section

<Bitmaps>
    <Bitmap guid="AddSampleData.bmpGuid"
            href="..\Button Bitmaps\AddSampleData.bmp"
            usedList="AddSampleData.bmpId" />
    <Bitmap guid="ApplySampleData.bmpGuid"
            href="..\Button Bitmaps\ApplySampleData.bmp"
            usedList="ApplySampleData.bmpId" />
</Bitmaps>

and assign it a guid in the symbols node

<Symbols>
    <!-- snip -->
    <GuidSymbol name="AddSampleData.bmpGuid"
                value="{dcae7c84-8e91-4f8a-907b-95ccb0f52e6e}">
        <IDSymbol name="AddSampleData.bmpId"
                    value="1" />
    </GuidSymbol>
    <GuidSymbol name="ApplySampleData.bmpGuid"
                value="{9f555245-2430-4e6f-992b-b49ce87a31a2}">
        <IDSymbol name="ApplySampleData.bmpId"
                    value="1" />
    </GuidSymbol>
</Symbols>

and apply it to a button

<Buttons>
<!-- snip -->
    <Button guid="guidEditorExtensionCommandSet"
            id="setDesignTimeDataOnPage"
            priority="0x0100">
        <Icon guid="ApplySampleData.bmpGuid"
                id="ApplySampleData.bmpId" />
        <Strings>
                    <!-- snip -->
        </Strings>
    </Button>
</Buttons>

Of course, its always easier to use the available tools, including the excellent VSPackage Builder extension.

A workaround for this is to create a PNG and rename the extension as *.bmp. VS will accept it as an icon image and it will also have transparency (from Visual Studio Extensibility > Toolbox Icons -- Is transparency supported?)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!