1,支持cui和cuix。
2,菜单组重复加载或显示,C#下都会崩溃。所以要判断。
3,菜单加到最后。
public static AcadMenuGroup LoadMenu(AcadMenuGroups menuGroups, string filepath)
{
if( null == menuGroups )
{
return null;
}
if (!System.IO.File.Exists(filepath))
{
return null;
}
//如果已经加载则直接返回
string strMenuGroupName = System.IO.Path.GetFileNameWithoutExtension(filepath);
for (int i = 0; i < menuGroups.Count; i++)
{
AcadMenuGroup menuGroup = menuGroups.Item(i);
if (menuGroup.Name.Equals(strMenuGroupName, StringComparison.OrdinalIgnoreCase))
{
return menuGroup;
}
}
return menuGroups.Load(filepath);
}
protected void LoadMenu(AcadApplication acadapp,string filepath)
{
AcadMenuGroup menuGroup = LoadMenu(acadapp.MenuGroups,filepath);
if (null == menuGroup)
{
return;
}
//菜单栏 各popMenu的标题
List<string> names = new List<string>();
for (int i = 0; i < acadapp.MenuBar.Count; i++)
{
names.Add(acadapp.MenuBar.Item(i).Name);
}
for (int i = 0; i < menuGroup.Menus.Count; i++)
{//依次加到最后
AcadPopupMenu popMenu = menuGroup.Menus.Item(i);
if (-1 != names.IndexOf(popMenu.Name))
{//已经加载
continue;
}
popMenu.InsertInMenuBar(i + acadapp.MenuBar.Count);
}
}