The Macro SDK template contains all of the structure and configurations you need to get started. These include:
- Links to program DLLs
- Environments and references
- Setup for debugging
Making TBC Controls Available in Your VS Project
In Visual Studio's Solution Explorer pane (on the right), open the MyFirstMacro.xaml file..
On the left side of the screen, click Toolbox.
In the Toolbox pane, right-click All WPF Controls, and select Choose Items.
Click the WPF Components tab and then click Browse.
Navigate to C:\Program Files (x86)\Trimble\Macros SDK\, and select Trimble.Vce.UI.Controls.dll.
In the Choose Toolbox Items dialog, you will now see the custom TBC controls highlighted.
Press F5 to refresh the project.
Double-click one of the custom controls to add all of the custom controls DLLs as references.
Adding Controls to the UI
You can create user interfaces for your apps by dragging controls from the Toolbox and setting properties in the Properties window.
Select Project > Add New Item > IronPython WPF Window, and click Add to open a new XAML file.If the graphical Designer window does not open, right-click the .xaml file in the Solution Explorer, and select Include in Project to open it.
In the source view, type <Label Content=”Hello world”/> between <Grid> and </Grid> to see it appear in the Designer view.
Click-and-drag several of the WPF and TBC custom controls into the view as well. This is how you layout a command's UI. Notice how code for each control is added to the right pane as you do this.
Use the center grip to position the control and the corner and side grips to resize the control.
To add more controls, type the beginning of the control name and select the appropriate tag. For example, type <checkb... You will see Intellisense offer suggested tags. Select CheckBox and then Content.
Note: You can press Enter when the auto-fill (Intellisense) suggests the correct tag. Note: If you are not receiving Intellisense prompts as you type, you may need to add a WPF project or reference a 32-bit version of TBC. Note: You can add code to say what the state of the checkbox does in terms of operations. If you want enabled/checked to be the default for a checkbox, add the code.
The Designer offers many more controls you can use. This shows how easy it is to add UI, especially if the commands are written in WPF.
If you open the associated .py file, you can see where the corresponding .xaml file is referenced under class.
Close the tab when you are done experimenting.