예제 #1
0
        public HotZoneFloating(Rectangle hotArea, Rectangle newSize, Point offset, RedockerContent redocker)
            : base(hotArea, newSize)
        {
            // Store initial state
            _offset   = offset;
            _redocker = redocker;

            Size  floatSize        = CalculateFloatingSize();
            float widthPercentage  = (float)floatSize.Width / (float)_newSize.Width;
            float heightPercentage = (float)floatSize.Height / (float)_newSize.Height;

            _newSize.Width  = floatSize.Width;
            _newSize.Height = floatSize.Height + SystemInformation.ToolWindowCaptionHeight;

            _offset.X = (int)((float)_offset.X * widthPercentage);
            _offset.Y = (int)((float)_offset.Y * heightPercentage);

            // We do not want the indicator to be too far away from the cursor, so limit check the offset
            if (_offset.X > newSize.Width)
            {
                _offset.X = newSize.Width;
            }

            if (_offset.Y > newSize.Height)
            {
                _offset.Y = newSize.Height;
            }
        }
예제 #2
0
        protected void OnPageDragStart(object sender, MouseEventArgs e)
        {
            if (this.RedockAllowed)
            {
                // There must be a selected page for this event to occur
                Magic.Controls.TabPage page = _tabControl.SelectedTab;

                // Event page must specify its Content object
                Content c = page.Tag as Content;

                // Remember the position of the tab before it is removed
                _dragPageIndex = _tabControl.TabPages.IndexOf(page);

                // Remove page from TabControl
                _tabControl.TabPages.Remove(page);

                // Force the entire window to redraw to ensure the Redocker does not start drawing
                // the XOR indicator before the window repaints itself. Otherwise the repainted
                // control will interfere with the XOR indicator.
                this.Refresh();

                // Start redocking activity for the single Content of this WindowContent
                _redocker = new RedockerContent(_tabControl, c, this, new Point(e.X, e.Y));
            }
        }
예제 #3
0
        public bool PreFilterMessage(ref Message m)
        {
            // Has a key been pressed?
            if (m.Msg == (int)Win32.Msgs.WM_KEYDOWN)
            {
                // Is it the ESCAPE key?
                if ((int)m.WParam == (int)Win32.VirtualKeys.VK_ESCAPE)
                {
                    // Are we in redocking mode?
                    if (_redocker != null)
                    {
                        // Cancel the redocking activity
                        _redocker.QuitTrackingMode(null);

                        // Put back the page that was removed when dragging started
                        RestoreDraggingPage();

                        // No longer need the object
                        _redocker = null;

                        return(true);
                    }
                }
            }

            return(false);
        }
예제 #4
0
        protected override void OnMouseUp(MouseEventArgs e)
        {
            // The double click event will cause the control to be destroyed as
            // the Contents are restored to their alternative positions, so need to
            // double check the control is not already dead
            if (!IsDisposed)
            {
                // Are we currently in a redocking state?
                if (_redocker != null)
                {
                    // Let the redocker finish off
                    _redocker.OnMouseUp(e);

                    // No longer need the object
                    _redocker = null;
                }

                // Right mouse button can generate a Context event
                if (e.Button == MouseButtons.Right)
                {
                    // Get screen coordinates of the mouse
                    Point pt = this.PointToScreen(new Point(e.X, e.Y));

                    // Box to transfer as parameter
                    OnContext(pt);
                }
            }

            base.OnMouseUp(e);
        }
예제 #5
0
        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);
        }
예제 #6
0
        public FloatingForm(DockingManager dockingManager, Zone zone, ContextHandler contextHandler)
        {
            // The caller is responsible for setting our initial screen location
            this.StartPosition = FormStartPosition.Manual;

            // Not in task bar to prevent clutter
            this.ShowInTaskbar = false;

            // Make sure the main Form owns us
            this.Owner = dockingManager.Container.FindForm();

            // Need to know when the Zone is removed
            this.ControlRemoved += new ControlEventHandler(OnZoneRemoved);

            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow;

            // Add the Zone as the only content of the Form
            Controls.Add(zone);

            // Default state
            _redocker       = null;
            _intercept      = false;
            _zone           = zone;
            _dockingManager = dockingManager;

            // Assign any event handler for context menu
            if (contextHandler != null)
            {
                this.Context += contextHandler;
            }

            // Default color
            this.BackColor = _dockingManager.BackColor;
            this.ForeColor = _dockingManager.InactiveTextColor;

            // Monitor changes in the Zone content
            _zone.Windows.Inserted += new CollectionChange(OnWindowInserted);
            _zone.Windows.Removing += new CollectionChange(OnWindowRemoving);
            _zone.Windows.Removed  += new CollectionChange(OnWindowRemoved);

            if (_zone.Windows.Count == 1)
            {
                // The first Window to be added. Tell it to hide details
                _zone.Windows[0].HideDetails();

                // Monitor change in window title
                _zone.Windows[0].FullTitleChanged += new EventHandler(OnFullTitleChanged);

                // Grab any existing title
                this.Text = _zone.Windows[0].FullTitle;
            }

            // Need to hook into message pump so that the ESCAPE key can be
            // intercepted when in redocking mode
            Application.AddMessageFilter(this);
        }
