/// <summary>
        ///     Dispose of resources used by the designer tool window.
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            try
            {
                if (disposing)
                {
                    SystemEvents.UserPreferenceChanged -= OnUserPreferenceChanged;
                    VSColorTheme.ThemeChanged -= VSColorTheme_ThemeChanged;

                    if (_deferredExpandAllNodes != null)
                    {
                        _deferredExpandAllNodes.Dispose();
                        _deferredExpandAllNodes = null;
                    }

                    if (_containerControl != null)
                    {
                        _containerControl.Dispose();
                        _containerControl = null;
                    }

                    if (_treeControl != null)
                    {
                        _treeControl.Dispose();
                        _treeControl = null;
                    }

                    if (vsEventBroadcaster != null)
                    {
                        vsEventBroadcaster.Dispose();
                    }
                    _treeProvider = null;
                }
            }
            finally
            {
                base.Dispose(disposing);
            }
        }
        /// <summary>
        ///     Overriden to create the VirtualTreeControl hosted in the tool window
        /// </summary>
        /// <returns></returns>
        protected override void OnToolWindowCreate()
        {
            Debug.Assert(_containerControl == null, "containerControl should be null at the beginning of OnCreate");

            // set up tree data
            _treeProvider = new VariableColumnTree(1);

            // set up tree control
            _treeControl = new TreeGridDesignerTreeControl(this);
            _treeControl.SelectionMode = SelectionMode.One;
            _treeControl.LabelEditSupport = VirtualTreeLabelEditActivationStyles.ImmediateMouse
                                            | VirtualTreeLabelEditActivationStyles.Explicit;
            _treeControl.HasHorizontalGridLines = true;
            _treeControl.HasVerticalGridLines = false;
            _treeControl.ShowToolTips = true;
            _treeControl.MultiColumnTree = _treeProvider as IMultiColumnTree;
            _treeControl.IsDragSource = false;
            _treeControl.MultiColumnHighlight = true;
            _treeControl.StandardCheckBoxes = true;
            _treeControl.SelectionChanged += OnTreeSelectionChanged;
            _treeControl.LabelEditControlChanged += OnLabelEditControlChanged;
            _treeControl.Site = new TreeGridDesignerSite(this);
            _treeControl.ContextMenuInvoked += OnContextMenu;

            var defaultColumnsCollection = DefaultColumns;
            if (defaultColumnsCollection != null)
            {
                _treeControl.DefaultColumns = defaultColumnsCollection;
            }

            // create container control which handles the watermark
            _containerControl = CreateContainer();
            _containerControl.SetWatermarkInfo(WatermarkInfo);
            _containerControl.WatermarkVisible = true;
            _containerControl.AccessibilityObject.Name = AccessibilityName;

            // Listen for user preference changes.  We use this to update our fonts due to high-contrast changes.
            SystemEvents.UserPreferenceChanged += OnUserPreferenceChanged;

            // we always want focus rectangles to be drawn
            NativeMethods.SendMessage(
                _treeControl.Handle, NativeMethods.WM_UPDATEUISTATE, (NativeMethods.UIS_CLEAR | (NativeMethods.UISF_HIDEFOCUS << 16)), 0);

            vsEventBroadcaster = new VSEventBroadcaster(this);
            vsEventBroadcaster.Initialize();
            vsEventBroadcaster.OnFontChanged += vsEventBroadcaster_OnFontChanged;

            // set the font based on VS settings
            SetFonts();

            SetTreeControlThemedColors();

            VSColorTheme.ThemeChanged += VSColorTheme_ThemeChanged;
        }