Пример #1
0
        public HotZoneTabbed(Rectangle hotArea, Rectangle newSize, WindowContentTabbed wct, bool itself)
            : base(hotArea, newSize)
        {
            // Remember state
            _wct = wct;
            _itself = itself;

            // Instead of a single rectangle for the dragging indicator we want to provide
            // two rectangles. One for the main area and another to show a tab extending
            // below it. This ensures the user can tell that it will be added as a new tab
            // page of the control.

            int tabHeight = _tabPageHeight;

            // Make sure the tab rectangle does not extend past end of control
            if (newSize.Height < (tabHeight + _dragWidth))
                tabHeight = newSize.Height -  _dragWidth * 3;

            // Create the tab page extension
            _tabRect = new Rectangle(newSize.X + _tabPageLeft,
                                     newSize.Bottom - tabHeight,
                                     _tabPageWidth,
                                     tabHeight);

            // Make sure tab rectangle does not draw off right side of control
            if (_tabRect.Right > newSize.Right)
                _tabRect.Width -= _tabRect.Right - newSize.Right;

            // We want the intersection between the top left and top right corners to be displayed
            _tabRectTL = new Rectangle(_tabRect.X, _tabRect.Y, _dragWidth, _dragWidth);
            _tabRectTR = new Rectangle(_tabRect.Right - _dragWidth, _tabRect.Y, _dragWidth, _dragWidth);

            // Reduce the main area by the height of the above item
            _newSize.Height -= tabHeight - _dragWidth;
        }
Пример #2
0
		public TabStub(VisualStyle style)
		{
			// Default state
			_wct = null;
			_style = style;
            _hoverOver = -1;
            _hoverItem = -1;
            _selectedIndex = -1;
            _defaultFont = true;
			_defaultColor = true;
			_edge = Edge.None;
			_drawTabs = new ArrayList();
            _tabPages = new TabPageCollection();
            base.Font = SystemInformation.MenuFont;

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

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

			// Default default colors
			DefineBackColor(SystemColors.Control);

			// Create the Timer for handling hovering over items
			_hoverTimer = new Timer();
			_hoverTimer.Interval = _hoverInterval;
			_hoverTimer.Tick += new EventHandler(OnTimerExpire);
		}
Пример #3
0
        public AutoHidePanel(DockingManager manager, DockStyle dockEdge)
        {
            // Define initial state
            _number = _num++;
            _defaultColor = true;
            _dismissRunning = false;
            _slideRunning = false;
            _ignoreDismiss = false;
            _killing = false;
            _manager = manager;
            _currentWCT = null;
            _currentPanel = null;
            _slideRect = new Rectangle();
            _rememberRect = new Rectangle();

            // Get the minimum vector length used for sizing
            int vector = TabStub.TabStubVector(this.Font);

            // Use for both directions, the appropriate one will be ignored because of docking style
            this.Size = new Size(vector, vector);

            // Dock ourself against requested position
            this.Dock = dockEdge;

            // We should be hidden until some Contents are added
            this.Hide();

            // We want to perform special action when container is resized
            _manager.Container.Resize += new EventHandler(OnContainerResized);

            // Add ourself to the application filtering list
            Application.AddMessageFilter(this);

            // Configuration timer objects
            CreateTimers();
        }
Пример #4
0
        //,                                                     ContextHandler showContextMenu)
        public virtual Window CreateWindowForContent(Content c,
                                                     EventHandler contentClose,
                                                     EventHandler restore,
                                                     EventHandler invertAutoHide
			)
        {
            // Create new instance with correct style
            WindowContent wc = new WindowContentTabbed(this, _visualStyle);

            WindowDetailCaption wdc;

            // Create a style specific caption detail
            if (_visualStyle == VisualStyle.IDE)
                wdc = new WindowDetailCaptionIDE(this, contentClose, restore,
                                                 invertAutoHide);
            //, showContextMenu);
            else
                wdc = new WindowDetailCaptionPlain(this, contentClose, restore,
                                                   invertAutoHide);
            //, showContextMenu);

            // Add the caption to the window display
            wc.WindowDetails.Add(wdc);

            if (c != null)
            {
                // Add provided Content to this instance
                wc.Contents.Add(c);
            }

            return wc;
        }
