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

夙愿已清 提交于 2019-12-23 01:55:09

问题


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?


回答1:


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.




回答2:


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?)



来源:https://stackoverflow.com/questions/9092595/how-can-i-add-a-new-icon-to-a-visual-studio-2010-extension

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