Hi there,
how can I write an add-in that shows a Message Box when the project is loaded? I want to give the user some new informations, when he starts a new project?
Thanks,
Karsten
Solved! Go to Solution.
Hi,
You can subscribe to the ProjectOpenedEvent (topic9319) to accomplish this. Additionally, the add-in will need to load as soon as Pro launches, so you will have to set the "autoload" attribute to true in the config.daml of the add-in. Code snippets below:
In the Module class of the add-in:
protected override bool Initialize()
{
ProjectOpenedEvent.Subscribe(OnProjectOpened); //subscribe to event
return base.Initialize();
}
private void OnProjectOpened(ProjectEventArgs obj)
{
MessageBox.Show($"{Project.Current} has opened"); //show your message box
}
protected override void Uninitialize()
{
ProjectOpenedEvent.Unsubscribe(OnProjectOpened); //unsubscribe
return;
}
In your config.daml, set the autoload attribute to true so that the add-in loads when Pro launches:
...
<modules>
<insertModule id="SubscribeProjectLoad_Module" className="Module1" autoLoad="true" caption="Module1">
...
Thanks
Uma
Hi,
You can subscribe to the ProjectOpenedEvent (topic9319) to accomplish this. Additionally, the add-in will need to load as soon as Pro launches, so you will have to set the "autoload" attribute to true in the config.daml of the add-in. Code snippets below:
In the Module class of the add-in:
protected override bool Initialize()
{
ProjectOpenedEvent.Subscribe(OnProjectOpened); //subscribe to event
return base.Initialize();
}
private void OnProjectOpened(ProjectEventArgs obj)
{
MessageBox.Show($"{Project.Current} has opened"); //show your message box
}
protected override void Uninitialize()
{
ProjectOpenedEvent.Unsubscribe(OnProjectOpened); //unsubscribe
return;
}
In your config.daml, set the autoload attribute to true so that the add-in loads when Pro launches:
...
<modules>
<insertModule id="SubscribeProjectLoad_Module" className="Module1" autoLoad="true" caption="Module1">
...
Thanks
Uma