Esempio n. 1
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);
        }
Esempio n. 2
0
 public HotZoneSequence(Rectangle hotArea, Rectangle newSize, ZoneSequence zs, int index)
     : base(hotArea, newSize)
 {
     _index = index;
     _zs    = zs;
 }
Esempio n. 3
0
        /// <summary>
        /// Perform a restore using provided zone.
        /// </summary>
        /// <param name="z">Reference to source.</param>
        public override void PerformRestore(Zone z)
        {
            int count       = z.Windows.Count;
            int beforeIndex = -1;
            int afterIndex  = count;

            // Find the match to one of our best friends
            for (int index = 0; index < count; index++)
            {
                WindowContent wc = z.Windows[index] as WindowContent;

                if (wc != null)
                {
                    // If this WindowContent contains a best friend, then add ourself here as well
                    if (wc.Contents.ContainsTitleOrUnique(_best))
                    {
                        if (Child == null)
                        {
                            // If we do not have a Restore object for the Window then just add
                            // into the WindowContent at the end of the existing Contents
                            wc.Contents.Add(Content);
                        }
                        else
                        {
                            // Get the child to restore as best as possible inside WindowContent
                            Child.PerformRestore(wc);
                        }

                        return;
                    }

                    // If the WindowContent contains a Content previous to the target
                    if (wc.Contents.ContainsTitleOrUnique(_previous))
                    {
                        if (index > beforeIndex)
                        {
                            beforeIndex = index;
                        }
                    }

                    // If the WindowContent contains a Content next to the target
                    if (wc.Contents.ContainsTitleOrUnique(_next))
                    {
                        if (index < afterIndex)
                        {
                            afterIndex = index;
                        }
                    }
                }
            }

            // If we get here then we did not find any best friends, this
            // means we need to create a new WindowContent to host the Content.
            Window newW = z.DockingManager.CreateWindowForContent(Content);

            ZoneSequence zs = z as ZoneSequence;

            // If this is inside a ZoneSequence instance
            if (zs != null)
            {
                // Do not reposition the Windows on the .Insert but instead ignore the
                // reposition and let it happen in the .ModifyWindowSpace. This reduces
                // the flicker that would occur otherwise
                zs.SuppressReposition();
            }

            // Need to find the best place in the order for the Content, start by
            // looking for the last 'previous' content and place immediately after it
            if (beforeIndex >= 0)
            {
                // Great, insert after it
                z.Windows.Insert(beforeIndex + 1, newW);
            }
            else
            {
                // No joy, so find the first 'next' content and place just before it, if
                // none are found then just add to the end of the collection.
                z.Windows.Insert(afterIndex, newW);
            }

            // If this is inside a ZoneSequence instance
            if (zs != null)
            {
                // We want to try and allocate the correct Zone space
                zs.ModifyWindowSpace(newW, _space);
            }
        }