예제 #7
0
        public FloatingForm(DockingManager dockingManager, Zone zone, ContextHandler contextHandler)
        {
            // The caller is responsible for setting our initial screen location
            this.StartPosition = FormStartPosition.Manual;

            // Not in task bar to prevent clutter
            this.ShowInTaskbar = false;

            // Make sure the main Form owns us
            this.Owner = dockingManager.Container.FindForm();

            // Need to know when the Zone is removed
            this.ControlRemoved += new ControlEventHandler(OnZoneRemoved);

            // Add the Zone as the only content of the Form
            Controls.Add(zone);

            // Default state
            _redocker = null;
            _intercept = false;
            _zone = zone;
            _dockingManager = dockingManager;

            // Assign any event handler for context menu
            if (contextHandler != null)
                this.Context += contextHandler;

            // Default color
            this.BackColor = _dockingManager.BackColor;
            this.ForeColor = _dockingManager.InactiveTextColor;

            // Monitor changes in the Zone content
            _zone.Windows.Inserted += new CollectionChange(OnWindowInserted);
            _zone.Windows.Removing += new CollectionChange(OnWindowRemoving);
            _zone.Windows.Removed += new CollectionChange(OnWindowRemoved);

            if (_zone.Windows.Count == 1)
            {
                // The first Window to be added. Tell it to hide details
                _zone.Windows[0].HideDetails();

                // Monitor change in window title
                _zone.Windows[0].FullTitleChanged += new EventHandler(OnFullTitleChanged);

                // Grab any existing title
                this.Text = _zone.Windows[0].FullTitle;
            }

            // Need to hook into message pump so that the ESCAPE key can be
            // intercepted when in redocking mode
            Application.AddMessageFilter(this);
        }
예제 #8
0
        protected Size CalculateFloatingSize()
        {
            Size floatingSize = new Size(0, 0);

            // Get specific redocker type
            RedockerContent redock = _redocker as RedockerContent;

            switch (redock.DockingSource)
            {
            case RedockerContent.Source.RawContent:
                // Whole Form is size requested by single Content
                floatingSize = redock.Content.FloatingSize;
                break;

            case RedockerContent.Source.WindowContent:
                // Find the largest requested floating size
                foreach (Content c in redock.WindowContent.Contents)
                {
                    if (c.FloatingSize.Width > floatingSize.Width)
                    {
                        floatingSize.Width = c.FloatingSize.Width;
                    }

                    if (c.FloatingSize.Height > floatingSize.Height)
                    {
                        floatingSize.Height = c.FloatingSize.Height;
                    }
                }

                // Apply same size to all Content objects
                foreach (Content c in redock.WindowContent.Contents)
                {
                    c.FloatingSize = floatingSize;
                }
                break;

            case RedockerContent.Source.ContentInsideWindow:
                // Whole Form is size requested by single Content
                floatingSize = redock.Content.FloatingSize;
                break;

            case RedockerContent.Source.FloatingForm:
                // Use the requested size
                floatingSize.Width  = _newSize.Width;
                floatingSize.Height = _newSize.Height;
                break;
            }

            return(floatingSize);
        }
예제 #9
0
        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);
        }
예제 #10
0
        protected void OnPageDragQuit(object sender, MouseEventArgs e)
        {
            // Are we currently in a redocking state?
            if (_redocker != null)
            {
                // Get redocker to quit
                _redocker.QuitTrackingMode(e);

                // Put back the page that was removed when dragging started
                RestoreDraggingPage();

                // No longer need the object
                _redocker = null;
            }
        }
예제 #11
0
        public void AddHotZones(Redocker redock, HotZoneCollection collection)
        {
            RedockerContent redocker = redock as RedockerContent;

            // Allow the contained Zone a chance to expose HotZones
            foreach (Control c in this.Controls)
            {
                IHotZoneSource ag = c as IHotZoneSource;

                // Does this control expose an interface for its own HotZones?
                if (ag != null)
                {
                    ag.AddHotZones(redock, collection);
                }
            }
        }
예제 #12
0
        protected override void OnDoubleClick(EventArgs e)
        {
            // The double click event will cause the control to be destroyed as
            // the Contents are restored to their alternative positions, so need to
            // double check the control is not already dead
            if (!IsDisposed)
            {
                // Are we currently in a redocking state?
                if (_redocker != null)
                {
                    // No longer need the object
                    _redocker = null;
                }
            }

            // Fire attached event handlers
            OnRestore();
        }
예제 #13
0
        public void AddHotZones(Redocker redock, HotZoneCollection collection)
        {
            RedockerContent redocker = redock as RedockerContent;

            bool itself   = false;
            bool nullZone = false;

            // We process differently for WindowContent to redock into itself!
            if ((redocker.WindowContent != null) && (redocker.WindowContent == this))
            {
                itself = true;
            }

            // We do not allow a Content to redock into its existing container
            if (itself && !_contents.Contains(redocker.Content))
            {
                nullZone = true;
            }

            Rectangle newSize = this.RectangleToScreen(this.ClientRectangle);
            Rectangle hotArea = _tabControl.RectangleToScreen(_tabControl.ClientRectangle);;

            // Find any caption detail and use that area as the hot area
            foreach (WindowDetail wd in _windowDetails)
            {
                WindowDetailCaption wdc = wd as WindowDetailCaption;

                if (wdc != null)
                {
                    hotArea = wdc.RectangleToScreen(wdc.ClientRectangle);
                    hotArea.Inflate(_hotAreaInflate, _hotAreaInflate);
                    break;
                }
            }

            if (nullZone)
            {
                collection.Add(new HotZoneNull(hotArea));
            }
            else
            {
                collection.Add(new HotZoneTabbed(hotArea, newSize, this, itself));
            }
        }
예제 #14
0
        protected void OnPageDragEnd(object sender, MouseEventArgs e)
        {
            // Are we currently in a redocking state?
            if (_redocker != null)
            {
                // Let the redocker finish off
                bool moved = _redocker.OnMouseUp(e);

                // If the tab was not positioned somewhere else
                if (!moved)
                {
                    // Put back the page that was removed when dragging started
                    RestoreDraggingPage();
                }

                // No longer need the object
                _redocker = null;
            }
        }
