Hi,
is it possible to put an ArcGIS.Desktop.Framework.Dialogs.MessageBox in front of the "Closing Project" MessageBox?
Thanks Karsten
Solved! Go to Solution.
Hi Karsten,
I tried the following code which seemed to work fine. In essence i subscribe to the Project Closing event in my module class and execute your MessageBox logic in the subscription method.
First i changed the autoLocad property in the insertModule tag in my config.daml to true:
<modules>
<insertModule id="ProjClosing_Module" className="Module1"
autoLoad="true" caption="Module1">
....
</insertModule>
</modules>
This will ensure that my add-in is initialized regardless of any UI interactions.
In the Module's Initialize override i subscribe to the Project Closing event, and in OnProjectClosing i do the customization including the MessageBox.
protected override bool Initialize()
{
ArcGIS.Desktop.Core.Events.ProjectClosingEvent.Subscribe(OnProjectClosing);
return base.Initialize();
}
/// <summary>
/// Event handler for ProjectClosing event.
/// </summary>
/// <param name="args">The ProjectClosing arguments.</param>
/// <returns></returns>
private Task OnProjectClosing(ArcGIS.Desktop.Core.Events.ProjectClosingEventArgs args)
{
// if already canceled, ignore
if (args.Cancel)
return Task.CompletedTask;
var targetProjFolder = @"c:\temp";
var result = MessageBox.Show($@"Soll das aktuelle Projekt in ein anderes Verzeichnis als {targetProjFolder} kopiert werden ?", "Projekt sichern", System.Windows.MessageBoxButton.YesNoCancel, System.Windows.MessageBoxImage.Question);
return Task.CompletedTask;
}
the Project closing messagebox doesn't show up until after i answer the popup messagebox.
Hope this helps,
Wolf
Hi Karsten, what is the workflow that you try to accomplish, in order words what event triggers the MessageBox that occurs with the 'Closing Project' message box?
I check the project path and if a part of that is set in the options, a MessageBox appears. The user can choose if the set save path in the options is right or not, can cancel the action.
How to call the MessageBox to show it always in foreground (right image)?
static void closedProject()
{
...
if (appSettings.GeneralSetting1 == true && appSettings.GeneralSetting2 == sourceProjFolder.Substring(0, lensourceAppFolder))
{MessageBoxResult result = ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("Soll das aktuelle Projekt in ein anderes Verzeichnis als " + targetProjFolder + " kopiert werden ?", "Projekt sichern", System.Windows.MessageBoxButton.YesNoCancel, System.Windows.MessageBoxImage.Question);
Hi Karsten,
I tried the following code which seemed to work fine. In essence i subscribe to the Project Closing event in my module class and execute your MessageBox logic in the subscription method.
First i changed the autoLocad property in the insertModule tag in my config.daml to true:
<modules>
<insertModule id="ProjClosing_Module" className="Module1"
autoLoad="true" caption="Module1">
....
</insertModule>
</modules>
This will ensure that my add-in is initialized regardless of any UI interactions.
In the Module's Initialize override i subscribe to the Project Closing event, and in OnProjectClosing i do the customization including the MessageBox.
protected override bool Initialize()
{
ArcGIS.Desktop.Core.Events.ProjectClosingEvent.Subscribe(OnProjectClosing);
return base.Initialize();
}
/// <summary>
/// Event handler for ProjectClosing event.
/// </summary>
/// <param name="args">The ProjectClosing arguments.</param>
/// <returns></returns>
private Task OnProjectClosing(ArcGIS.Desktop.Core.Events.ProjectClosingEventArgs args)
{
// if already canceled, ignore
if (args.Cancel)
return Task.CompletedTask;
var targetProjFolder = @"c:\temp";
var result = MessageBox.Show($@"Soll das aktuelle Projekt in ein anderes Verzeichnis als {targetProjFolder} kopiert werden ?", "Projekt sichern", System.Windows.MessageBoxButton.YesNoCancel, System.Windows.MessageBoxImage.Question);
return Task.CompletedTask;
}
the Project closing messagebox doesn't show up until after i answer the popup messagebox.
Hope this helps,
Wolf