Control Architect provides the ability to define and save often used pieces of C# code used to define Control Binding expressions as Code Snippets. Code snippets provide a library of samples of C# scripting that can be easily dragged and dropped onto the script editor.
Creating a Code Snippet
A Code Snippet can be created in one of two ways as follows:
Click the Add-New Snippet Button in the Code Snippet view.
From the Script Editor surface of a Control Binding, select a text range and left mouse-click and hold the button while dragging the selected text range to the Code Snippet View, then release the mouse button to drop the selected text.
Using a Code Snippet
To use an existing Code Snippet, left mouse-click to select the Code Snippet in the Code Snippet view and drag it to the text position in the script editor surface, then release the mouse button to drop the dragged snippet text.
You can also select the script code using Ctrl+A and Ctrl+C to copy it to the Windows Clipboard. Use Ctrl+V to paste the code script in the editor.
Edit Existing Code Snippets
You can edit existing code snippets by selecting the Code Snippet to edit in the Code Snippet view. This will update the Code Snippet Editor view with the contents of the selected code snippet for editing. Any changes made in the Code Snippet Editor view will automatically be saved.
Delete an existing Code Snippet
A Code Snippet can be deleted by clicking the Remove Code Snippet button to delete the selected Code Snippet item.
Application Option to Auto Activate the Code Snippet Editor View
You can turn on/off the application option to automatically activate the Code Snippet Editor view when a code snippet item is selected in the Code Snippet view.
Notes
Your code snippets are saved to an json format file that is located in your local application data folder. This can typically be located at C:\Users\<user-name>\AppData\Local\Automation Software Technology, Inc.\Control Architect\UserSnippets.json where AppData is the hidden folder.
You can copy this file to save as a backup or share with other users.
This file can be edited off-line using a JSON editor. When edited, Control Architect must be restarted to reread the file.
Hover your mouse cursor over a Snippet item in the Snippet View to show a ToolTip that show the Snippet contents.