How to create a custom panel?

Hi,

I would like to create a custom panel, i.e. a little window that can be docked to the left or right side and show a treeview list of items, like the structure panel. I'll be finde to fill the panel, however I need to the starting point. For example, what is the container object to put the control into? If anyone has a little example for this, I would be very grateful!

Thanks

Comments

  • Which API will you be using?

  • @Roy Klein Gebbinck said:
    Which API will you be using?

    I will be using the .Net Api, developing in C#/Visual Studio. Sorry, I forgot to mention that.

  • Hi,

    You can use a PaletteSet with a UserControl (palette tab) containing your TreeView.

    Here's a simple example, The CustomPaletteSet class inherits from PaletteSet.
    It contains an instance of TreeViewTab class, the custom class derived from UserControl which contains your TreeView control.

    using System;
    
    using Bricscad.Windows;
    
    namespace BricscadPaletteSample
    {
        /// <summary>
        /// Describes a custom palette set
        /// </summary>
        public class CustomPaletteSet : PaletteSet
        {
            /// <summary>
            /// Creates a new instance of CustomPalette 
            /// SHOW_PALETTE is the name of the command used to set the palette visible
            /// </summary>
            public CustomPaletteSet() : base("SHOW_PALETTE", new Guid("{0CF42D05-06C0-4D77-9648-04E293538098}"))
            {
                Name = "Palette";
                Style = PaletteSetStyles.ShowAutoHideButton |
                        PaletteSetStyles.ShowCloseButton |
                        PaletteSetStyles.ShowPropertiesMenu;
                MinimumSize = new System.Drawing.Size(250, 150);
                Dock = DockSides.Left;
    
                // add a palette tab (derived from System.Windows.Forms.UserControl) to the palette set
                Add("Tree View", new TreeViewTab());
            }
        }
    }
    

    The Commands class where the command to set the palette visible is defined

    using Bricscad.Windows;
    
    using Teigha.Runtime;
    
    namespace BricscadPaletteSample
    {
        public class Commands
        {
            static PaletteSet palette;
    
            [CommandMethod("SHOW_PALETTE")]
            public static void ShowPalette()
            {
                if (palette == null)
                    palette = new CustomPaletteSet();
                palette.Visible = true;
            }
        }
    }