예제 #15
0
        protected override void OnMouseDown(MouseEventArgs e)
        {
            // The double click event will cause the control to be destroyed as
            // the Contents are restored to their alternative positions, so need to
            // double check the control is not already dead
            if (!IsDisposed)
            {
                // Always quit when new another button pressed and already docking
                if (_redocker != null)
                {
                    _redocker.QuitTrackingMode(e);

                    // No longer need the object
                    _redocker = null;
                }
                else
                {
                    // Left mouse down begins a redocking action
                    if (e.Button == MouseButtons.Left)
                    {
                        if (this.ParentWindow.RedockAllowed)
                        {
                            WindowContent wc = this.ParentWindow as WindowContent;

                            // Is our parent a WindowContent instance?
                            if (wc != null)
                            {
                                // Start redocking activity for the whole WindowContent
                                _redocker = new RedockerContent(this, wc, new Point(e.X, e.Y));
                            }
                        }
                    }

                    this.Focus();
                }
            }

            base.OnMouseDown(e);
        }
        public HotZoneFloating(Rectangle hotArea, Rectangle newSize, Point offset, RedockerContent redocker)
            : base(hotArea, newSize)
        {
            // Store initial state
            _offset = offset;
            _redocker = redocker;

            Size floatSize = CalculateFloatingSize();
            float widthPercentage = (float)floatSize.Width / (float)_newSize.Width;
            float heightPercentage = (float)floatSize.Height / (float)_newSize.Height;

            _newSize.Width = floatSize.Width;
            _newSize.Height = floatSize.Height + SystemInformation.ToolWindowCaptionHeight;

            _offset.X = (int)((float) _offset.X * widthPercentage);
            _offset.Y = (int)((float) _offset.Y * heightPercentage);

            // We do not want the indicator to be too far away from the cursor, so limit check the offset
            if (_offset.X > newSize.Width)
                _offset.X = newSize.Width;

            if (_offset.Y > newSize.Height)
                _offset.Y = newSize.Height;
        }
예제 #17
0
        public override bool ApplyChange(Point screenPos, Redocker parent)
        {
            // We are only called from the RedockerContent class
            RedockerContent redock = parent as RedockerContent;

            DockingManager dockingManager = redock.DockingManager;

            bool becomeFloating = (_zs.State == State.Floating);

            // Reduce flicker during transition
            dockingManager.Container.SuspendLayout();

            // Manageing Zones should remove display AutoHide windows
            dockingManager.RemoveShowingAutoHideWindows();

            switch (redock.DockingSource)
            {
            case RedockerContent.Source.RawContent:
            {
                // Perform State specific Restore actions
                if (becomeFloating)
                {
                    redock.Content.ContentBecomesFloating();
                }

                // Create a new Window to host Content
                Window w = dockingManager.CreateWindowForContent(redock.Content);

                // Add into Zone
                _zs.Windows.Insert(_index, w);
            }
            break;

            case RedockerContent.Source.WindowContent:
            {
                // Is the destination Zone in the Floating state?
                if (becomeFloating)
                {
                    foreach (Content c in redock.WindowContent.Contents)
                    {
                        c.ContentBecomesFloating();
                    }
                }
                else
                {
                    if (redock.WindowContent.State == State.Floating)
                    {
                        foreach (Content c in redock.WindowContent.Contents)
                        {
                            c.ContentLeavesFloating();
                        }
                    }
                }

                // Check if the WindowContent source is in same Zone
                if (redock.WindowContent.ParentZone == _zs)
                {
                    // Find current position of source WindowContent
                    int currPos = _zs.Windows.IndexOf(redock.WindowContent);

                    // If current window is before the new position then the current
                    // window will disappear before the new one is inserted,so need to
                    // adjust down the new insertion point
                    if (currPos < _index)
                    {
                        _index--;
                    }
                }

                // Create a new Window to host Content
                WindowContent wc = dockingManager.CreateWindowForContent(null) as WindowContent;

                // Transfer content across
                int count = redock.WindowContent.Contents.Count;

                for (int index = 0; index < count; index++)
                {
                    Content c = redock.WindowContent.Contents[0];

                    // Remove from existing location
                    redock.WindowContent.Contents.RemoveAt(0);

                    // Add into new WindowContent host
                    wc.Contents.Add(c);
                }

                // Add into host into Zone
                _zs.Windows.Insert(_index, wc);
            }
            break;

            case RedockerContent.Source.ContentInsideWindow:
            {
                // Perform State specific Restore actions
                if (becomeFloating)
                {
                    redock.Content.ContentBecomesFloating();
                }
                else
                {
                    if (redock.Content.ParentWindowContent.State == State.Floating)
                    {
                        redock.Content.ContentLeavesFloating();
                    }
                }

                // Remove Content from existing WindowContent
                if (redock.Content.ParentWindowContent != null)
                {
                    // Will removing the Content cause the WindowContent to die?
                    if (redock.Content.ParentWindowContent.Contents.Count == 1)
                    {
                        // Check if the WindowContent source is in same Zone
                        if (redock.Content.ParentWindowContent.ParentZone == _zs)
                        {
                            // Find current position of source WindowContent
                            int currPos = _zs.Windows.IndexOf(redock.Content.ParentWindowContent);

                            // If current window is before the new position then the current
                            // window will disappear before the new one is inserted,so need to
                            // adjust down the new insertion point
                            if (currPos < _index)
                            {
                                _index--;
                            }
                        }
                    }

                    redock.Content.ParentWindowContent.Contents.Remove(redock.Content);
                }

                // Create a new Window to host Content
                Window w = dockingManager.CreateWindowForContent(redock.Content);

                // Add into Zone
                _zs.Windows.Insert(_index, w);
            }
            break;

            case RedockerContent.Source.FloatingForm:
            {
                // Perform State specific Restore actions
                if (!becomeFloating)
                {
                    // Make every Content object in the Floating Zone
                    // record its current state as the Floating state
                    redock.FloatingForm.ExitFloating();
                }

                int count = redock.FloatingForm.Zone.Windows.Count;

                for (int index = count - 1; index >= 0; index--)
                {
                    // Remember the Window reference
                    Window w = redock.FloatingForm.Zone.Windows[index];

                    // Remove from floating collection
                    redock.FloatingForm.Zone.Windows.RemoveAt(index);

                    // Add into new ZoneSequence destination
                    _zs.Windows.Insert(_index, w);
                }
            }
            break;
            }

            dockingManager.UpdateInsideFill();

            // Reduce flicker during transition
            dockingManager.Container.ResumeLayout();

            return(true);
        }
