Search code examples
visual-studio-2010vsxvsix

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


i'm developing a Visual Studio 2010 extension, i already have a toolbar inside my window. on that toolbar i have a button that i want to give an icon - my own icon! I've read this article and it is great but... it explains how to replace the icons.

i want to add an additional icon.

how do i achieve that?


Solution

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

    enter image description here

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

    enter image description here

    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.

    enter image description here