Select to view content in your preferred language

Refresh homefolder/catalog to see newly added contents

1837
6
Jump to solution
01-31-2021 04:59 PM
PrashantKirpan
Frequent Contributor

Hi,

I've created ArcPro Add-in in C# and added folder under home folder and copying project related content into it.

After adding folder I'm activating Catlog pane. If my project home folder is already in open state then i can't see newly added folder. I need to manually click on folder/homefolder location and hit refresh command.

Is there any way I can programmatically refresh homefolder/folder to see updated contents?

Any help would be appreciated.

Regards,

Prashant 

 

 

 

 

 

0 Kudos
1 Solution

Accepted Solutions
KirkKuykendall1
Frequent Contributor

I guess Esri might change internal interfaces in future releases, but typically once an interface is defined it's not supposed to change (?)

This works for me:

foreach (var itm in Project.Current.Items.OfType<FolderConnectionProjectItem>())
{
    ((ArcGIS.Desktop.Internal.Core.IItemInternal)itm).RefreshChildren();
}

View solution in original post

6 Replies
FredericPoliart_EsriAU
Frequent Contributor

Hi 

You may be able to invoke esri_itemInfoRefreshButton manually,  but you would have to specify which folder.   There could also be an "invalidate" command, which would force your Catalog to refresh/reload the newly added folders.    

https://github.com/Esri/arcgis-pro-sdk-community-samples/blob/master/Map-Exploration/IdentifyWindow/... 

FredericPoliart_EsriAU_0-1612141395764.png

 

0 Kudos
PrashantKirpan
Frequent Contributor

Hi,

I tried to execute below code but CanExecute returning false so unable to execute command. Also not sure how to specify folder to execute command? Could you please provide any sample?

var commandId = @"esri_itemInfoRefreshButton";
var iCommand = FrameworkApplication.GetPlugInWrapper(commandId) as ICommand;
if (iCommand != null)
{
  if (iCommand.CanExecute(null))
  {
    iCommand.Execute(null);
  }
}

-Prashant

0 Kudos
FredericPoliart_EsriAU
Frequent Contributor

The following sample has similar  FrameworkApplication.GetPlugInWrapper() commands:
https://github.com/Esri/arcgis-pro-sdk-community-samples/tree/master/Framework/HookProCommands

but I agree, you would need to specify which sub-folder you are targeting (for the refresh)

0 Kudos
PrashantKirpan
Frequent Contributor

Hi,

I tried to execute refresh command in same project but still CanExecute returning false value. Exit application/Bookmark are working fine.

Could you please help me out to set target for refresh command? 

 

 protected override void OnClick()
        { 
            var commandId = FrameworkApplication.GetPlugInWrapper(@"esri_core_exitApplicationButton") as ICommand;
            if (commandId != null)
            {
                if (commandId.CanExecute(null))
                    commandId.Execute(null);
            }

            var commandId1 = FrameworkApplication.GetPlugInWrapper(@"esri_itemInfoRefreshButton") as ICommand;
            if (commandId1 != null)
            {
                if (commandId1.CanExecute(null))
                    commandId1.Execute(null);  /******** Not Executing ***********/
            }
        }

 

-Prashant

0 Kudos
KirkKuykendall1
Frequent Contributor

I guess Esri might change internal interfaces in future releases, but typically once an interface is defined it's not supposed to change (?)

This works for me:

foreach (var itm in Project.Current.Items.OfType<FolderConnectionProjectItem>())
{
    ((ArcGIS.Desktop.Internal.Core.IItemInternal)itm).RefreshChildren();
}
PrashantKirpan
Frequent Contributor

Thank you @KirkKuykendall1 , Perfectly working 👍