For those new to C# and the arx .net api I thought I'd post a very simple dockable palette application to get you started.
So here goes -
1) Create a new class library application, add references to the 2 AutoCAD managed dll's, the Systym.Windows.Forms.dll and the System.Drawing dll.
2) Create 2 new UserControls, call them what you like but here I've used default names.
3) To each UserControl, add 1 button, to each button add some code to handle the click event (tip. double click the control in the ide)
4) Create a command to load up our palette and show it in AutoCAD.
5) Compile, load and give it a run.
Below is the typical code used to set up and load your palette, I've attached the solution (VS2002) for AutoCAD 2006, I'm sure it would take very little to compile in 2007.
using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using System.Collections;
using System.Data;
using System.Data.OleDb;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.GraphicsInterface;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Windows.ToolPalette;
namespace ClassLibrary1
{
/// <summary>
/// Summary description for Class1.
/// </summary>
public class Class1
{
public Class1()
{
//
// TODO: Add constructor logic here
//
}
private Autodesk.AutoCAD.Windows.PaletteSet ps;
[CommandMethod("MyPalette")]
public void CreateMyPalette()
{
if(ps == null)
{
ps = new Autodesk.AutoCAD.Windows.PaletteSet("My Palette");
ps.Style = Autodesk.AutoCAD.Windows.PaletteSetStyles.ShowPropertiesMenu
| Autodesk.AutoCAD.Windows.PaletteSetStyles.ShowAutoHideButton
| Autodesk.AutoCAD.Windows.PaletteSetStyles.ShowCloseButton;
ps.Opacity = 90;
ps.Size = new System.Drawing.Size(250,400);
ps.MinimumSize = new System.Drawing.Size(225, 400);
//ctrl.Dock = System.Windows.Forms.DockStyle.Fill;
ps.Add("My Controls 1", new UserControl1());
ps.Add("My Controls 2", new UserControl2());
ps.Dock = Autodesk.AutoCAD.Windows.DockSides.None;
//You may or may not need the below code for list/combo boxes to retain focus.
//ps.KeepFocus = true;
ps.Visible = true;
}
else
{
ps.Visible = true;
}
}
}
}
Some typical code for the button event handler -
private void button1_Click(object sender, System.EventArgs e)
{
MessageBox.Show("Activated Button 1 on User control 1!");
}
You may also need Document locking for times when you need to go to and from the editor, I'll post some typical code later, absorb this for now and if you have any questions, ask away