<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Track user added layers in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/track-user-added-layers/m-p/348500#M9217</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for the reply Kirk.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I like your idea but I do not think our IT department will go for it. They are already very unhappy that we are creating an extension in addition to a custom toolbar so I seriously doubt they are going to let us run a service in the background on their Citrix server. Whatever solution I end up using, it has to be contained within my extension or .dll file.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Ideally, the logic my boss wants to see is: &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Track anything the user adds from the Add Data button that is on an Enterprise server (not local data), write this to an Access or Oracle table and keep a running total of how many times each particular data set is loaded so we can detect the most popular ones for inclusion on the forms.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I thought about adding a timer so that I can fire code to see what is in the TOC say every 5 minutes but I strongly suspect this would adversely affect performance as this was the case once before when I tried using timers through Citrix.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 06 Jul 2010 14:14:29 GMT</pubDate>
    <dc:creator>CarlosPiccirillo</dc:creator>
    <dc:date>2010-07-06T14:14:29Z</dc:date>
    <item>
      <title>Track user added layers</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/track-user-added-layers/m-p/348496#M9213</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi everyone,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;We have a custom toolbar with lots of forms to make loading enterprise wide data more user friendly, especially for non-GIS staff. From time to time we send out surverys asking the users if there are additional data sets they wish added to our forms. Since few people return the surveys, we thought a better way of tracking this is to see what data users are adding themselves through the Add Data button on the Standard toolbar.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My first attempt, was to create an extension and listen for the IActiveViewEvents::ItemAdded event. This works great but I get layers recorded that I do not want to track. We have predefined load sets which contain all the most common layers used by a particular group of users. Right now we have about a dozen different load sets. I already know which layers are in these load sets so I do not need to track them but IActiveViewEvents::ItemAdded tracks everything.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My second attempt was to use a customization filter to trap when the Add Data button is pressed and again this works great. However, as others have pointed out in previous posts, you cannot get anything in return from a built-in command so while I can detect the user pressing the Add Data button, I have no way of detecting what they added. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I thought about creating my own Add Data button but cannot figure out how to remove the built-in Add Data button and replace it with my own. Plus this seems like overkill.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Does anyone have an idea how to best get around this problem?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I could stick with IActiveViewEvents::ItemAdded and just ignore the layers from the load sets but was hoping for something more efficient as I suspect running queries to see if I layer has already been loaded would slow down the whole code and since the code has to run through Citrix, performance is a big issue.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Carlos&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Jul 2010 12:35:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/track-user-added-layers/m-p/348496#M9213</guid>
      <dc:creator>CarlosPiccirillo</dc:creator>
      <dc:date>2010-07-06T12:35:08Z</dc:date>
    </item>
    <item>
      <title>Re: Track user added layers</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/track-user-added-layers/m-p/348497#M9214</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This may not be the best idea, or even if it's feasible, but how about taking advantage of the default behavior of the "Add Data" Command/button?&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What I mean is that, and this may or may not be correct, but I think that particular command always adds the layer as the first one in the TOC.&amp;nbsp; Can you not use this to track the layer the user just added by getting the first layer in the TOC after the AddData command is run?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;pLayer = pMap.Layer(0)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But what if the user drags-and-drops a layer from ArcCatalog?&amp;nbsp; They may or may not drop it in the first position in the TOC.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Jul 2010 13:03:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/track-user-added-layers/m-p/348497#M9214</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2010-07-06T13:03:29Z</dc:date>
    </item>
    <item>
      <title>Re: Track user added layers</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/track-user-added-layers/m-p/348498#M9215</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;James,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for the reply. Unfortunately, it is not working correctly. The code in the customization filter detects when the Add Data button is pressed and then immediately executes your line of code before the user even adds anything to the TOC. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (pCommandItem.Name.ToString() == "File_AddData")
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
 MessageBox.Show("Add Command Executed");

 IApplication pApplication = ClsHelper.GetArcGISApplication();
 IMxDocument pMxDocument = (IMxDocument)pApplication.Document;
 IMap pMap = pMxDocument.FocusMap;
 IFeatureLayer pFeatureLayer = pMap.get_Layer(0) as IFeatureLayer;
 MessageBox.Show("Layer name: " + pFeatureLayer.FeatureClass.AliasName);
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 16:23:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/track-user-added-layers/m-p/348498#M9215</guid>
      <dc:creator>CarlosPiccirillo</dc:creator>
      <dc:date>2021-12-11T16:23:54Z</dc:date>
    </item>
    <item>
      <title>Re: Track user added layers</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/track-user-added-layers/m-p/348499#M9216</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Since you are doing this as a survey, it seems like you could have a service running in the background that periodically checks to see if arcmap is running and if so, scan to see what layers the user has in the TOC.&amp;nbsp; The service would be a standalone exe, that uses IAppROT to find arcmap instances, then IDocumentDatasets to list the datasource of each layer in the document to a log file.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Jul 2010 13:41:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/track-user-added-layers/m-p/348499#M9216</guid>
      <dc:creator>KirkKuykendall</dc:creator>
      <dc:date>2010-07-06T13:41:00Z</dc:date>
    </item>
    <item>
      <title>Re: Track user added layers</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/track-user-added-layers/m-p/348500#M9217</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for the reply Kirk.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I like your idea but I do not think our IT department will go for it. They are already very unhappy that we are creating an extension in addition to a custom toolbar so I seriously doubt they are going to let us run a service in the background on their Citrix server. Whatever solution I end up using, it has to be contained within my extension or .dll file.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Ideally, the logic my boss wants to see is: &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Track anything the user adds from the Add Data button that is on an Enterprise server (not local data), write this to an Access or Oracle table and keep a running total of how many times each particular data set is loaded so we can detect the most popular ones for inclusion on the forms.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I thought about adding a timer so that I can fire code to see what is in the TOC say every 5 minutes but I strongly suspect this would adversely affect performance as this was the case once before when I tried using timers through Citrix.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Jul 2010 14:14:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/track-user-added-layers/m-p/348500#M9217</guid>
      <dc:creator>CarlosPiccirillo</dc:creator>
      <dc:date>2010-07-06T14:14:29Z</dc:date>
    </item>
    <item>
      <title>Re: Track user added layers</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/track-user-added-layers/m-p/348501#M9218</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Carlos, &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This works for me in my class that implements ICommand/IToolControl...&amp;nbsp; Also, it works if the user clicks the Add Data button or drops a layer into the TOC from ArcCatalog.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;Public Class BFETools
