<?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 How to enable/disable circular referenced buttons in Add-in? (Converted from COM registered) in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-enable-disable-circular-referenced-buttons/m-p/473142#M12791</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We have to convert two COM registered command buttons to Add-in buttons.&lt;/P&gt;&lt;P&gt;When any button clicked, a&amp;nbsp;message appears and both buttons should be disabled.&lt;/P&gt;&lt;P&gt;It worked "anonymously" in COM.&amp;nbsp; In "COM" &lt;SPAN style="font-family: arial, helvetica, sans-serif;"&gt;code we have&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; private static void DisableButtons(string progId, bool isEnabled)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; {&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; UID pUID = new UID();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; pUID.Value = progId;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; ICommandItem pItem = ArcMap.Application.Document.CommandBars.Find(pUID, false, false);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; IComponentAvailable pAvailable = pItem.Command as FirstButton.IComponentAvailable;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; pAvailable.IsEnabled = isEnabled;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P&gt;In "Add-in" code we need to have AddIn.FromID() method&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; public static class AddIn&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;public static T FromID&amp;lt;T&amp;gt;(string id) where T : class;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;e.g.&amp;nbsp;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;AddIn.FromID&amp;lt;FirstButtonClass&amp;gt;(progId);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P&gt;which means we must explicitly use reference to a Class Name (FirstButtonClass, SecondButtonClass). It will create a circular reference and will not work on Bamboo deployment (However,&amp;nbsp;it builds ok on a local machine)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;case "Test_FirstButton":&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;pAvailable = AddIn.FromID&amp;lt;FirstButtonClass&amp;gt;(progId);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; break;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;case "Test_SecondButton":&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;pAvailable = AddIn.FromID&amp;lt;SecondButtonClass&amp;gt;(progId); // WE SHOULD NOT USE "SecondButtonClass" here. It will raise circular dependency&amp;nbsp;error on aBamboo deployment&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; break;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;Question: can we use another ArcObjects API to disable buttons?&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;We cannot change the architecture. Each button exists in its own .Net solution. See the attached simple projects.&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;C#, ArcObjects 10.6.1&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 11 Mar 2019 02:07:04 GMT</pubDate>
    <dc:creator>MarkMindlin</dc:creator>
    <dc:date>2019-03-11T02:07:04Z</dc:date>
    <item>
      <title>How to enable/disable circular referenced buttons in Add-in? (Converted from COM registered)</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-enable-disable-circular-referenced-buttons/m-p/473142#M12791</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We have to convert two COM registered command buttons to Add-in buttons.&lt;/P&gt;&lt;P&gt;When any button clicked, a&amp;nbsp;message appears and both buttons should be disabled.&lt;/P&gt;&lt;P&gt;It worked "anonymously" in COM.&amp;nbsp; In "COM" &lt;SPAN style="font-family: arial, helvetica, sans-serif;"&gt;code we have&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; private static void DisableButtons(string progId, bool isEnabled)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; {&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; UID pUID = new UID();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; pUID.Value = progId;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; ICommandItem pItem = ArcMap.Application.Document.CommandBars.Find(pUID, false, false);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; IComponentAvailable pAvailable = pItem.Command as FirstButton.IComponentAvailable;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; pAvailable.IsEnabled = isEnabled;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P&gt;In "Add-in" code we need to have AddIn.FromID() method&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; public static class AddIn&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;public static T FromID&amp;lt;T&amp;gt;(string id) where T : class;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;e.g.&amp;nbsp;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;AddIn.FromID&amp;lt;FirstButtonClass&amp;gt;(progId);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P&gt;which means we must explicitly use reference to a Class Name (FirstButtonClass, SecondButtonClass). It will create a circular reference and will not work on Bamboo deployment (However,&amp;nbsp;it builds ok on a local machine)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;case "Test_FirstButton":&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;pAvailable = AddIn.FromID&amp;lt;FirstButtonClass&amp;gt;(progId);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; break;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;case "Test_SecondButton":&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;pAvailable = AddIn.FromID&amp;lt;SecondButtonClass&amp;gt;(progId); // WE SHOULD NOT USE "SecondButtonClass" here. It will raise circular dependency&amp;nbsp;error on aBamboo deployment&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; break;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;Question: can we use another ArcObjects API to disable buttons?&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;We cannot change the architecture. Each button exists in its own .Net solution. See the attached simple projects.&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;C#, ArcObjects 10.6.1&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Mar 2019 02:07:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-enable-disable-circular-referenced-buttons/m-p/473142#M12791</guid>
      <dc:creator>MarkMindlin</dc:creator>
      <dc:date>2019-03-11T02:07:04Z</dc:date>
    </item>
  </channel>
</rss>

