Hey all,
I'm currently capturing the project open event to process some data, it's currently possible to determine if the project has been created from a template through the ProjectOpenMode enum, what I am trying to do is retrieve the path of template that was used but can't seem to find any events or data within the Project.Items that would point to the template path.
What I've tried:
var items = obj.Project.Items;
Checking all project items for the template name or path
var temp = Project.GetRecentProjectTemplates();
Getting the recent project templates, but this is only updated after its been used, I could work-around this by capturing it from the save event instead but it wouldn't be my first choice as it'd be a little messy
I've also tried something along the lines of:
var rtc = new RecentTemplatesControl();
rtc.SelectedTemplateChanged += OnSelectedTemplateChanged;
but naturally this didn't work because its not the actual reference to the control UI
Is there something I'm overlooking here?
Thanks,
Curtis
Hi,
Start listening to OnProjectOpened event. You will find project path in ProjectEventArgs parameter.
private void OnProjectOpened(ProjectEventArgs obj) //Project Opened event handler
{
MessageBox.Show($"{obj.Project.Path} has opened"); //show project path
}
Hi GKmieliauskas,
I'm actually looking for the template path that was loaded APTX, not the project path APRX.
My work around for this involves tracking the project load event and the project save event
looks like the following
private void OnProjectSaved(ProjectEventArgs obj)
{
_lastLoadedProject.ArcGisTemplate.FilePath = Project.GetRecentProjectTemplates()[^1];
but I was hoping for a better way to handle this
You can call GetRecentProjectTemplates() and from ProjectEventArgs parameter directly:
private void OnProjectOpened(ProjectEventArgs obj) //Project Opened event handler
{
_lastLoadedProject.ArcGisTemplate.FilePath = obj.Project.GetRecentProjectTemplates()[^1];
}
Unfortunately the RecentProjectTemplates gets updated after the project has been opened, which is why I'm capturing it in the save event.
Thanks for your time appreciate the response, seems as though I'll just have to capture it on the save event unfortunately.