Beispiel #1
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);
                }
            }
        }
Beispiel #2
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));
            }
        }
Beispiel #3
0
        public override void UpdateForMousePosition(Point screenPos, Redocker parent)
        {
            // Remember the current mouse pos
            Point newPos = screenPos;

            // Calculate the new drawing rectangle
            Rectangle newRect = new Rectangle(newPos.X, newPos.Y, _newSize.Width, _newSize.Height);

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

            // Draw both the old rectangle and the new one, that will remove flicker as the
            // draw method will only actually draw areas that differ between the two rectangles
            DrawHelper.DrawDragRectangles(new Rectangle[] { _drawRect, newRect }, _dragWidth);

            // Remember new values
            _drawPos  = newPos;
            _drawRect = newRect;
        }
Beispiel #4
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);
        }
Beispiel #5
0
 public virtual void UpdateForMousePosition(Point screenPos, Redocker parent)
 {
 }
Beispiel #6
0
 public virtual bool ApplyChange(Point screenPos, Redocker parent)
 {
     return(false);
 }
Beispiel #7
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);
        }
Beispiel #8
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);
        }
Beispiel #9
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);
        }