Public ReadOnly Property Items As ReadOnlyObservableCollection(Of Item)
public ReadOnlyObservableCollection<Item> Items {get;}
Public ReadOnly Property Items As ReadOnlyObservableCollection(Of Item)
public ReadOnlyObservableCollection<Item> Items {get;}
Returns the current collection of project items: the maps, layouts, toolboxes, databases, folder connections, locators, and so on that have been added to the project.
A folder connection is a project item. Subfolders and files accessed using a folder connection are items, but are not project items; they have not been added to a project. Similarly, databases that have been added to a project are project items, but databases accessed from a folder connection are items. The items within a database are always items, not project items.
{
string openProjectPath = @"D\DATA\IGPHistoryItemTestProject\IGPHistoryItemTestProject.aprx";
Project.OpenAsync(openProjectPath);
MapProjectItem mapProjItem = Project.Current.GetItems<MapProjectItem>().FirstOrDefault(item => item.Name.Equals("Map", StringComparison.CurrentCultureIgnoreCase));
// Note: Needs QueuedTask to run
var map = mapProjItem.GetMap();
var ftrLayer = map.Layers[0] as FeatureLayer;
string tool1 = "management.GetCount";
var args1 = Geoprocessing.MakeValueArray(ftrLayer);
var env = Geoprocessing.MakeEnvironmentArray(overwriteoutput: true);
GPExecuteToolFlags executeFlags = GPExecuteToolFlags.AddToHistory;
var t = Geoprocessing.ExecuteToolAsync(tool1, args1, env, null, null, executeFlags);
IEnumerable<IGPHistoryItem> hisItems = Project.Current.GetProjectItemContainer(Geoprocessing.HistoryContainerKey) as IEnumerable<IGPHistoryItem>;
string hitemID = "";
string hitemToolPath = "";
IGPResult hitemGPResult = null;
DateTime hitemTimeStamp;
foreach (var hitem in hisItems)
{
// common IGPHistoryItem and Item properties
hitemID = (hitem as Item).ID;
hitemToolPath = hitem.ToolPath;
hitemGPResult = hitem.GPResult;
hitemTimeStamp = hitem.TimeStamp;
// use the properties as needed
}
}
Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)