/// <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;
        }
Exemple #2
0
        /// <summary>
        ///     This is called after our control has been created and sited.
        ///     This is a good place to initialize the control with data gathered
        ///     from Visual Studio services.
        /// </summary>
        public override void OnToolWindowCreated()
        {
            base.OnToolWindowCreated();

            // Set the text that will appear in the title bar of the tool window.
            // Note that because we need access to the package for localization,
            // we have to wait to do this here. If we used a constant string,
            // we could do this in the consturctor.
            Caption = _package.GetResourceString("ExplorerWindowTitle");

            IServiceProvider serviceProvider = _package;

            if (serviceProvider != null)
            {
                var packageMenuService = serviceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
                _menuService = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
                if (packageMenuService != null &&
                    _menuService != null)
                {
                    var cmd = packageMenuService.FindCommand(StandardCommands.Delete);
                    if (cmd != null)
                    {
                        _menuService.AddCommand(cmd);
                    }

                    cmd = packageMenuService.FindCommand(StandardCommands.Cut);
                    if (cmd != null)
                    {
                        _menuService.AddCommand(cmd);
                    }

                    cmd = packageMenuService.FindCommand(StandardCommands.Copy);
                    if (cmd != null)
                    {
                        _menuService.AddCommand(cmd);
                    }

                    cmd = packageMenuService.FindCommand(StandardCommands.Paste);
                    if (cmd != null)
                    {
                        _menuService.AddCommand(cmd);
                    }

                    DefineSearchCommands();

                    vsEventBroadcaster = new VSEventBroadcaster(serviceProvider);
                    vsEventBroadcaster.Initialize();
                    vsEventBroadcaster.OnFontChanged += vsEventBroadcaster_OnFontChanged;
                }
            }
        }
        /// <summary>
        ///     This is called after our control has been created and sited.
        ///     This is a good place to initialize the control with data gathered
        ///     from Visual Studio services.
        /// </summary>
        public override void OnToolWindowCreated()
        {
            base.OnToolWindowCreated();

            // Set the text that will appear in the title bar of the tool window.
            // Note that because we need access to the package for localization,
            // we have to wait to do this here. If we used a constant string,
            // we could do this in the consturctor.
            Caption = _package.GetResourceString("ExplorerWindowTitle");

            IServiceProvider serviceProvider = _package;
            if (serviceProvider != null)
            {
                var packageMenuService = serviceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
                _menuService = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
                if (packageMenuService != null
                    && _menuService != null)
                {
                    var cmd = packageMenuService.FindCommand(StandardCommands.Delete);
                    if (cmd != null)
                    {
                        _menuService.AddCommand(cmd);
                    }

                    cmd = packageMenuService.FindCommand(StandardCommands.Cut);
                    if (cmd != null)
                    {
                        _menuService.AddCommand(cmd);
                    }

                    cmd = packageMenuService.FindCommand(StandardCommands.Copy);
                    if (cmd != null)
                    {
                        _menuService.AddCommand(cmd);
                    }

                    cmd = packageMenuService.FindCommand(StandardCommands.Paste);
                    if (cmd != null)
                    {
                        _menuService.AddCommand(cmd);
                    }

                    DefineSearchCommands();

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