Implements ESRI.ArcGIS.SystemUI.ICommand
Implements ESRI.ArcGIS.SystemUI.IToolControl
Private m_pApp As IApplication
Private WithEvents m_pActiveViewEvents As ESRI.ArcGIS.Carto.Map

'as normally, you will set your IApplication in your OnCreate Sub

Private Sub m_pActiveViewEvents_ItemAdded(ByVal Item As Object) Handles m_pActiveViewEvents.ItemAdded
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pMxDoc As IMxDocument = m_pApp.Document
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pLayer As IFeatureLayer
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pLayer = pMxDoc.FocusMap.Layer(0)

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MsgBox(pLayer.Name &amp;amp; " has been Added")
&amp;nbsp;&amp;nbsp;&amp;nbsp; End Sub&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 16:23:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/track-user-added-layers/m-p/348501#M9218</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2021-12-11T16:23:57Z</dc:date>
    </item>
    <item>
      <title>Re: Track user added layers</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/track-user-added-layers/m-p/348502#M9219</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Keep in mind a document can have more than one map,.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;An IExtension could listen for newly added mapframes and initialize a new layer listener when a new map is added.&amp;nbsp; The extension could manage a list of listeners (one for each map in the document).&amp;nbsp; Or it might be easier to just put it in the MapFrames's IElementProperties.CustomProperty, but I'd test to make sure objects are destroyed gracefully when mapframes are deleted.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums.esri.com/Thread.asp?c=93&amp;amp;f=993&amp;amp;t=246221&amp;amp;mc=2#752174"&gt;http://forums.esri.com/Thread.asp?c=93&amp;amp;f=993&amp;amp;t=246221&amp;amp;mc=2#752174&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Jul 2010 15:42:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/track-user-added-layers/m-p/348502#M9219</guid>
      <dc:creator>KirkKuykendall</dc:creator>
      <dc:date>2010-07-06T15:42:56Z</dc:date>
    </item>
    <item>
      <title>Re: Track user added layers</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/track-user-added-layers/m-p/348503#M9220</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks James,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is pretty much the code I currently have in my extension. Looks like this will be my best option to catch something being added regardless of the source, Add Data, ArcCatalog, etc.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Carlos, &lt;BR /&gt;&lt;BR /&gt;This works for me in my class that implements ICommand/IToolControl...&amp;nbsp; Also, it works if the user clicks the Add Data button or drops a layer into the TOC from ArcCatalog.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;Public Class BFETools
Implements ESRI.ArcGIS.SystemUI.ICommand
Implements ESRI.ArcGIS.SystemUI.IToolControl
Private m_pApp As IApplication
Private WithEvents m_pActiveViewEvents As ESRI.ArcGIS.Carto.Map

'as normally, you will set your IApplication in your OnCreate Sub

Private Sub m_pActiveViewEvents_ItemAdded(ByVal Item As Object) Handles m_pActiveViewEvents.ItemAdded
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pMxDoc As IMxDocument = m_pApp.Document
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pLayer As IFeatureLayer
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pLayer = pMxDoc.FocusMap.Layer(0)

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MsgBox(pLayer.Name &amp;amp; " has been Added")
&amp;nbsp;&amp;nbsp;&amp;nbsp; End Sub&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 16:24:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/track-user-added-layers/m-p/348503#M9220</guid>
      <dc:creator>CarlosPiccirillo</dc:creator>
      <dc:date>2021-12-11T16:24:00Z</dc:date>
    </item>
    <item>
      <title>Re: Track user added layers</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/track-user-added-layers/m-p/348504#M9221</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I had not considered the possibility that the user might add additional frames. I've never used a MapFrames's IElementProperties.CustomProperty so I will see if I can get that working. Thanks again!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Keep in mind a document can have more than one map,.&lt;BR /&gt;&lt;BR /&gt;An IExtension could listen for newly added mapframes and initialize a new layer listener when a new map is added.&amp;nbsp; The extension could manage a list of listeners (one for each map in the document).&amp;nbsp; Or it might be easier to just put it in the MapFrames's IElementProperties.CustomProperty, but I'd test to make sure objects are destroyed gracefully when mapframes are deleted.&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums.esri.com/Thread.asp?c=93&amp;amp;f=993&amp;amp;t=246221&amp;amp;mc=2#752174"&gt;http://forums.esri.com/Thread.asp?c=93&amp;amp;f=993&amp;amp;t=246221&amp;amp;mc=2#752174&lt;/A&gt;&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Jul 2010 16:14:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/track-user-added-layers/m-p/348504#M9221</guid>
      <dc:creator>CarlosPiccirillo</dc:creator>
      <dc:date>2010-07-06T16:14:36Z</dc:date>
    </item>
  </channel>
</rss>

