I create the palette dialog at last. But I meet a new issue. I can load the dialog at first time. When I close it, I can run it again. Could anyone help me? I open a new file. It can be used by type "Leodock" in the commanf again.
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Windows;
using Autodesk.AutoCAD.Runtime;
namespace CsMgdAcad1
{
public class ModelessForm: System.Windows.Forms.UserControl
{
private System.Windows.Forms.Label label1;
private System.ComponentModel.Container components = null;
public ModelessForm()
{
}
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// label1
//
this.label1.Location = new System.Drawing.Point(0, 32);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(128, 64);
this.label1.TabIndex = 0;
this.label1.Text = "Leo Li. Hello World!";
//
// ModelessForm
//
this.Controls.Add(this.label1);
this.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.Name = "ModelessForm";
this.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.Size = new System.Drawing.Size(128, 136);
this.ResumeLayout(false);
}
#endregion
private void ModelessForm_Load(object sender, System.EventArgs e)
{
}
private Autodesk.AutoCAD.Windows.PaletteSet ps;
[CommandMethod("leodock")]
public void testPalette()
{
if(ps == null)
{
ps = new Autodesk.AutoCAD.Windows.PaletteSet("Leo Li's first docking palette");
ps.Style = PaletteSetStyles.ShowCloseButton;
ps.Opacity = 90;
ps.MinimumSize = new System.Drawing.Size(300, 300);
System.Windows.Forms.UserControl myCtrl = new ModelessForm();
ps.Add("Leo", myCtrl);
ps.Visible = true;
}
}
}
}