Пример #5
0
        protected void OnPageOver(TabStub sender, int pageIndex)
        {
            // Remove any showing auto hide windows except our own
            _manager.RemoveShowingAutoHideWindowsExcept(this);
            
            // No need for running timer, this action supercedes it
            StopDismissTimer();

            // Hovering over a different TabStub?
            if (_currentWCT != sender.WindowContentTabbed)
            {
                // Remove any currently displayed Panel/WCT
                if (_currentWCT != null)
                    RemoveDisplayedWindow();
            }
            else
            {
                // Different tab in the same TabStub?
                if (pageIndex != _currentWCT.TabControl.SelectedIndex)
                {
                    // Remove any currently displayed Panel/WCT
                    if (_currentWCT != null)
                        RemoveDisplayedWindow();
                }            
                else
                {
                    // Hover over the current window, so do nothing
                    return;
                }
            }

            Edge borderEdge = Edge.None;

            // Define which edge of the host panel shown have a border drawn
            switch(this.Dock)
            {
                case DockStyle.Left:
                    borderEdge = Edge.Right;
                    break;
                case DockStyle.Right:
                    borderEdge = Edge.Left;
                    break;
                case DockStyle.Top:
                    borderEdge = Edge.Bottom;
                    break;
                case DockStyle.Bottom:
                    borderEdge = Edge.Top;
                    break;
            }

            // Create a Panel that will host the actual WindowContentTabbed control,
            // the Panel is resized to slide into/from view. The WCT is a fixed size
            // within the Panel and so only the partial view of the WCT is shown and
            // at any point in time. Cannot resize the WCT into view as it would keep
            // repainting the caption details and effect and docking items inside it.
            _currentPanel = new AutoHostPanel(_manager, this, borderEdge);
            
            // Do not show it until we have resizing it as needed
            _currentPanel.Hide();                 
            
            // Get access to the WindowContentTabbed that is to be hosted
            _currentWCT = sender.WindowContentTabbed;

            // Select the correct page for view in the WCT
            _currentWCT.TabControl.SelectedIndex = pageIndex;            
                
            // Place the WCT inside the host Panel
            _currentPanel.Controls.Add(_currentWCT);

            // Now add the Panel to the container display
            _manager.Container.Controls.Add(_currentPanel);
		    
            // Make it top of the Z-Order
            _manager.Container.Controls.SetChildIndex(_currentPanel, 0);

            // Define the remember and slide rectangle values
            DefineRectangles();

            // Set the modified WCT size
            _currentWCT.Width = _slideRect.Width;
            _currentWCT.Height = _slideRect.Height;

            Size barSize = _currentPanel.ResizeBarSize();

            // Set the initial size/location of Panel and hosted WCT
            switch(this.Dock)
            {
                case DockStyle.Left:
                    _currentPanel.Size = new Size(0, this.Height);
                    _currentPanel.Location = new Point(this.Right, this.Top);
                    _currentWCT.Height = this.Height;
                    break;
                case DockStyle.Right:
                    _currentPanel.Size = new Size(0, this.Height);
                    _currentPanel.Location = new Point(this.Left, this.Top);
                    _currentWCT.Height = this.Height;
                    break;
                case DockStyle.Top:
                    _currentPanel.Size = new Size(this.Width, 0);
                    _currentPanel.Location = new Point(this.Left, this.Bottom);
                    _currentWCT.Width = this.Width;
                    break;
                case DockStyle.Bottom:
                    _currentPanel.Size = new Size(this.Width, 0);
                    _currentPanel.Location = new Point(this.Left, this.Top);
                    _currentWCT.Width = this.Width;
                    break;
            }

            // Finally we are ready to show it
            _currentPanel.Show();
                
            // We want to snoop of changes of focus to and from Panel and its children
            MonitorPanel(true);

            // We are showing and not hiding with the timer
            _slideOut = true;
                
            // Kick off the slide timer
            StartSlideTimer();
        }