예제 #18
0
        public override bool ApplyChange(Point screenPos, Redocker parent)
        {
            // If docking back to itself then refuse to apply the change, this will cause the
            // WindowContentTabbed object to put back the content which is the desired effect
            if (_itself)
            {
                return(false);
            }

            // We are only called from the RedockerContent class
            RedockerContent redock = parent as RedockerContent;

            DockingManager dockingManager = redock.DockingManager;

            bool becomeFloating = (_wct.ParentZone.State == State.Floating);

            // Reduce flicker during transition
            dockingManager.Container.SuspendLayout();

            // Manageing Zones should remove display AutoHide windows
            dockingManager.RemoveShowingAutoHideWindows();

            switch (redock.DockingSource)
            {
            case RedockerContent.Source.RawContent:
            {
                // Perform State specific Restore actions
                if (becomeFloating)
                {
                    redock.Content.ContentBecomesFloating();
                }

                _wct.Contents.Add(redock.Content);
            }
            break;

            case RedockerContent.Source.WindowContent:
            {
                // Perform State specific Restore actions
                if (becomeFloating)
                {
                    foreach (Content c in redock.WindowContent.Contents)
                    {
                        c.ContentBecomesFloating();
                    }
                }
                else
                {
                    // If the source is leaving the Floating state then need to record Restore positions
                    if (redock.WindowContent.State == State.Floating)
                    {
                        foreach (Content c in redock.WindowContent.Contents)
                        {
                            c.ContentLeavesFloating();
                        }
                    }
                }

                int count = redock.WindowContent.Contents.Count;

                for (int index = 0; index < count; index++)
                {
                    Content c = redock.WindowContent.Contents[0];

                    // Remove Content from previous WindowContent
                    redock.WindowContent.Contents.RemoveAt(0);

                    // Add into new WindowContent
                    _wct.Contents.Add(c);
                }
            }
            break;

            case RedockerContent.Source.ContentInsideWindow:
            {
                // Perform State specific Restore actions
                if (becomeFloating)
                {
                    redock.Content.ContentBecomesFloating();
                }
                else
                {
                    // If the source is leaving the Floating state then need to record Restore position
                    if (redock.Content.ParentWindowContent.State == State.Floating)
                    {
                        redock.Content.ContentLeavesFloating();
                    }
                }

                // Remove Content from existing WindowContent
                if (redock.Content.ParentWindowContent != null)
                {
                    redock.Content.ParentWindowContent.Contents.Remove(redock.Content);
                }

                _wct.Contents.Add(redock.Content);
            }
            break;

            case RedockerContent.Source.FloatingForm:
            {
                // Perform State specific Restore actions
                if (!becomeFloating)
                {
                    // Make every Content object in the Floating Zone
                    // record its current state as the Floating state
                    redock.FloatingForm.ExitFloating();
                }

                int wCount = redock.FloatingForm.Zone.Windows.Count;

                for (int wIndex = 0; wIndex < wCount; wIndex++)
                {
                    WindowContent wc = redock.FloatingForm.Zone.Windows[0] as WindowContent;

                    if (wc != null)
                    {
                        int cCount = wc.Contents.Count;

                        for (int cIndex = 0; cIndex < cCount; cIndex++)
                        {
                            // Get reference to first content in collection
                            Content c = wc.Contents[0];

                            // Remove from old WindowContent
                            wc.Contents.RemoveAt(0);

                            // Add into new WindowContentTabbed
                            _wct.Contents.Add(c);
                        }
                    }
                }
            }
            break;
            }

            dockingManager.UpdateInsideFill();

            // Reduce flicker during transition
            dockingManager.Container.ResumeLayout();

            return(true);
        }
예제 #19
0
        protected void OnPageDragEnd(object sender, MouseEventArgs e)
        {
            // Are we currently in a redocking state?
            if (_redocker != null)
            {
                // Let the redocker finish off
                bool moved = _redocker.OnMouseUp(e);

                // If the tab was not positioned somewhere else
                if (!moved)
                {
                    // Put back the page that was removed when dragging started
                    RestoreDraggingPage();
                }

                // No longer need the object
                _redocker = null;
            }
        }
예제 #20
0
        protected void OnPageDragQuit(object sender, MouseEventArgs e)
        {
            // Are we currently in a redocking state?
            if (_redocker != null)
            {
				// Get redocker to quit
				_redocker.QuitTrackingMode(e);

                // Put back the page that was removed when dragging started
                RestoreDraggingPage();

                // No longer need the object
                _redocker = null;
            }
        }
예제 #21
0
        public WindowContentTabbed(DockingManager manager, VisualStyle vs)
            : base(manager, vs)
        {
            _redocker = null;
            _activeContent = null;
            
            // Create the TabControl used for viewing the Content windows
            _tabControl = new Magic.Controls.TabControl();

            // It should always occupy the remaining space after all details
            _tabControl.Dock = DockStyle.Fill;

            // Show tabs only if two or more tab pages exist
            _tabControl.HideTabsMode = Magic.Controls.TabControl.HideTabsModes.HideUsingLogic;
            
            // Hook into the TabControl notifications
            _tabControl.GotFocus += new EventHandler(OnTabControlGotFocus);
            _tabControl.LostFocus += new EventHandler(OnTabControlLostFocus);
            _tabControl.PageGotFocus += new EventHandler(OnTabControlGotFocus);
            _tabControl.PageLostFocus += new EventHandler(OnTabControlLostFocus);
            _tabControl.SelectionChanged += new EventHandler(OnSelectionChanged);
            _tabControl.PageDragStart += new MouseEventHandler(OnPageDragStart);
            _tabControl.PageDragMove += new MouseEventHandler(OnPageDragMove);
            _tabControl.PageDragEnd += new MouseEventHandler(OnPageDragEnd);
            _tabControl.PageDragQuit += new MouseEventHandler(OnPageDragQuit);
            _tabControl.DoubleClickTab += new Magic.Controls.TabControl.DoubleClickTabHandler(OnDoubleClickTab);
			_tabControl.Font = manager.TabControlFont;
            _tabControl.BackColor = manager.BackColor;
            _tabControl.ForeColor = manager.InactiveTextColor;

            // Define the visual style required
            _tabControl.Style = vs;

			// Allow developers a chance to override default settings
			manager.OnTabControlCreated(_tabControl);

            switch(vs)
            {
                case VisualStyle.IDE:
                    Controls.Add(_tabControl);
                    break;
                case VisualStyle.Plain:
                    // Only the border at the pages edge and not around the whole control
                    _tabControl.InsetBorderPagesOnly = !_manager.PlainTabBorder;

                    // We want a border around the TabControl so it is indented and looks consistent
                    // with the Plain look and feel, so use the helper Control 'BorderForControl'
                    BorderForControl bfc = new BorderForControl(_tabControl, _plainBorder);

                    // It should always occupy the remaining space after all details
                    bfc.Dock = DockStyle.Fill;

                    // Define the default border border
                    bfc.BackColor = _manager.BackColor;

                    // When in 'VisualStyle.Plain' we need to 
                    Controls.Add(bfc);
                    break;
            }

            // Need to hook into message pump so that the ESCAPE key can be 
            // intercepted when in redocking mode
            Application.AddMessageFilter(this);
        }
