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.
<SPAN class="comment token">//1. See if the layouts have been imported to this Project</SPAN>
<SPAN class="comment token">//Reference all the layout project items</SPAN>
IEnumerable<SPAN class="operator token"><</SPAN>LayoutProjectItem<SPAN class="operator token">></SPAN> layouts <SPAN class="operator token">=</SPAN> Project<SPAN class="punctuation token">.</SPAN>Current<SPAN class="punctuation token">.</SPAN>GetItems<SPAN class="operator token"><</SPAN>LayoutProjectItem<SPAN class="operator token">></SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">//Or reference a specific layout project item by name</SPAN>
LayoutProjectItem layoutItem <SPAN class="operator token">=</SPAN> Project<SPAN class="punctuation token">.</SPAN>Current<SPAN class="punctuation token">.</SPAN>GetItems<SPAN class="operator token"><</SPAN>LayoutProjectItem<SPAN class="operator token">></SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="token function">FirstOrDefault</SPAN><SPAN class="punctuation token">(</SPAN>item <SPAN class="operator token">=</SPAN><SPAN class="operator token">></SPAN> item<SPAN class="punctuation token">.</SPAN>Name<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Equals</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"CurrentFieldMapHybrid"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">//*************************</SPAN>
<SPAN class="comment token">//*************************</SPAN>
<SPAN class="comment token">//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</SPAN>
<SPAN class="comment token">//*************************</SPAN>
<SPAN class="comment token">//*************************</SPAN>
<SPAN class="comment token">//If the layout is null, then import them</SPAN>
<SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>layoutItem <SPAN class="operator token">==</SPAN> <SPAN class="keyword token">null</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">{</SPAN>
<SPAN class="token preprocessor">#region Add new </SPAN><SPAN class="token class-name">Layout</SPAN> <SPAN class="keyword token">if</SPAN> it doesn't exist
<SPAN class="keyword token">await</SPAN> QueuedTask<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Run</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">=</SPAN><SPAN class="operator token">></SPAN>
<SPAN class="punctuation token">{</SPAN>
<SPAN class="comment token">//IProjectItem pagx = ItemFactory.Instance.Create(@"xyz\CurrentFieldMapHybrid.pagx") as IProjectItem;</SPAN>
<SPAN class="comment token">//Project.Current.AddItem(pagx);</SPAN>
IProjectMultiItem pagx <SPAN class="operator token">=</SPAN> ItemFactory<SPAN class="punctuation token">.</SPAN>Instance<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Create</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">@"xyz\CurrentFieldMapHybrid.pagx"</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">as</SPAN> IProjectMultiItem<SPAN class="punctuation token">;</SPAN>
Project<SPAN class="punctuation token">.</SPAN>Current<SPAN class="punctuation token">.</SPAN><SPAN class="token function">ImportItem</SPAN><SPAN class="punctuation token">(</SPAN>pagx<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="token preprocessor">#endregion</SPAN>
<SPAN class="punctuation token">}</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>