By Deepak Nadig
This is my first post of 2017 and here is wishing you all a "Happy New Year" :-)
Recently, we had a query from an ADN partner:
How to roll up a docked and hidden custom PaletteSet using.NET API ?
The behaviour the ADN partner is expecting to be accomplished using .NET API can be seen in the below screencast:
With the help of my colleague Madhu, we figured out the answer is to set PaletteSet.RolledUp to false.
In the below code, command MyPalette launches a docked palette and command ExpandPalette rolls up the palette. Subsequently, screencast shows the testing of the code.
public class MyCommands { static System.Windows.Forms.Timer Clock; public static PaletteSet m_ps = null; [CommandMethod("MyPalette")] public void MyPalette() { if (m_ps == null) { m_ps = new PaletteSet("My Palette 1", new Guid("170B0084-7B01-487E-9CBC-C7018588F26F")); m_ps.SetLocation(new System.Drawing.Point(312, 763)); m_ps.SetSize(new System.Drawing.Size(909, 40)); m_ps.DockEnabled = DockSides.Bottom; if (m_ps.Dock == DockSides.None) { m_ps.AutoRollUp = true; m_ps.Visible = false; m_ps.Visible = true; } // If the palette is docked, // we need to undock it first. else { m_ps.Visible = false; m_ps.Visible = true; CreateTimer(); } } m_ps.Visible = true; } public static void CreateTimer() { Clock = new System.Windows.Forms.Timer(); Clock.Interval = 500; Clock.Start(); Clock.Tick += new EventHandler(Timer_Tick); } static public void Timer_Tick(object sender, EventArgs eArgs) { if (sender == Clock) { m_ps.Dock = DockSides.None; m_ps.AutoRollUp = true; m_ps.Dock = DockSides.Left; // Note: we need to update the palette // window. I found turning it off and // on is the most robust way. m_ps.Visible = false; m_ps.Visible = true; // Stop the clock and destroy it. Clock.Stop(); Clock.Dispose(); } } [CommandMethod("ExpandPalette")] public static void CheckPaletteSetState() { if (m_ps != null) { m_ps.RolledUp = false; } } }
Screencast :
Recent Comments