예제 #22
0
        public WindowContentTabbed(DockingManager manager, VisualStyle vs)
            : base(manager, vs)
        {
            _redocker      = null;
            _activeContent = null;

            // Create the TabControl used for viewing the Content windows
            _tabControl = new Magic.Controls.TabControl();

            // It should always occupy the remaining space after all details
            _tabControl.Dock = DockStyle.Fill;

            // Show tabs only if two or more tab pages exist
            _tabControl.HideTabsMode = Magic.Controls.TabControl.HideTabsModes.HideUsingLogic;

            // Hook into the TabControl notifications
            _tabControl.GotFocus         += new EventHandler(OnTabControlGotFocus);
            _tabControl.LostFocus        += new EventHandler(OnTabControlLostFocus);
            _tabControl.PageGotFocus     += new EventHandler(OnTabControlGotFocus);
            _tabControl.PageLostFocus    += new EventHandler(OnTabControlLostFocus);
            _tabControl.SelectionChanged += new EventHandler(OnSelectionChanged);
            _tabControl.PageDragStart    += new MouseEventHandler(OnPageDragStart);
            _tabControl.PageDragMove     += new MouseEventHandler(OnPageDragMove);
            _tabControl.PageDragEnd      += new MouseEventHandler(OnPageDragEnd);
            _tabControl.PageDragQuit     += new MouseEventHandler(OnPageDragQuit);
            _tabControl.DoubleClickTab   += new Magic.Controls.TabControl.DoubleClickTabHandler(OnDoubleClickTab);
            _tabControl.Font              = manager.TabControlFont;
            _tabControl.BackColor         = manager.BackColor;
            _tabControl.ForeColor         = manager.InactiveTextColor;

            // Define the visual style required
            _tabControl.Style = vs;

            // Allow developers a chance to override default settings
            manager.OnTabControlCreated(_tabControl);

            switch (vs)
            {
            case VisualStyle.IDE:
                Controls.Add(_tabControl);
                break;

            case VisualStyle.Plain:
                // Only the border at the pages edge and not around the whole control
                _tabControl.InsetBorderPagesOnly = !_manager.PlainTabBorder;

                // We want a border around the TabControl so it is indented and looks consistent
                // with the Plain look and feel, so use the helper Control 'BorderForControl'
                BorderForControl bfc = new BorderForControl(_tabControl, _plainBorder);

                // It should always occupy the remaining space after all details
                bfc.Dock = DockStyle.Fill;

                // Define the default border border
                bfc.BackColor = _manager.BackColor;

                // When in 'VisualStyle.Plain' we need to
                Controls.Add(bfc);
                break;
            }

            // Need to hook into message pump so that the ESCAPE key can be
            // intercepted when in redocking mode
            Application.AddMessageFilter(this);
        }
        public bool PreFilterMessage(ref Message m)
        {
            // Has a key been pressed?
            if (m.Msg == (int)Win32.Msgs.WM_KEYDOWN)
            {
                // Is it the ESCAPE key?
                if ((int)m.WParam == (int)Win32.VirtualKeys.VK_ESCAPE)
                {
                    // Are we in redocking mode?
                    if (_redocker != null)
                    {
                        // Cancel the redocking activity
                        _redocker.QuitTrackingMode(null);

                        // No longer need the object
                        _redocker = null;

                        return true;
                    }
                }
            }

            return false;
        }
        protected override void OnDoubleClick(EventArgs e)
        {
            // The double click event will cause the control to be destroyed as
            // the Contents are restored to their alternative positions, so need to
            // double check the control is not already dead
            if (!IsDisposed)
            {
                // Are we currently in a redocking state?
                if (_redocker != null)
                {
                    // No longer need the object
                    _redocker = null;
                }
            }

            // Fire attached event handlers
            OnRestore();
        }
        protected override void OnMouseDown(MouseEventArgs e)
        {
            // The double click event will cause the control to be destroyed as
            // the Contents are restored to their alternative positions, so need to
            // double check the control is not already dead
            if (!IsDisposed)
            {
                // Left mouse down begins a redocking action
                if (e.Button == MouseButtons.Left)
                {
                    if (this.ParentWindow.RedockAllowed)
                    {
                        WindowContent wc = this.ParentWindow as WindowContent;

                        // Is our parent a WindowContent instance?
                        if (wc != null)
                        {
                            // Start redocking activity for the whole WindowContent
                            _redocker = new RedockerContent(this, wc, new Point(e.X, e.Y));
                        }
                    }
                }

                this.Focus();
            }

            base.OnMouseDown(e);
        }
