using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Ribbon;
using Autodesk.AutoCAD.Runtime;
using Autodesk.Windows;
using System;
using System.Reflection;
using System.Windows.Controls;
using System.Windows.Media.Imaging;
[assembly
: CommandClass
(typeof(FooRibbon
.Commands))]
namespace FooRibbon
{
public class Commands
{
private Editor ed =
Application.DocumentManager.MdiActiveDocument.Editor;
[CommandMethod("FooRIbbon")]
public void FooRibbon()
{
try
{
RibbonControl oRibbon = ComponentManager.Ribbon;
if (oRibbon != null)
{
RibbonTab oTab = oRibbon.FindTab("FooTabId");
if (oTab != null)
{
oTab.IsActive = true;
}
else
{
oTab.Title = "FOO";
oTab.Id = "FOO_RIBBONTAB";
oTab.IsVisible = true;
oRibbon.Tabs.Add(oTab);
oTab.IsActive = true;
// <-- Add custom ribbon panel(s) here
}
}
}
catch (Autodesk.AutoCAD.Runtime.Exception ex)
{
ed.WriteMessage("\n** AutoCAD Error: " + ex.Message + " ** ");
}
catch (System.Exception ex)
{
ed.WriteMessage("\n** System Error: " + ex.Message + " ** ");
}
}
public class HelpRibbonPanel : RibbonPanel
{
public static RibbonPanel GetItem()
{
// Define HelpRibbonPanel
return HelpRibbonPanel;
}
}
// Same sort of thing for HelpRibbonButton
}