We support injecting values from registry values, which means that we can refer to values from registry in attributes and element values in other commands. To do so, use the command below around the commands where you want to refer to a given registry value. It has no parameters but should have both an opening and closing tag with the commands that should run inside.
The registry value that should be injected must start and end with %. Examples of usage can be seen below.
CMD
<Cmd case="BaseExtensions:inject-registry-value">
....
</Cmd>
Example of usage: Change colors
The example below is an odd case, yet it illustrates how we can execute various commands that inject registry values, and thus perform several changes, with just one click.
<Cmd case="BaseExtensions:inject-registry-value">
<Cmd case="%HKEY_CURRENT_USER\Teste\Leste\changefill%" name="MyShape" color="%HKEY_CURRENT_USER\Teste\Leste\colorRed%"/>
<Cmd case="BaseExtensions:change-font-color-named-shape" name="MyShape" color="%HKEY_CURRENT_USER\Teste\Leste\colorBlue%"/>
<Cmd case="BaseExtensions:change-line-color-named-shape" name="MyShape" color="%HKEY_CURRENT_USER\Teste\Leste\colorGreen%"/>
</Cmd>
In this case, the commands inside the command to inject registry values change both the fill, font and line color of a shape called MyShape. In the first command, we refer to a registry value in the command case. As seen in the image below, the value of this registry entry is a command case. In the remaining commands that handle shape color, we refer to a registry value in the color parameter. Thus, it is possible to inject registry values in several parameters.
Example of usage: Change text
<Cmd case="BaseExtensions:inject-registry-value">
<Cmd case="SkabelonDesign.DocumentData:EnablePendingChanges"/>
<Cmd case="SkabelonDesign.DocumentData:DefineData" variableName="Teste">
<s>
%HKEY_CURRENT_USER\Teste\Leste\changeme%
</s>
</Cmd>
<Cmd case="SkabelonDesign.DocumentData:Commit"/>
</Cmd>
As seen in the attached document (bottom of article), there is a content control named Teste. The remaining commands in the example defines data to this very variable, meaning that text in this content control will be replaced with what is defined in the registry called changeme
.
Example of usage: Set printer
In the configuration for this, we define the name of the printer. The case is that it should print from the default printer if it prints black/white, and if the user enforces color print, it should print from another.
Firstly, the client has a toggle button that sets a registry value. Read more about how toggle buttons work in this article. As seen in the code snippet below, the value is set to "Follow Me Colour" when the toggle button is pressed and "Default" when it is not pressed. In this way, the registry value that sets the printer is adjusted based on this toggle button.
<ToggleButton label="Enforce PM Color print (Default printer if not selected)" pressed="BaseExtensions:any"
pressed-1-type="REGISTRY"
pressed-1-key-1="Software\Alloy" pressed-1-key-2="ForcePrinter" pressed-1-value-1="Follow Me Colour">
<True>
<Cmd case="BaseExtensions:update-registry" path="Software\Alloy" name="ForcePrinter" type="string" valueDefault="Follow Me Colour"/>
</True>
<False>
<Cmd case="BaseExtensions:update-registry" path="Software\Alloy" name="ForcePrinter" type="string" valueDefault="Default"/>
</False>
</ToggleButton>
The client has a menu consisting of various print options. In each option, we surround the configuration with the command to inject registry values in order to refer to the particular registry value that determines the printer. The code snippet below is an excerpt of the entire module.
<Button label="A3" icon="GroupPrintPreviewPrint"> <Cmd case="BaseExtensions:inject-registry-value">
<Cmd case="BaseExtensions:print-advanced"
Duplex="false"
PrinterName="%HKEY_CURRENT_USER\Software\Alloy\ForcePrinter%"
PrintSize="A3"
NumberOfCopies="1"
FirstPageTray="Tray 4"
RemainingPagesTray="Tray 4"
Collate="true"
PagesPerSheet="1"
PrintWhat="Document"
/>
</Cmd>
</Button>
In this way, the value of the PrinterName
parameter is determined by the registry value that is based on the toggle button.
Comments
0 comments
Article is closed for comments.