(Continued with Custom Ribbon of Navisworks part 1)
Ribbon Interface File
The technique to configure the ribbon interfaces uses Extensible Application Markup Language(XAML). Several main types of tag (nodes):
RibbonControl: This is the top most node. It defines the Ribbon’s unique name and necessary configurations for the xaml.
RibbonTab: configures the Ribbon tab. The attributes include:
- Id: defines a unique identifier for the ribbon tab - this must be identical to the ribbon tab Id in compiled code.
- Title: defines the text than appears on the tab. This overrides the DisplayName attribute in compiled code.
- KeyTip: the key or combination of keys that enables the tab to be activated using the keyboard rather than the mouse.
RibbonPanel: provides a distinct panel in the ribbon tab for a group of buttons. Only one attribute:
- x:Uid: unique id used in xmal file
RibbonPanelSource: defines the content and properties of its parent node RibbonPanel. Commands are defined with this node.
local:NWRibbonButton: indicates a button in the ribbon. The attributes include:
- x:Uid: unique id used in xmal file
- Id: Defines a unique identifier for the command
- Size: standard (default) or Large.
- Image: image to display. It overrides that defined by plug-in attributes in the compiled code. The image path defines the location relative to the ribbon definition file (XAML), hence our image path here indicates that the images are located in an Images subdirectory next to the sub-directory when the ribbon file is located. If you wish you can define the image location relative to the Roamer executable by using Image="pack://siteOfOrigin:,,,{image location}" where {image location} is the location of the icon (or png file) relative to the executable. Standard images must be 16x16 pixels. For large buttons specify Size="Large" and define a LargeImage attribute, which must be 32x32 pixels.
- KeyTip: the key or combination of keys that enables the button to be activated using the keyboard rather than the mouse. Keytips are made visible by pressing
- Orientation: "Horizontal" or "Vertical". Horizontal places the buttons side by side with the Text. Vertical places the buttons above the text.
- ShowText : indicates whether the button should display its Text with the button, or image only. Text: text displayed on the button if ShowText is true. It overrides that defined by plugin attributes in the compiled code)
local:NWRibbonSplitButton: As the name suggests, this defines the Split button. It can be defined as synchronized with current item (i.e. the last drop-down item clicked appears on the button), or not synchronized with the current item. The button can be clicked independently from the drop-down menu. Most attributes are same to local:NWRibbonButton.
- IsSynchronizedWithCurrentItem: synchronized or non- synchronized
- IsSplit: indicates that the button can be clicked independently from the drop down, thus activating the current item.
e.g.
<?xml version="1.0" encoding="utf-8" ?>
<RibbonControl
x:Uid="ADNRibbonDemo" xmlns="clr-namespace:Autodesk.Windows;assembly=AdWindows"
xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:adwi="clr-namespace:Autodesk.Internal.Windows;assembly=AdWindows"
xmlns:system="clr-namespace:System;assembly=mscorlib"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Autodesk.Navisworks.Gui.Roamer.AIRLook;assembly=navisworks.gui.roamer">
<RibbonTab Id="ID_CustomTab_1" KeyTip="T1">
<RibbonPanel x:Uid="RibbonPane1_1">
<RibbonPanelSource x:Uid="RibbonPanelSource_RibbonPanel_1" KeyTip="C1" Title="Large Button">
<local:NWRibbonButton x:Uid="Button_1" Id="ID_Button_1"
Size="Large"
KeyTip="B1"
ShowText="True"
Text="Button 1 in xaml"
Orientation="Vertical"/>
</RibbonPanelSource>
</RibbonPanel>
</RibbonTab>
</RibbonControl>
In our sample, the grouped buttons (Button4 and Button5) are designed as Synchronize.
Name File for Localization
This is a text file with the extension *.name. It defines the localized text for ribbon tabs and commands. The strings defined in the xaml layout file overrides strings defined in the name file. That implies that Navisworks will ignore the strings in *.name file if you specify the strings in xaml. So the name file is not required when the xaml file is language-specific. The name file in our sample provides display names for all tabs and buttons. This file uses UTF8 encoding. Lines starting with # or $, or ending with = means do not need translating. e.g.
# This is comments
$ This is comments
ID_CustomTab_2.DisplayName=
Tab2 in name file
ID_Button_1.DisplayName=
Button1 in name file
In general, the icon of the command is specified with a relative path, while the root path is where the plug-in dll resides in. It is recommended to create one sub-folder for storing these images.
Now that the whole application is available. We shall build the project to generate the ADNRibbonDemo.dll.
(To be continued)