Defining the User Interface
You can design the user interface of an add-in either programmatically using RobotStudio APIs or declaratively using the Ribbon.xml
available in the add-in template project.
The add-in templates are part of the RobotStudio SDK and will be installed in your machine during installation.
You can use one of these templates while creating a new add-in project.
In the New Project window of Visual Studio, select Installed > Templates> Visual C# > RobotStudio and then click Sample Add-in.
Ribbon.xml
The Ribbon.xml
conform to the Ribbon.xsd schema. This XML contains various elements for defining the user interface of your add-in. This XML file is part of your add-in project.
Open your sample add-in project and in the Solution Explorer, double-click the project name and then click the Ribbon folder.
This folder contains Ribbon.xml, CommandBarControls.xml
and ControlHelpTexts.xml
.
RobotStudio user interface follows Microsoft Office 2012 look and feel, for more details, refer User Interface.
A typical Ribbon area contains various Tabs. These Tabs contain one or more groups which display related controls together. The sample Ribbon.xml
follows the same structure.
<Tab id="SampleAddinUserDoc.Tab1" caption="Tab1" visible="false">
<Group id="Group1" caption="Group 1">
<Control id="SampleAddinUserDoc.Button1" layout="Large"/>
<Control id="SampleAddinUserDoc.Gallery1" layout="Large"/>
</Group>
</Tab>
The CommandBarControls.xml
. You can reference these controls using their IDs from the Ribbon.xml
.
CommandBarControls.xml
This XML file conform to the CommandBarControl.xsd schema. This schema contains definitions of various controls that can be defined in CommandBarControls.xml
file.
<CommandBarButton id="RobotStudioSampleAddin1.Button1" caption="Button 1"/>
In the CommandBarControls.xml
file the Start button has defaultEnabled
set to true which means that it will be enabled even before the add-in is loaded.
When it is clicked
, the add-in will be loaded and the ExecuteCommand
handler will be called.
Note
When you create the user interface of an add-in programmatically,
you must execute the add-in definition to add the controls to access the functionalities.
But, when you use Ribbon.xml
, RobotStudio finds the Ribbon.xml
file and parses it and creates
user interface as specified even without loading and executing the .dll files. By using the Ribbon.xml
file, you can prevent the delay loading of your add-in's user interface.
ControlHelpTexts.xml
This XML file conforms to the ControlHelpTexts.xsd schema. If you hover the mouse pointer over a control in the user interface, you can see the help text. Use this XML for defining the help text for the controls that you design.
<Control id="RobotStudioSampleAddin1.Button1">Button1 help text</Control>
Sample code for creating user interface controls
The section shows few examples of sample code for creating certain user interface controls and how they appear in the add-in's user interface.
<!-- In Ribbon.xml -->
<Group id="Group2" caption="Group 2">
<Control id="RobotStudioSampleAddin1.Menu1" layout="Small"/>
</Group>
<!-- In ControlHelpTexts.xml -->
<CommandBarPopup id="RobotStudioSampleAddin1.Menu1" caption="Sample Menu">
<Controls>
<Header caption="Header"/>
<Control id="RobotStudioSampleAddin1.Button1"/>
<Separator/>
<Control id="RobotStudioSampleAddin1.Button2"/>
</Controls>
</CommandBarPopup>
<!-- In Ribbon.xml -->
<Group id="Group2" caption="Group 2">
<Control id="RobotStudioSampleAddin1.ComboBox1" layout="Small"/>
</Group>
<!-- In ControlHelpTexts.xml -->
<CommandBarComboBox id="RobotStudioSampleAddin1.ComboBox1" caption="Select: ">
<Items>
<Item tag="1" caption="Item 1"/>
<Item tag="2" caption="Item 2"/>
<Item tag="3" caption="Item 3"/>
</Items>
</CommandBarComboBox>
<!-- In Ribbon.xml -->
<Group id="Group1" caption="Group 1">
<Control id="RobotStudioSampleAddin1.Gallery1" layout="Large"/>
</Group>
<!-- In ControlHelpTexts.xml -->
<CommandBarGalleryPopup id="RobotStudioSampleAddin1.Gallery1" caption="Sample Gallery" textPos="Right" imageId="RobotStudioSampleAddin1.Button2">
<GalleryControls>
<Header caption="Header 1"/>
<Control id="RobotStudioSampleAddin1.GalleryButton1"/>
<Header caption="Header 2"/>
</GalleryControls>
<Controls>
<Control id="RobotStudioSampleAddin1.Button1"/>
</Controls>
</CommandBarGalleryPopup>