Пример #6
0
        protected void KillDisplayedWindow()
        {
            _killing = true;
            
            // If dismiss timer running, then turn it off
            StopDismissTimer();

            // Remove content objects from WCT to update state
            int count = _currentWCT.Contents.Count;
            
            for(int index=0; index<count; index++)
            {
                // Remember reference to first content
                Content c = _currentWCT.Contents[0];
                
                // Remove it from collection
                _currentWCT.Contents.RemoveAt(0);
            }
            
            // Get rid of the displayed Panel immediately
            RemoveDisplayedWindow();

            // No longer considered the shown window
            _currentWCT.Dispose();
            _currentWCT = null;
            
            _killing = false;
        }
Пример #7
0
        protected void OnPanelLeave(object sender, EventArgs e)
        {
            _ignoreDismiss = false;

            // Is focus leaving the entire WindowContentTabbed control?
            if (!_killing && (_currentWCT != null) && !_currentWCT.ContainsFocus)
            {
                // Remember current focus
                IntPtr hWnd = User32.GetFocus();
			
                // Do not slide a window in the process of being removed
                StopDismissTimer();
                StopSlideTimer();

                // Remove Panel/WCT from display and stop timers
                RemoveDisplayedWindow();
                
                // No longer considered the shown window
                _currentWCT = null;

                // Replace the focus
                User32.SetFocus(hWnd);
            }	
        }
Пример #8
0
        public void RemoveShowingWindow()
        {
            _ignoreDismiss = false;

            // Is focus leaving the entire WindowContentTabbed control?
            if (_currentWCT != null)
            {
                // Remember current focus
                IntPtr hWnd = User32.GetFocus();

                // Do not slide a window in the process of being removed
                StopDismissTimer();
                StopSlideTimer();
			
                // Remove Panel/WCT from display and stop timers
                RemoveDisplayedWindow();
                
                // No longer considered the shown window
                _currentWCT = null;

                // Replace the focus
                User32.SetFocus(hWnd);
            }	
            
            // Prevent drawing artifacts by invalidating window
            Invalidate();
        }