예제 #26
0
        protected override void WndProc(ref Message m)
        {
            // Want to notice when the window is maximized
            if (m.Msg == (int)Win32.Msgs.WM_NCLBUTTONDBLCLK)
            {
                // Redock and kill ourself
                Restore();

                // We do not want to let the base process the message as the
                // restore might fail due to lack of permission to restore to
                // old state.  In that case we do not want to maximize the window
                return;
            }
            else if (m.Msg == (int)Win32.Msgs.WM_NCLBUTTONDOWN)
            {
                if (!_intercept)
                {
                    // Perform a hit test against our own window to determine
                    // which area the mouse press is over at the moment.
                    uint result = User32.SendMessage(this.Handle, (int)Win32.Msgs.WM_NCHITTEST, 0, (uint)m.LParam);

                    // Only want to override the behviour of moving the window via the caption box
                    if (result == HITTEST_CAPTION)
                    {
                        // Remember new state
                        _intercept = true;

                        // Capture the mouse until the mouse us is received
                        this.Capture = true;

                        // Ensure that we gain focus and look active
                        this.Activate();

                        // Get mouse position to inscreen coordinates
                        Win32.POINT mousePos;
                        mousePos.x = (short)((uint)m.LParam & 0x0000FFFFU);
                        mousePos.y = (short)(uint)(((uint)m.LParam & 0xFFFF0000U) >> 16);

                        // Find adjustment to bring screen to client coordinates
                        Point topLeft = PointToScreen(new Point(0, 0));
                        topLeft.Y -= SystemInformation.CaptionHeight;
                        topLeft.X -= SystemInformation.BorderSize.Width;

                        // Begin a redocking activity
                        _redocker = new RedockerContent(this, new Point(mousePos.x - topLeft.X,
                                                        mousePos.y - topLeft.Y));

                        return;
                    }
                }
            }
            else if (m.Msg == (int)Win32.Msgs.WM_MOUSEMOVE)
            {
                if (_intercept)
                {
                    Win32.POINT mousePos;
                    mousePos.x = (short)((uint)m.LParam & 0x0000FFFFU);
                    mousePos.y = (short)(uint)(((uint)m.LParam & 0xFFFF0000U) >> 16);

                    _redocker.OnMouseMove(new MouseEventArgs(MouseButtons.Left,
                                          0,
                                          mousePos.x,
                                          mousePos.y,
                                          0));

                    return;
                }
            }
            else if (m.Msg == (int)Win32.Msgs.WM_LBUTTONUP)
            {
                if (_intercept)
                {
                    Win32.POINT mousePos;
                    mousePos.x = (short)((uint)m.LParam & 0x0000FFFFU);
                    mousePos.y = (short)(uint)(((uint)m.LParam & 0xFFFF0000U) >> 16);

                    _redocker.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 0,
                                                           mousePos.x, mousePos.y, 0));

                    // Release capture
                    this.Capture = false;

                    // Reset state
                    _intercept = false;

                    return;
                }
            }
            else if ((m.Msg == (int)Win32.Msgs.WM_NCRBUTTONUP) ||
                     (m.Msg == (int)Win32.Msgs.WM_NCMBUTTONDOWN) ||
                     (m.Msg == (int)Win32.Msgs.WM_NCMBUTTONUP) ||
                     (m.Msg == (int)Win32.Msgs.WM_RBUTTONDOWN) ||
                     (m.Msg == (int)Win32.Msgs.WM_RBUTTONUP) ||
                     (m.Msg == (int)Win32.Msgs.WM_MBUTTONDOWN) ||
                     (m.Msg == (int)Win32.Msgs.WM_MBUTTONUP))
            {
                // Prevent middle and right mouse buttons from interrupting
                // the correct operation of left mouse dragging
                return;
            }
            else if (m.Msg == (int)Win32.Msgs.WM_NCRBUTTONDOWN)
            {
                if (!_intercept)
                {
                    // Get screen coordinates of the mouse
                    Win32.POINT mousePos;
                    mousePos.x = (short)((uint)m.LParam & 0x0000FFFFU);
                    mousePos.y = (short)(uint)(((uint)m.LParam & 0xFFFF0000U) >> 16);

                    // Box to transfer as parameter
                    OnContext(new Point(mousePos.x, mousePos.y));

                    return;
                }
            }

            base.WndProc(ref m);
        }
예제 #27
0
        protected void OnPageDragStart(object sender, MouseEventArgs e)
        {
            if (this.RedockAllowed)
            {
                // There must be a selected page for this event to occur
                Magic.Controls.TabPage page = _tabControl.SelectedTab;

                // Event page must specify its Content object
                Content c = page.Tag as Content;

                // Remember the position of the tab before it is removed
                _dragPageIndex = _tabControl.TabPages.IndexOf(page);

                // Remove page from TabControl
                _tabControl.TabPages.Remove(page);

                // Force the entire window to redraw to ensure the Redocker does not start drawing
                // the XOR indicator before the window repaints itself. Otherwise the repainted
                // control will interfere with the XOR indicator.
                this.Refresh();

                // Start redocking activity for the single Content of this WindowContent
                _redocker = new RedockerContent(_tabControl, c, this, new Point(e.X, e.Y));
            }
        }
