Hi Guys,
I want to load/initialize the ribbon bar button after the module is intialized.
So I set loadOnClick="false" property on button control in daml.
And I add a few code at constructor.
However the constructor only call when the tab is activated.
So how shall I force the button to load upon project is loaded.
If the tab which hold the button need to be activated, how shall I achieve it? Uma Harano Wolfgang Kaiser
I am using pro 2.5.
Solved! Go to Solution.
You can get the IPluginWrapper interface by using the button's ID from the config.daml. Below is the snippet that i added to my test add-in's Module class:
protected override bool Initialize ()
{
ActiveMapViewChangedEvent.Subscribe(OnActiveMapViewChanged);
return base.Initialize();
}
/// <summary>
/// Event delegate for the ActiveMapViewChangedEvent
/// </summary>
private void OnActiveMapViewChanged(ActiveMapViewChangedEventArgs args)
{
// get the button and change the caption
// button's id from config.daml: DynamicButtonChange_ButtonMapLoaded
var plugin = FrameworkApplication.GetPlugInWrapper("DynamicButtonChange_ButtonMapLoaded");
if (args.IncomingView == null)
{
plugin.Caption = "No Mapview";
// plugin.LargeImage = ...
return;
}
plugin.Caption = "Active Mapview";
// plugin.LargeImage = ...
}
Hi Than,
You can look here for an explanation: https://github.com/Esri/arcgis-pro-sdk/wiki/ProConcepts-Framework#jit-loading In essence Pro is using JIT (Just in time) loading to make Pro be more responsive at startup. However, if you need your add-in to start with Pro then you can change the autoLoad attribute of the module tag to "true" in your config.daml:
<insertModule id="yourmoduleId" className="..." autoLoad="true" caption="...">
Thank for your reply Wolfgang Kaiser,
It seems, I shall need to explain full scenario.
The one I want to achieve is that when user load/open the project, If the active view is map view, based on the certain condition the ribbon bar button will have different image and captions.
Related to the tab group changing colour post you answer before, I have to determine condition and switch the tab group as well.
I have no idea how to retrieve the specific ribbon button instance from Module instance, I manage the changing of button image and caption in the button class instance itself. So the condition/state for managing switching tab group and switching the image and caption of the ribbon button are the same.
And upon ribbon button click, the message result of those conditional check shall display.
So I tried and initialised the button instance once the module is initialized. (That I want to achieve)
But right now, I add the boolean switch in module class to monitor button instance is initiated. Before button initiated, all the task to do checking condition/state is performed in module instance (of course button image/caption will not manage). So I did turn on autoload to true for the module as well.
Any advice?
You can get the IPluginWrapper interface by using the button's ID from the config.daml. Below is the snippet that i added to my test add-in's Module class:
protected override bool Initialize ()
{
ActiveMapViewChangedEvent.Subscribe(OnActiveMapViewChanged);
return base.Initialize();
}
/// <summary>
/// Event delegate for the ActiveMapViewChangedEvent
/// </summary>
private void OnActiveMapViewChanged(ActiveMapViewChangedEventArgs args)
{
// get the button and change the caption
// button's id from config.daml: DynamicButtonChange_ButtonMapLoaded
var plugin = FrameworkApplication.GetPlugInWrapper("DynamicButtonChange_ButtonMapLoaded");
if (args.IncomingView == null)
{
plugin.Caption = "No Mapview";
// plugin.LargeImage = ...
return;
}
plugin.Caption = "Active Mapview";
// plugin.LargeImage = ...
}
That's great Wolfgang Kaiser,
That help me centralize the state management in module class.
And one interesting part is that that trigger the button class instantiation as well. Not require to click tab.