且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何向 Visual Studio 2010 扩展添加新图标?

更新时间:2023-12-04 09:43:16

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.