Exemplo n.º 1
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();
        }
Exemplo n.º 2
0
        protected void OnPageClicked(TabStub sender, int pageIndex)
        {
            // Remove any showing auto hide windows except our own
            _manager.RemoveShowingAutoHideWindowsExcept(this);
            
            // A click is the same as an immediate hover over
            OnPageOver(sender, pageIndex);

            // A click implies the panel takes the focus immediately
            SetFocusToWCT();
        }
Exemplo n.º 3
0
        public void AddContentIntoTabStub(Content content, TabStub ts, int index)
        {
            // Is focus leaving the entire WindowContentTabbed control?
            if ((_currentWCT != null) && (_currentWCT == ts.WindowContentTabbed))
            {
                // Remove Panel/WCT from display and stop timers
                RemoveDisplayedWindow();
            }                
        
            // Create a new tab page
            SharpClient.UI.Controls.TabPage page = new SharpClient.UI.Controls.TabPage();
		        
            // Copy across the visual properties
            page.Title = content.Title;
            page.ImageList = content.ImageList;
            page.ImageIndex = content.ImageIndex;
                
            // Remember reference to Content it represents
            page.Tag = content;
		        
            // Add into the stub
            ts.TabPages.Insert(index, page);
		        
            // Mark Content as being in AutoHide mode
            content.AutoHidePanel = this;
            content.AutoHidden = true;
        
            // Add content into the WCT of the TabStub
            ts.WindowContentTabbed.Contents.Insert(index, content);

            // Make sure this AutoHidePanel is visible
            if (!this.Visible)
                this.Show();
                
            Invalidate();
        }
Exemplo n.º 4
0
        public void AddContentsAsGroup(ContentCollection contents, int index)
		{
            // Create new TabStub to represent the Contents
            TabStub ts = new TabStub(_manager.Style);

            // Set manager requested settings
            ts.Font = _manager.CaptionFont;
            ts.BackColor = _manager.BackColor;
            ts.ForeColor = _manager.InactiveTextColor;

            // Hook into events
            ts.PageOver += new TabStub.TabStubIndexHandler(OnPageOver);
            ts.PageClicked += new TabStub.TabStubIndexHandler(OnPageClicked);
            ts.PagesLeave += new TabStub.TabStubHandler(OnPagesLeave);
		    
            // Add a page for each Content instance
            foreach(Content c in contents)
            {
                // Create page object
                SharpClient.UI.Controls.TabPage page = new SharpClient.UI.Controls.TabPage();
		        
                // Copy across the visual properties
                page.Title = c.Title;
                page.ImageList = c.ImageList;
                page.ImageIndex = c.ImageIndex;
                
                // Remember reference to Content it represents
                page.Tag = c;
		        
                // Add into the stub
                ts.TabPages.Add(page);
		        
                // Mark Content as being in AutoHide mode
                c.AutoHidePanel = this;
                c.AutoHidden = true;
            }

            State windowState = State.DockLeft;
		    
            // Define stub settings based on our docking position
            switch(this.Dock)
            {
                case DockStyle.Left:
                    windowState = State.DockLeft;
                    ts.Edging = Edge.Left;
                    ts.Dock = DockStyle.Top;
                    break;
                case DockStyle.Right:
                    windowState = State.DockRight;
                    ts.Edging = Edge.Right;
                    ts.Dock = DockStyle.Top;
                    break;
                case DockStyle.Top:
                    windowState = State.DockTop;
                    ts.Edging = Edge.Top;
                    ts.Dock = DockStyle.Left;
                    break;
                case DockStyle.Bottom:
                    windowState = State.DockBottom;
                    ts.Edging = Edge.Bottom;
                    ts.Dock = DockStyle.Left;
                    break;
            }
		    
            // Add stub into the view
            Controls.Add(ts);
            
            // Set correct new position
            Controls.SetChildIndex(ts, index);
		    
            // Each TabStub has a WCT created and ready to be shown when needed
            WindowContentTabbed wct = _manager.CreateWindowForContent(null, new EventHandler(OnPageClose),
                                                                      null, new EventHandler(OnPageAutoHide))as WindowContentTabbed;
				//,                                                                      new ContextHandler(OnPageContextMenu)) as WindowContentTabbed;
            
            // Add each Content instance in turn
            foreach(Content c in contents)
                wct.Contents.Add(c);
                
            // By default the first Content added to a WCT will define the size
            // of the WCT control. We need to override this to use the AutoHideSize
            // from the first Content instead.
            wct.Size = contents[0].AutoHideSize;

            // Ensure Window caption bar reflects correct docking status
            wct.State = windowState;

            // Inform Window it should not allow user initiated redocking
            wct.RedockAllowed = false;

            // Hide tab selection from user
            wct.TabControl.HideTabsMode = SharpClient.UI.Controls.TabControl.HideTabsModes.HideAlways;

            // Associate WCT with matching TabStub
            ts.WindowContentTabbed = wct;
            
            // Make sure this AutoHidePanel is visible
            if (!this.Visible)
			    this.Show();
			    
	        Invalidate();
		}
Exemplo n.º 5
0
 protected void OnPagesLeave(TabStub sender)
 {
     // Do we have anything to dismiss?
     if ((_currentPanel != null) && (_currentWCT != null))
     {
         // Only dimiss if the panel does not have focus
         if (!_currentPanel.ContainsFocus)
             StartDismissTimer();
     }
 }