Hello all. I have a plugin where I have a Connect and Disconnect button. I've been exploring the use of conditions to enable/disable the buttons. What I cannot figure out is how to have the Connect enabled while the Disconnect is disabled from the start. Below is the snippet from my Config.daml. With this setup the Connect and Disconnect buttons are disabled from the start. Based on the state of the connection I'd like the button state to change too.
Thanks!
<button id="btnConnect" caption="Connect" className="Connect" smallImage="Images\greenCheck16.png" largeImage="Images\greenCheck32.png" condition="Disconnected"><tooltip heading="Tooltip">Use this button to connect to the system</tooltip>"</button><button id="btnDisconnect" caption="Disconnect" className="Disconnect" smallImage="Images\redX16.png" largeImage="Images\redX32.png" condition="Connected"><tooltip heading="Tooltip">Use this button to disconnect to the system</tooltip>"</button></controls></insertModule></modules><conditions><!-- our custom condition --><insertCondition id="Connected" caption="Connected to the system"><!-- our condition is set true or false based on this underlying state --><state id="connected" /></insertCondition><insertCondition id="Disconnected" caption="Disconnected from the system"><!-- our condition is set true or false based on this underlying state --><state id="disconnected" /></insertCondition></conditions>
Solved! Go to Solution.
I think you're on the right track.
I would first setup your conditions like this:
<insertCondition id="Disconnected_condition">
<not>
<state id="Connected_state" />
</not>
</insertCondition>
<insertCondition id="Connected_condition">
<state id="Connected_state" />
</insertCondition>
By default, you are in a disconnected state so your connect button should be enabled. Your disconnect button should be disabled.
In the OnClick method of your connect button, change the state:
FrameworkApplication.State.Activate("Connected_state");
The UI should automatically update itself and your connect button should become disabled and your disconnect button enabled.
In the OnClick method of your disconnect button, change the state:
FrameworkApplication.State.Deactivate("Connected_state");
At this point, your disconnect button should now disable and your connect button is enabled.
HTH,
Kris
p.s. instead of using hard-coded strings, I recommend using constants. You won't be able to use the constants in the config.daml file but you will be able to use them in code.
I think you're on the right track.
I would first setup your conditions like this:
<insertCondition id="Disconnected_condition">
<not>
<state id="Connected_state" />
</not>
</insertCondition>
<insertCondition id="Connected_condition">
<state id="Connected_state" />
</insertCondition>
By default, you are in a disconnected state so your connect button should be enabled. Your disconnect button should be disabled.
In the OnClick method of your connect button, change the state:
FrameworkApplication.State.Activate("Connected_state");
The UI should automatically update itself and your connect button should become disabled and your disconnect button enabled.
In the OnClick method of your disconnect button, change the state:
FrameworkApplication.State.Deactivate("Connected_state");
At this point, your disconnect button should now disable and your connect button is enabled.
HTH,
Kris
p.s. instead of using hard-coded strings, I recommend using constants. You won't be able to use the constants in the config.daml file but you will be able to use them in code.
Here is a Pro Guide on States & Conditions:
ProGuide Code Your Own States and Conditions · Esri/arcgis-pro-sdk Wiki (github.com)