public WindowDetailCaption(DockingManager manager, 
                                   Size fixedSize, 
                                   EventHandler closeHandler, 
                                   EventHandler restoreHandler, 
                                   EventHandler invertAutoHideHandler, 
                                   ContextHandler contextHandler)
            : base(manager)
        {
            // Setup correct color remapping depending on initial colors
            DefineButtonRemapping();

            // Default state
            _maxButton = null;
            _hideButton = null;
            _maxInterface = null;
            _redocker = null;
            _showCloseButton = true;
            _showHideButton = true;
            _ignoreHideButton = false;
            _pinnedImage = false;
            
            // Prevent flicker with double buffering and all painting inside WM_PAINT
			SetStyle(ControlStyles.DoubleBuffer | 
					 ControlStyles.AllPaintingInWmPaint |
					 ControlStyles.UserPaint, true);

            // Our size is always fixed at the required length in both directions
            // as one of the sizes will be provided for us because of our docking
            this.Size = fixedSize;

            if (closeHandler != null)
                this.Close += closeHandler;	

            if (restoreHandler != null)
                this.Restore += restoreHandler;	

            if (invertAutoHideHandler != null)
                this.InvertAutoHide += invertAutoHideHandler;
    
            if (contextHandler != null)
                this.Context += contextHandler;	

            // Let derived classes override the button creation
            CreateButtons();

            // Need to hook into message pump so that the ESCAPE key can be 
            // intercepted when in redocking mode
            Application.AddMessageFilter(this);
        }
Beispiel #2
0
        protected void RemovePendantButtons()
        {
            // Unhook event handlers
            _minButton.Click -= new EventHandler(OnMdiMin);
            _restoreButton.Click -= new EventHandler(OnMdiRestore);
            _closeButton.Click -= new EventHandler(OnMdiClose);

            // Remove from display

            // Use helper method to circumvent form Close bug
            ControlHelper.Remove(this.Controls, _minButton);
            ControlHelper.Remove(this.Controls, _restoreButton);
            ControlHelper.Remove(this.Controls, _closeButton);

            // Release resources
            _minButton.Dispose();
            _restoreButton.Dispose();
            _closeButton.Dispose();

            // Remove references
            _minButton = null;
            _restoreButton = null;
            _closeButton = null;
        }
Beispiel #3
0
        public MenuControl()
        {
            // Set default values
            lastX = -1;
            lastY = -1;
            _trackItem = -1;
            _oldFocus = IntPtr.Zero;
            _minButton = null;
            _popupMenu = null;
            _activeChild = null;
            _closeButton = null;
            _controlLPen = null;
            _mdiContainer = null;
            _restoreButton = null;
            _controlLBrush = null;
            _chevronStartCommand = null;
            _animateFirst = true;
            _exitLoop = false;
            _selected = false;
            _multiLine = false;
            _mouseOver = false;
            _defaultFont = true;
            _manualFocus = false;
            _drawUpwards = false;
            _plainAsBlock = false;
            _clientSubclass = null;
            _ignoreMouseMove = false;
            _deselectReset = true;
            _expandAllTogether = true;
            _rememberExpansion = true;
            _highlightInfrequent = true;
            _dismissTransfer = false;
            _style = VisualStyle.IDE;
            _direction = Direction.Horizontal;
            _menuCommands = new MenuCommandCollection();
            _glyphFading = GlyphFading.Default;
            this.Dock = DockStyle.Top;
            this.Cursor = System.Windows.Forms.Cursors.Arrow;

            // Animation details
            _animateTime = 100;
            _animate = Animate.System;
            _animateStyle = Animation.System;

            // Prevent flicker with double buffering and all painting inside WM_PAINT
            SetStyle(ControlStyles.DoubleBuffer |
                     ControlStyles.AllPaintingInWmPaint |
                     ControlStyles.UserPaint, true);

            // Should not be allowed to select this control
            SetStyle(ControlStyles.Selectable, false);

            // Hookup to collection events
            _menuCommands.Cleared += new CollectionClear(OnCollectionCleared);
            _menuCommands.Inserted += new CollectionChange(OnCollectionInserted);
            _menuCommands.Removed += new CollectionChange(OnCollectionRemoved);

            // Need notification when the MenuFont is changed
            Microsoft.Win32.SystemEvents.UserPreferenceChanged +=
                new UserPreferenceChangedEventHandler(OnPreferenceChanged);

            DefineColors();

            // Set the starting Font
            DefineFont(SystemInformation.MenuFont);

            // Do not allow tab key to select this control
            this.TabStop = false;

            // Default to one line of items
            this.Height = _rowHeight;

            // Add ourself to the application filtering list
            Application.AddMessageFilter(this);
        }