Пример #9
0
//        protected void OnPageContextMenu(Point screenPos)
//        {
//            _manager.OnShowContextMenu(screenPos);
//       }

        protected void OnSlideTick(object sender, EventArgs e)
        {
            // Is the slide timer supposed to be running?
            if (_slideRunning)
            {            
                // Safety check that timer does not expire after our death
                if (this.IsDisposed || _currentPanel.IsDisposed || _currentWCT.IsDisposed)
                {
                    StopSlideTimer();
                    return;
                }

                // Use the current size/location as the starting point for changes
                Rectangle rect = new Rectangle(_currentPanel.Left, _currentPanel.Top, 
                                            _currentPanel.Width, _currentPanel.Height);
    		    
		        // How big is the resize bar inside the Panel?
                Size barSize = _currentPanel.ResizeBarSize();

                // Is this the last sliding step? 
                // (increase test by 1 because we have not yet incremented it)
                bool lastStep = ((_slideStep+1) >= _slideSteps);

                // Bringing the Panel into view?
                if (_slideOut)
                {
                    // Bring Panel another step into full view
                    switch(this.Dock)
                    {
                        case DockStyle.Left:
                            if (lastStep)
                                rect.Width = _slideRect.Width + barSize.Width;
                            else
                                rect.Width = (_slideRect.Width + barSize.Width) / 
                                            _slideSteps * (_slideStep + 1);
                            
                            // Want the right hand side of WCT showing
                            _currentWCT.Location = new Point(rect.Width - _currentWCT.Width - barSize.Width, 0);
                            break;
                        case DockStyle.Right:
                            int right = _currentPanel.Right;
                            
                            if (lastStep)
                                rect.Width = _slideRect.Width + barSize.Width;
                            else
                                rect.Width = (_slideRect.Width + barSize.Width) / 
                                            _slideSteps * (_slideStep + 1);
                                              
                            rect.X -= rect.Right - right;
                            
                            _currentWCT.Location = new Point(barSize.Width, 0);
                            break;
                        case DockStyle.Top:
                            if (lastStep)
                                rect.Height = _slideRect.Height + barSize.Height;
                            else
                                rect.Height = (_slideRect.Height + barSize.Height) / 
                                            _slideSteps * (_slideStep + 1);
                            
                            // Want the bottom of the WCT showing
                            _currentWCT.Location = new Point(0, rect.Height - _currentWCT.Height - barSize.Height);
                            break;
                        case DockStyle.Bottom:
                            int bottom = _currentPanel.Bottom;
                            
                            if (lastStep)
                                rect.Height = _slideRect.Height + barSize.Height;
                            else
                                rect.Height = (_slideRect.Height + barSize.Height) / 
                                            _slideSteps * (_slideStep + 1);
                                              
                            rect.Y -= rect.Bottom - bottom;

                            _currentWCT.Location = new Point(0, barSize.Height);
                            break;
                    }

                    // Have to use Win32 API call to alter the Panel size and position at the same time, no 
                    // Control method/property is available to do both at the same time. Otherwise you can see
                    // the Panel being moved in two steps which looks naff!
                    User32.MoveWindow(_currentPanel.Handle, rect.Left, rect.Top, rect.Width, rect.Height, true);
                    
                    // Stop timer when all required steps performed		    
                    if (lastStep)
                    {
                        StopSlideTimer();
                        
                        // If sliding into view from bottom
                        if (this.Dock == DockStyle.Top)
                        {
                            // Must cause repaint to prevent artifacts
                            _currentPanel.Refresh();
                        }
                    }
                }
                else
                {
                    int steps = _slideSteps - _slideStep;
                    
                    // Move Window another step towards required position
                    switch(this.Dock)
                    {
                        case DockStyle.Left:
                            if (lastStep)
                                rect.Width = 0;
                            else
                                rect.Width = (_slideRect.Width + barSize.Width) / 
                                            _slideSteps * steps;
                            break;
                        case DockStyle.Right:
                            int right = _currentPanel.Right;
                            
                            if (lastStep)
                                rect.Width = 0;
                            else
                                rect.Width = (_slideRect.Width + barSize.Width) / 
                                            _slideSteps * steps;
                                             
                            rect.X += right - rect.Right;
                            break;
                        case DockStyle.Top:
                            if (lastStep)
                                rect.Height = 0;
                            else
                                rect.Height = (_slideRect.Height + barSize.Height) / 
                                            _slideSteps * steps;
                            break;
                        case DockStyle.Bottom:
                            int bottom = _currentPanel.Bottom;
                            
                            if (lastStep)
                                rect.Height = 0;
                            else
                                rect.Height = (_slideRect.Height + barSize.Height) / 
                                            _slideSteps * steps;
                                              
                            rect.Y += bottom - rect.Bottom;
                            break;
                    }
                    
                    // Have to use Win32 API call to alter the Panel size and position at the same time, no 
                    // Control method/property is available to do both at the same time. Otherwise you can see
                    // the Panel being moved in two steps which looks naff!
                    User32.MoveWindow(_currentPanel.Handle, rect.Left, rect.Top, rect.Width, rect.Height, true);

                    // Stop timer when all required steps performed		    
                    if (lastStep)
                    {
                        StopSlideTimer();
                        
                        // No longer need to show it
                        RemoveDisplayedWindow();
                        
                        // No longer considered the shown window
                        _currentWCT = null;
                    }
                }
                
                // Increment the step value
                _slideStep++;
            }
        }