예제 #28
0
        public override bool ApplyChange(Point screenPos, Redocker parent)
        {
            // We are only called from the RedockerContent class
            RedockerContent redock = parent as RedockerContent;

            DockingManager dockingManager = redock.DockingManager;

            // Reduce flicker during transition
            dockingManager.Container.SuspendLayout();

            // Need to create a new Zone
            Zone zone;

            if (redock.DockingSource == RedockerContent.Source.FloatingForm)
            {
                // Make every Content object in the Floating Zone
                // record its current state as the Floating state
                redock.FloatingForm.ExitFloating();

                zone = redock.FloatingForm.Zone;
            }
            else
            {
                zone = dockingManager.CreateZoneForContent(_state);
            }

            // Insert Zone at end of Controls collection
            dockingManager.Container.Controls.Add(zone);

            // Adjust ordering
            switch (_position)
            {
            case Position.Inner:
                dockingManager.ReorderZoneToInnerMost(zone);
                break;

            case Position.Index:
                // Manageing Zones should remove display AutoHide windows
                dockingManager.RemoveShowingAutoHideWindows();

                // Place new Zone AFTER the one given, so need to increase index by one
                dockingManager.Container.Controls.SetChildIndex(zone, _newIndex + 1);
                break;

            case Position.Outer:
                dockingManager.ReorderZoneToOuterMost(zone);
                break;
            }

            switch (redock.DockingSource)
            {
            case RedockerContent.Source.RawContent:
            {
                // Create a new Window to host Content
                Window w = dockingManager.CreateWindowForContent(redock.Content);

                // Add into Zone
                zone.Windows.Add(w);
            }
            break;

            case RedockerContent.Source.WindowContent:
                // Remove WindowContent from old Zone
                if (redock.WindowContent.ParentZone != null)
                {
                    // If the source is leaving the Floating state then need to record Restore positions
                    if (redock.WindowContent.State == State.Floating)
                    {
                        foreach (Content c in redock.WindowContent.Contents)
                        {
                            c.ContentLeavesFloating();
                        }
                    }

                    redock.WindowContent.ParentZone.Windows.Remove(redock.WindowContent);
                }

                // Add into new Zone
                zone.Windows.Add(redock.WindowContent);
                break;

            case RedockerContent.Source.ContentInsideWindow:
            {
                // Remove Content from existing WindowContent
                if (redock.Content.ParentWindowContent != null)
                {
                    // If the source is leaving the Floating state then need to record Restore position
                    if (redock.Content.ParentWindowContent.State == State.Floating)
                    {
                        redock.Content.ContentLeavesFloating();
                    }

                    redock.Content.ParentWindowContent.Contents.Remove(redock.Content);
                }

                // Create a new WindowContent to host Content
                Window w = dockingManager.CreateWindowForContent(redock.Content);

                // Add into Zone
                zone.Windows.Add(w);
            }
            break;

            case RedockerContent.Source.FloatingForm:
                DockStyle ds;
                Direction direction;

                dockingManager.ValuesFromState(_state, out ds, out direction);

                // Define correct docking style to match state
                zone.Dock = ds;

                ZoneSequence zs = zone as ZoneSequence;

                // Define correct display direction to match state
                if (zs != null)
                {
                    zs.Direction = direction;
                }

                // Ensure the Zone recalculates contents according to new state
                zone.State = _state;
                break;
            }

            // Define correct size of the new Zone
            switch (_state)
            {
            case State.DockLeft:
            case State.DockRight:
                zone.Width = _newSize.Width;
                break;

            case State.DockTop:
            case State.DockBottom:
                zone.Height = _newSize.Height;
                break;
            }

            dockingManager.UpdateInsideFill();

            // Reduce flicker during transition
            dockingManager.Container.ResumeLayout();

            return(true);
        }
예제 #29
0
        protected override void WndProc(ref Message m)
        {
            // Want to notice when the window is maximized
            if (m.Msg == (int)Win32.Msgs.WM_NCLBUTTONDBLCLK)
            {
                // Redock and kill ourself
                Restore();

                // We do not want to let the base process the message as the
                // restore might fail due to lack of permission to restore to
                // old state.  In that case we do not want to maximize the window
                return;
            }
            else if (m.Msg == (int)Win32.Msgs.WM_NCLBUTTONDOWN)
            {
                if (!_intercept)
                {
                    // Perform a hit test against our own window to determine
                    // which area the mouse press is over at the moment.
                    uint result = User32.SendMessage(this.Handle, (int)Win32.Msgs.WM_NCHITTEST, 0, (uint)m.LParam);

                    // Only want to override the behviour of moving the window via the caption box
                    if (result == HITTEST_CAPTION)
                    {
                        // Remember new state
                        _intercept = true;

                        // Capture the mouse until the mouse us is received
                        this.Capture = true;

                        // Ensure that we gain focus and look active
                        this.Activate();

                        // Get mouse position to inscreen coordinates
                        Win32.POINT mousePos;
                        mousePos.x = (short)((uint)m.LParam & 0x0000FFFFU);
                        mousePos.y = (short)(uint)(((uint)m.LParam & 0xFFFF0000U) >> 16);

                        // Find adjustment to bring screen to client coordinates
                        Point topLeft = PointToScreen(new Point(0, 0));
                        topLeft.Y -= SystemInformation.CaptionHeight;
                        topLeft.X -= SystemInformation.BorderSize.Width;

                        // Begin a redocking activity
                        _redocker = new RedockerContent(this, new Point(mousePos.x - topLeft.X,
                                                                        mousePos.y - topLeft.Y));


                        return;
                    }
                }
            }
            else if (m.Msg == (int)Win32.Msgs.WM_MOUSEMOVE)
            {
                if (_intercept)
                {
                    Win32.POINT mousePos;
                    mousePos.x = (short)((uint)m.LParam & 0x0000FFFFU);
                    mousePos.y = (short)(uint)(((uint)m.LParam & 0xFFFF0000U) >> 16);

                    _redocker.OnMouseMove(new MouseEventArgs(MouseButtons.Left,
                                                             0, mousePos.x, mousePos.y, 0));

                    return;
                }
            }
            else if ((m.Msg == (int)Win32.Msgs.WM_RBUTTONDOWN) ||
                     (m.Msg == (int)Win32.Msgs.WM_MBUTTONDOWN))
            {
                if (_intercept)
                {
                    Win32.POINT mousePos;
                    mousePos.x = (short)((uint)m.LParam & 0x0000FFFFU);
                    mousePos.y = (short)(uint)(((uint)m.LParam & 0xFFFF0000U) >> 16);

                    _redocker.QuitTrackingMode(new MouseEventArgs(MouseButtons.Left,
                                                                  0, mousePos.x, mousePos.y, 0));

                    // Release capture
                    this.Capture = false;

                    // Reset state
                    _intercept = false;

                    return;
                }
            }
            else if (m.Msg == (int)Win32.Msgs.WM_LBUTTONUP)
            {
                if (_intercept)
                {
                    Win32.POINT mousePos;
                    mousePos.x = (short)((uint)m.LParam & 0x0000FFFFU);
                    mousePos.y = (short)(uint)(((uint)m.LParam & 0xFFFF0000U) >> 16);

                    _redocker.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 0,
                                                           mousePos.x, mousePos.y, 0));

                    // Release capture
                    this.Capture = false;

                    // Reset state
                    _intercept = false;

                    return;
                }
            }
            else if ((m.Msg == (int)Win32.Msgs.WM_NCRBUTTONUP) ||
                     (m.Msg == (int)Win32.Msgs.WM_NCMBUTTONDOWN) ||
                     (m.Msg == (int)Win32.Msgs.WM_NCMBUTTONUP) ||
                     (m.Msg == (int)Win32.Msgs.WM_RBUTTONDOWN) ||
                     (m.Msg == (int)Win32.Msgs.WM_RBUTTONUP) ||
                     (m.Msg == (int)Win32.Msgs.WM_MBUTTONDOWN) ||
                     (m.Msg == (int)Win32.Msgs.WM_MBUTTONUP))
            {
                // Prevent middle and right mouse buttons from interrupting
                // the correct operation of left mouse dragging
                return;
            }
            else if (m.Msg == (int)Win32.Msgs.WM_NCRBUTTONDOWN)
            {
                if (!_intercept)
                {
                    // Get screen coordinates of the mouse
                    Win32.POINT mousePos;
                    mousePos.x = (short)((uint)m.LParam & 0x0000FFFFU);
                    mousePos.y = (short)(uint)(((uint)m.LParam & 0xFFFF0000U) >> 16);

                    // Box to transfer as parameter
                    OnContext(new Point(mousePos.x, mousePos.y));

                    return;
                }
            }

            base.WndProc(ref m);
        }
        protected override void OnMouseUp(MouseEventArgs e)
        {
            // The double click event will cause the control to be destroyed as
            // the Contents are restored to their alternative positions, so need to
            // double check the control is not already dead
            if (!IsDisposed)
            {
                // Are we currently in a redocking state?
                if (_redocker != null)
                {
                    // Let the redocker finish off
                    _redocker.OnMouseUp(e);

                    // No longer need the object
                    _redocker = null;
                }

                // Right mouse button can generate a Context event
                if (e.Button == MouseButtons.Right)
                {
                    // Get screen coordinates of the mouse
                    Point pt = this.PointToScreen(new Point(e.X, e.Y));

                    // Box to transfer as parameter
                    OnContext(pt);
                }
            }

            base.OnMouseUp(e);
        }