Beispiel #4
0
        protected void CreatePendantButtons()
        {
            // Create the objects
            _minButton = new InertButton(_menuImages, _minIndex);
            _restoreButton = new InertButton(_menuImages, _restoreIndex);
            _closeButton = new InertButton(_menuImages, _closeIndex);

            // Define the constant sizes
            _minButton.Size = new Size(_buttonLength, _buttonLength);
            _restoreButton.Size = new Size(_buttonLength, _buttonLength);
            _closeButton.Size = new Size(_buttonLength, _buttonLength);

            // Default their position so they are not visible
            _minButton.Location = new Point(-_buttonLength, -_buttonLength);
            _restoreButton.Location = new Point(-_buttonLength, -_buttonLength);
            _closeButton.Location = new Point(-_buttonLength, -_buttonLength);

            // Hookup event handlers
            _minButton.Click += new EventHandler(OnMdiMin);
            _restoreButton.Click += new EventHandler(OnMdiRestore);
            _closeButton.Click += new EventHandler(OnMdiClose);

            // Add to display
            this.Controls.AddRange(new Control[]{_minButton, _restoreButton, _closeButton});
        }
        protected override void CreateButtons()
        {
            // Define the ImageList and which ImageIndex to show initially
            _closeButton = new InertButton(_images, (int)ImageIndex.Close);
            _hideButton = new InertButton(_images, (int)ImageIndex.AutoHide);

            _closeButton.Size = new Size(_buttonWidth, _buttonHeight);
            _hideButton.Size = new Size(_buttonWidth, _buttonHeight);

            // Let the location of the control be updated for us
            _closeButton.Anchor = AnchorStyles.Right;
            _hideButton.Anchor = AnchorStyles.Right;

            // Define the button position relative to the size set in the constructor
            _closeButton.Location = new Point(_fixedLength - _buttonWidth - _buttonSpacer,
                                              (_fixedLength - _yInset * 2 - _buttonHeight) / 2 + _yInset);

            _hideButton.Location = new Point(_fixedLength - (_buttonWidth - _buttonSpacer) * 2,
                                             (_fixedLength - _yInset * 2 - _buttonHeight) / 2 + _yInset);

            // Give the button a very thin button
            _closeButton.BorderWidth = 1;
            _hideButton.BorderWidth = 1;

            // Define correct color setup
            _closeButton.BackColor = this.BackColor;
            _closeButton.ImageAttributes = _inactiveAttr;
            _hideButton.BackColor = this.BackColor;
            _hideButton.ImageAttributes = _inactiveAttr;

            // Add to the display
            Controls.Add(_closeButton);
            Controls.Add(_hideButton);

            // Let base class perform common actions
            base.CreateButtons();
        }
        protected void RemoveMaximizeInterface()
        {
            if (_maxInterface != null)
            {
                // Unhook from the interface change events
                _maxInterface.RefreshMaximize -= new EventHandler(OnRefreshMaximize);

                // Remove the interface reference
                _maxInterface = null;

                // Use helper method to circumvent form Close bug
                ControlHelper.Remove(this.Controls, _maxButton);

                OnRemoveMaximizeInterface();

                // Unhook into button events
                _maxButton.Click -= new EventHandler(OnButtonMax);
                _maxButton.GotFocus -= new EventHandler(OnButtonGotFocus);

                // Kill the button which is no longer needed
                _maxButton.Dispose();
                _maxButton = null;

                RecalculateButtons();
            }
        }
        protected void AddMaximizeInterface(IZoneMaximizeWindow zmw)
        {
            // Has the maximize button already been created?
            if (_maxInterface == null)
            {
                // Create the InertButton
                _maxButton = new InertButton(_images, 0);

                // Hook into button events
                _maxButton.Click += new EventHandler(OnButtonMax);
                _maxButton.GotFocus += new EventHandler(OnButtonGotFocus);

                // Define the default remapping
                _maxButton.ImageAttributes = _inactiveAttr;

                OnAddMaximizeInterface();

                Controls.Add(_maxButton);

                // Remember the interface reference
                _maxInterface = zmw;

                // Hook into the interface change events
                _maxInterface.RefreshMaximize += new EventHandler(OnRefreshMaximize);

                RecalculateButtons();
            }
        }
        protected override void CreateButtons()
        {
            // Define the ImageList and which ImageIndex to show initially
            _closeButton = new InertButton(_images, (int)ImageIndex.Close);
            _hideButton = new InertButton(_images, (int)ImageIndex.AutoHide);

            _closeButton.Size = new Size(_buttonWidth, _buttonHeight);
            _hideButton.Size = new Size(_buttonWidth, _buttonHeight);

            // Shows border all the time and not just when mouse is over control
            _closeButton.PopupStyle = false;
            _hideButton.PopupStyle = false;

            // Define the fixed remapping
            _closeButton.ImageAttributes = _activeAttr;
            _hideButton.ImageAttributes = _activeAttr;

            // Add to the display
            Controls.Add(_closeButton);
            Controls.Add(_hideButton);

            // Let base class perform common actions
            base.CreateButtons();
        }
        public TabControl()
        {
            // Prevent flicker with double buffering and all painting inside WM_PAINT
            SetStyle(ControlStyles.DoubleBuffer, true);
            SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            SetStyle(ControlStyles.UserPaint, true);

            // Create collections
            _tabRects = new ArrayList();
            _tabPages = new TabPageCollection();

            // Hookup to collection events
            _tabPages.Clearing += new CollectionClear(OnClearingPages);
            _tabPages.Cleared += new CollectionClear(OnClearedPages);
            _tabPages.Inserting += new CollectionChange(OnInsertingPage);
            _tabPages.Inserted += new CollectionChange(OnInsertedPage);
            _tabPages.Removing += new CollectionChange(OnRemovingPage);
            _tabPages.Removed += new CollectionChange(OnRemovedPage);

            // Define the default state of the control
            _startPage = -1;
            _pageSelected = -1;
            _hotTrackPage = -1;
            _imageList = null;
            _insetPlain = true;
            _multiline = false;
            _multilineFullWidth = false;
            _dragFromControl = true;
            _mouseOver = false;
            _leftScroll = false;
            _defaultFont = true;
            _defaultColor = true;
            _rightScroll = false;
            _hoverSelect = false;
            _leftMouseDown = false;
            _ignoreDownDrag = true;
            _selectedTextOnly = false;
            _leftMouseDownDrag = false;
            _insetBorderPagesOnly = false;
            _hideTabsMode = HideTabsModes.ShowAlways;
            _recordFocus = true;
            _styleIndex = 1;
            _leaveTimeout = 200;
            _ctrlTopOffset = 0;
            _ctrlLeftOffset = 0;
            _ctrlRightOffset = 0;
            _ctrlBottomOffset = 0;
            _style = VisualStyle.IDE;
            _buttonActiveColor = Color.FromArgb(128, this.ForeColor);
            _buttonInactiveColor = _buttonActiveColor;
            _textColor = TabControl.DefaultForeColor;
            _textInactiveColor = Color.FromArgb(128, _textColor);
            _hotTextColor = SystemColors.ActiveCaption;

            // Create the panel that hosts each page control. This is done to prevent the problem where a
            // hosted Control/Form has 'AutoScaleBaseSize' defined. In which case our attempt to size it the
            // first time is ignored and the control sizes itself to big and would overlap the tabs area.
            _hostPanel = new HostPanel();
            _hostPanel.Location = new Point(-1,-1);
            _hostPanel.Size = new Size(0,0);
            _hostPanel.MouseEnter += new EventHandler(OnPageMouseEnter);
            _hostPanel.MouseLeave += new EventHandler(OnPageMouseLeave);

            // Create hover buttons
            _closeButton = new InertButton(_internalImages, (int)ImageStrip.Close);
            _leftArrow = new InertButton(_internalImages, (int)ImageStrip.LeftEnabled, (int)ImageStrip.LeftDisabled);
            _rightArrow = new InertButton(_internalImages, (int)ImageStrip.RightEnabled, (int)ImageStrip.RightDisabled);

            // We want our buttons to have very thin borders
            _closeButton.BorderWidth = _leftArrow.BorderWidth = _rightArrow.BorderWidth = 1;

            // Hookup to the button events
            _closeButton.Click += new EventHandler(OnCloseButton);
            _leftArrow.Click += new EventHandler(OnLeftArrow);
            _rightArrow.Click += new EventHandler(OnRightArrow);

            // Set their fixed sizes
            _leftArrow.Size = _rightArrow.Size = _closeButton.Size = new Size(_buttonWidth, _buttonHeight);

            // Add child controls
            Controls.AddRange(new Control[]{_closeButton, _leftArrow, _rightArrow, _hostPanel});

            // Grab some contant values
            _imageWidth = 16;
            _imageHeight = 16;

            // Default to having a MultiForm usage
            SetAppearance(VisualAppearance.MultiForm);

            // Need a timer so that when the mouse leaves, a fractionaly delay occurs before
            // noticing and hiding the tabs area when the appropriate style is set
            _overTimer = new Timer();
            _overTimer.Interval = _leaveTimeout;
            _overTimer.Tick += new EventHandler(OnMouseTick);

            // Need notification when the MenuFont is changed
            Microsoft.Win32.SystemEvents.UserPreferenceChanged +=
                new UserPreferenceChangedEventHandler(OnPreferenceChanged);

            // Define the default Font, BackColor and Button images
            DefineFont(SystemInformation.MenuFont);
            DefineBackColor(SystemColors.Control);
            DefineButtonImages();

            Recalculate();
        }