Here's a short example
The Commands class
public class Commands
{
[CommandMethod("PC")]
public void Pc()
{
// here the code of the PC command
}
[CommandMethod("Method1")]
public void Method1()
{
// here the code of the Method1 command
}
[CommandMethod("Method2")]
public void Method2()
{
// here the code of the Method2 command
}
[CommandMethod("Method3")]
public void Method3()
{
// here the code of the Method3 command
}
[CommandMethod("Method4")]
public void Method4()
{
// here the code of the Method4 command
}
[CommandMethod("TEST")]
public void Test()
{
// here the code of the TEST command
}
static CustomPaletteSet palette;
[CommandMethod("CMDPALETTE")]
public void CmdPalette()
{
if (palette == null)
palette = new CustomPaletteSet();
palette.Visible = true;
}
}
The Palettetab class (UserControl) with the buttons event handlers
public partial class PaletteTab : UserControl
{
public PaletteTab()
{
InitializeComponent();
}
private void btnPc_Click(object sender, EventArgs e)
{
var doc = AcAp.DocumentManager.MdiActiveDocument;
if (doc != null)
doc.SendStringToExecute("PC ", false, false, true);
}
private void btnMethod1_Click(object sender, EventArgs e)
{
var doc = AcAp.DocumentManager.MdiActiveDocument;
if (doc != null)
doc.SendStringToExecute("Method1 ", false, false, true);
}
private void btnMethod2_Click(object sender, EventArgs e)
{
var doc = AcAp.DocumentManager.MdiActiveDocument;
if (doc != null)
doc.SendStringToExecute("Method2 ", false, false, true);
}
private void btnMethod3_Click(object sender, EventArgs e)
{
var doc = AcAp.DocumentManager.MdiActiveDocument;
if (doc != null)
doc.SendStringToExecute("Method3 ", false, false, true);
}
private void btnMethod4_Click(object sender, EventArgs e)
{
var doc = AcAp.DocumentManager.MdiActiveDocument;
if (doc != null)
doc.SendStringToExecute("Method4 ", false, false, true);
}
private void btnTest_Click(object sender, EventArgs e)
{
var doc = AcAp.DocumentManager.MdiActiveDocument;
if (doc != null)
doc.SendStringToExecute("TEST ", false, false, true);
}
}
The CustomPaletteSet class
public class CustomPaletteSet : PaletteSet
{
public CustomPaletteSet()
: base("COMMANDS", "CMDPALETTE", new Guid("{CB44AAE8-B3C8-4F97-817B-D5F96FDB3C1C}"))
{
Style = PaletteSetStyles.ShowAutoHideButton |
PaletteSetStyles.ShowCloseButton |
PaletteSetStyles.ShowPropertiesMenu;
MinimumSize = new System.Drawing.Size(150, 220);
Add("Tab", new PaletteTab());
}
}