예제 #31
0
        public override bool ApplyChange(Point screenPos, Redocker parent)
        {
            // Should always be the appropriate type
            RedockerContent redock = parent as RedockerContent;

            DockingManager dockingManager = redock.DockingManager;

            Zone newZone = null;

            // Manageing Zones should remove display AutoHide windows
            dockingManager.RemoveShowingAutoHideWindows();

            switch (redock.DockingSource)
            {
            case RedockerContent.Source.RawContent:
            {
                // Perform State specific Restore actions
                redock.Content.ContentBecomesFloating();

                // Create a new Window to host Content
                Window w = dockingManager.CreateWindowForContent(redock.Content);

                // We need to create a Zone for containing the transfered content
                newZone = dockingManager.CreateZoneForContent(State.Floating);

                // Add into Zone
                newZone.Windows.Add(w);
            }
            break;

            case RedockerContent.Source.WindowContent:
                // Perform State specific Restore actions
                foreach (Content c in redock.WindowContent.Contents)
                {
                    c.ContentBecomesFloating();
                }

                // Remove WindowContent from old Zone
                if (redock.WindowContent.ParentZone != null)
                {
                    redock.WindowContent.ParentZone.Windows.Remove(redock.WindowContent);
                }

                // We need to create a Zone for containing the transfered content
                newZone = dockingManager.CreateZoneForContent(State.Floating);

                // Add into new Zone
                newZone.Windows.Add(redock.WindowContent);
                break;

            case RedockerContent.Source.ContentInsideWindow:
            {
                // Perform State specific Restore actions
                redock.Content.ContentBecomesFloating();

                // Remove Content from existing WindowContent
                if (redock.Content.ParentWindowContent != null)
                {
                    redock.Content.ParentWindowContent.Contents.Remove(redock.Content);
                }

                // Create a new Window to host Content
                Window w = dockingManager.CreateWindowForContent(redock.Content);

                // We need to create a Zone for containing the transfered content
                newZone = dockingManager.CreateZoneForContent(State.Floating);

                // Add into Zone
                newZone.Windows.Add(w);
            }
            break;

            case RedockerContent.Source.FloatingForm:
                redock.FloatingForm.Location = new Point(screenPos.X - _offset.X,
                                                         screenPos.Y - _offset.Y);

                return(false);
            }

            dockingManager.UpdateInsideFill();

            // Create a new floating form
            FloatingForm floating = new FloatingForm(redock.DockingManager, newZone,
                                                     new ContextHandler(dockingManager.OnShowContextMenu));

            // Find screen location/size
            _drawRect = new Rectangle(screenPos.X, screenPos.Y, _newSize.Width, _newSize.Height);

            // Adjust for mouse starting position relative to source control
            _drawRect.X -= _offset.X;
            _drawRect.Y -= _offset.Y;

            // Define its location/size
            floating.Location = new Point(_drawRect.Left, _drawRect.Top);
            floating.Size     = new Size(_drawRect.Width, _drawRect.Height);

            // Show it!
            floating.Show();

            return(true);
        }
        protected void OnPageDragQuit(object sender, MouseEventArgs e)
        {
            try
                    {
            // Are we currently in a redocking state?
            if (_redocker != null)
            {
                // Put back the page that was removed when dragging started
                RestoreDraggingPage();

                // No longer need the object
                _redocker = null;
            }
                    }
                    catch(System.Exception ex)
                    {MessageBox.Show(ex.Message);}
        }