Thanks Geert,
i tried it and it's working fine, here is my code:
using System;
using System.Windows.Forms;
namespace EA_Banana_AddIn
{
public class Main
{
private bool m_ShowFullMenus = false;
private bool banana = false;
public String EA_Connect(EA.Repository Repository)
{
this.banana = true;
//No special processing required.
return "a string";
}
//Called when user Click Add-Ins Menu item from within EA.
//Populates the Menu with our desired selections.
public object EA_GetMenuItems(EA.Repository Repository, string Location, string MenuName)
{
EA.Package aPackage = Repository.GetTreeSelectedPackage();
switch( MenuName )
{
case "":
return "-&Banana";
case "-&Banana":
string[] ar = {"Banana Test"};
return ar;
}
return "";
}
//Sets the state of the menu depending if there is an active project or not
bool IsProjectOpen(EA.Repository Repository)
{
try
{
EA.Collection c = Repository.Models;
return true;
}
catch
{
return false;
}
}
//Called once Menu has been opened to see what menu items are active.
public void EA_GetMenuState(EA.Repository Repository, string Location, string MenuName, string ItemName, ref bool IsEnabled, ref bool IsChecked)
{
if( IsProjectOpen(Repository) )
{
if( ItemName == "Menu1" )
IsChecked = m_ShowFullMenus;
else if( ItemName == "Menu2")
IsEnabled = m_ShowFullMenus;
}
else
// If no open project, disable all menu options
IsEnabled = false;
}
//Called when user makes a selection in the menu.
//This is your main exit point to the rest of your Add-in
public void EA_MenuClick(EA.Repository Repository, string Location, string MenuName, string ItemName)
{
switch (ItemName)
{
case "Banana Test":
MessageBox.Show("It's "+this.banana+" that bananas are tasteful.", "Hint", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
break;
}
}
}
}
Cheers
Kai