Add Layouts in Background to Project/Catalog

1357
11
Jump to solution
08-20-2018 06:34 AM
MKa
by
Occasional Contributor III

I want to add some layouts to my project from the code.  I have about 4 different export templates that I plan to use in a project, so if a user wants to export a selected Item, they select export, the code finds the layout from the Project-->Layouts, updates the text/map elements and saves or shows a pdf to the user.

The problem, is that i want to add these 4 Layouts to a users project if they don't exist.  I plan on putting the pagx files in the config.x file, then on loading a project I will add them to the layouts for a project if they don't exist.  But when I do this, it "Auto" opens the layout when I use additem or import item from the Project tools.  I just want them to be added in the background?   This code below adds the items to layout, but it also opens up the layout tabs for each, which i don't want.  

//1. See if the layouts have been imported to this Project
//Reference all the layout project items
IEnumerable<LayoutProjectItem> layouts = Project.Current.GetItems<LayoutProjectItem>();

//Or reference a specific layout project item by name
LayoutProjectItem layoutItem = Project.Current.GetItems<LayoutProjectItem>().FirstOrDefault(item => item.Name.Equals("CurrentFieldMapHybrid"));

//*************************
//*************************
//THIS BELOW ADDS THE LAYOUT TO THE CATALOG, BUT OPENS UP THE LAYOUT TABS.  I JUST WANT THEM ADDED TO THE LAYOUT CATALOG.  BOTH AddItem AND ImportItem do this
//*************************
//*************************
                //If the layout is null, then import them
                if (layoutItem == null)
                {
                    #region Add new Layout if it doesn't exist

                    await QueuedTask.Run(() =>
                    {
                        //IProjectItem pagx = ItemFactory.Instance.Create(@"xxxxx\CurrentFieldMapHybrid.pagx") as IProjectItem;
                        //Project.Current.AddItem(pagx);

                        IProjectMultiItem pagx = ItemFactory.Instance.Create(@"xxxxx\CurrentFieldMapHybrid.pagx") as IProjectMultiItem;
                        Project.Current.ImportItem(pagx);
                    });

                    #endregion
                }‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
Tags (1)
0 Kudos
11 Replies
MKa
by
Occasional Contributor III

When will 2.3 be released.  I would like to get my users on the latest version, as they are still on 2.1.2.  But if you are planning a new release soon, i might wait.

0 Kudos
JeffBarrette
Esri Regular Contributor

2.3 isn't planned for release until the start of 2019.

Jeff