[Connect C# Addin] How can I get my own icon to a button on a ribbon?

How can I get my own icon to a button on a ribbon? Do I need a icon resource?

The Ribbon is load to Microstation Connect Edition and works fine. I use a xml file for the ribbon. Here is a snippet of a button in the xml file.

    <Button Name="MSCEAddin.OpenAction" Priority="100">
      <Label>Open</Label>
      <Description>Open document.</Description>
      <ButtonParams CollapseToSmall="WhenGroupIsSmall" Size="Large">
      </ButtonParams>
      <ButtonData>
        <CommandData Type="UserKeyinCommand">
          <UserKeyinCommand>
            <Keyin>MSCEAddin Open</Keyin>
            <Icon Type="NamedIcon">
              <NamedIcon>Application</NamedIcon>
            </Icon>
          </UserKeyinCommand>
        </CommandData>
      </ButtonData>
    </Button>

I think, the issue is the NamedIcon <NamedIcon>Application</NamedIcon>. How can I get 'MyOwnIcon.png' as icon?

Parents
  • Hi Philip,

    there are more way how and where to store own icons, that are used in ribbon. As Jon wrote, the standard format is .ico, not png, so you have to convert your icons at first.

    I think there are (at least) three ways:

    • Use separate ico files.
    • Use dnglib as icon container.
    • Compile icons to rsc file, in the best case including xml ribbon definition.

    The most simple is to use ico files:

    • Check how MS_ICONPATH is defined or to add own folder to the definition.
    • Copy your icons to this folder.
    • In XML, specify the icon name (without .ico extension) in <NamedIcon> definition.

    I guess the best, because it does not require any compilation, but using one file as a storage, is to store icons in dgnlib:

    1. Configure MS_GUIDGNLIBLIST to include your dgnlib. I usually have a dgnlib distributed with an application, but when the application is more complex, I can imagine there are more to have separated icons container and design customizations (levels, tasks...).
    2. Open the dgnlib in MicroStation. The best way in my opinion is to open Customize dialog (key-in "customize dialog") and check whether your dgnlib is listed in File menu. It allows open the dgnlib quickly and at the same time it's proof that the dgnlib is recognized by MicroStation.
    3. In Customize dialog, switch to Icons tab and import ico file.
    4. As in previous case, specify the icon name (without .ico extension) in <NamedIcon> definition.

    Result (worm defined in dgnlib, brain slug in separate ico file):

    With regards,

      Jan

    P.S. Please always use Insert > Insert code too to share code snippets. It's annoying to read code or xml content formated as a plain text.

  • worm defined in dgnlib, brain slug in separate ico file

    Please tell us more about those tools.

     
    Regards, Jon Summers
    LA Solutions

  • Please tell us more about those tools.

    Not too much behind these icons... ;-)

    They are leftovers of an evaluation of ribbon configurations I did in the past and the tools only call MicroStation key-ins:

    <Button Name="Drawing.MyTab.MyButton" Priority="100">
      <Label>Place worm</Label>
      <Description>Place linear element</Description>
      <ButtonParams Size="Large" />
      <ButtonData>
        <CommandData Type="UserKeyinCommand">
          <UserKeyinCommand>
            <Keyin>place smartline</Keyin>
            <Icon Type="NamedIcon">
              <NamedIcon>my_icon_worm</NamedIcon>
            </Icon>
          </UserKeyinCommand>
        </CommandData>
      </ButtonData>
    </Button>
    <Button Name="Drawing.MyTab.NButton" Priority="100">
      <Label>Place brain slug</Label>
      <Description>Place cell element</Description>
      <ButtonParams Size="Large" />
      <ButtonData>
        <CommandData Type="UserKeyinCommand">
          <UserKeyinCommand>
            <Keyin>place cell icon;set item toolsettings activecell=alien</Keyin>
            <Icon Type="NamedIcon">
              <NamedIcon>my_icon_brain-slug</NamedIcon>
            </Icon>
          </UserKeyinCommand>
        </CommandData>
      </ButtonData>
    </Button>

    Regards,

      Jan

  • Hi

    I have not done this before so was wondering if anyone has suggestions for free tools to convert to .ico format?

Reply Children