Example #1
0
        public override void PerformRestore(Window w)
        {
            // We are only ever called for a WindowContent object
            WindowContent wc = w as WindowContent;

            int bestIndex = -1;

            foreach (String s in _previous)
            {
                if (wc.Contents.Contains(s))
                {
                    int previousIndex = wc.Contents.IndexOf(wc.Contents[s]);

                    if (previousIndex > bestIndex)
                    {
                        bestIndex = previousIndex;
                    }
                }
            }

            // Did we find a previous Content?
            if (bestIndex >= 0)
            {
                // Great, insert after it
                wc.Contents.Insert(bestIndex + 1, _content);
            }
            else
            {
                bestIndex = wc.Contents.Count;

                foreach (String s in _next)
                {
                    if (wc.Contents.Contains(s))
                    {
                        int nextIndex = wc.Contents.IndexOf(wc.Contents[s]);

                        if (nextIndex < bestIndex)
                        {
                            bestIndex = nextIndex;
                        }
                    }
                }

                // Insert before the found entry (or at end if non found)
                wc.Contents.Insert(bestIndex, _content);
            }

            // Should this content become selected?
            if (_selected)
            {
                _content.BringToFront();
            }
        }
Example #2
0
        protected void InternalConstruct(DockingManager manager,
                                         Control control,
                                         string title,
                                         ImageList imageList,
                                         int imageIndex)
        {
            // Must provide a valid manager instance
            if (manager == null)
            {
                throw new ArgumentNullException("DockingManager");
            }

            // Define the initial object state
            _control             = control;
            _title               = title;
            _imageList           = imageList;
            _imageIndex          = imageIndex;
            _manager             = manager;
            _parentWindowContent = null;
            _order               = _counter++;
            _visible             = false;
            _displaySize         = new Size(_defaultDisplaySize, _defaultDisplaySize);
            _autoHideSize        = new Size(_defaultAutoHideSize, _defaultAutoHideSize);
            _floatingSize        = new Size(_defaultFloatingSize, _defaultFloatingSize);
            _displayLocation     = new Point(_defaultLocation, _defaultLocation);
            _defaultRestore      = new RestoreContentState(State.DockLeft, this);
            _floatingRestore     = new RestoreContentState(State.Floating, this);
            _autoHideRestore     = new RestoreAutoHideState(State.DockLeft, this);
            _dockingRestore      = _defaultRestore;
            _autoHidePanel       = null;
            _docked              = true;
            _captionBar          = true;
            _closeButton         = true;
            _hideButton          = true;
            _autoHidden          = false;
            _fullTitle           = title;

            _allowDocking = true;
        }
Example #3
0
        public static StringCollection ContentNames(Zone z)
        {
            // Container for returned group of found String objects
            StringCollection sc = new StringCollection();

            // Process each Window in the Zone
            foreach (Window w in z.Windows)
            {
                WindowContent wc = w as WindowContent;

                // Is the Zone a Content derived variation?
                if (wc != null)
                {
                    // Add each Content into the collection
                    foreach (Content c in wc.Contents)
                    {
                        sc.Add(c.Title);
                    }
                }
            }

            return(sc);
        }
Example #4
0
        public static ContentCollection Contents(Zone z)
        {
            // Container for returned group of found Content objects
            ContentCollection cc = new ContentCollection();

            // Process each Window in the Zone
            foreach (Window w in z.Windows)
            {
                WindowContent wc = w as WindowContent;

                // Is the Zone a Content derived variation?
                if (wc != null)
                {
                    // Add each Content into the collection
                    foreach (Content c in wc.Contents)
                    {
                        cc.Add(c);
                    }
                }
            }

            return(cc);
        }
Example #5
0
        public static StringCollection ContentNamesInPriority(Zone z, Content c)
        {
            // Container for returned group of found Content objects
            StringCollection sc = new StringCollection();

            // Process each Window in the Zone
            foreach (Window w in z.Windows)
            {
                WindowContent wc = w as WindowContent;

                // Is the Zone a Content derived variation?
                if (wc != null)
                {
                    // Does this contain the interesting Content?
                    if (wc.Contents.Contains(c))
                    {
                        // All Content of this Window are given priority and
                        // added into the start of the collection
                        foreach (Content content in wc.Contents)
                        {
                            sc.Insert(0, content.Title);
                        }
                    }
                    else
                    {
                        // Lower priority Window and so contents are always
                        // added to the end of the collection
                        foreach (Content content in wc.Contents)
                        {
                            sc.Add(content.Title);
                        }
                    }
                }
            }

            return(sc);
        }
Example #6
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);
        }
Example #7
0
 public RedockerContent(Control callingControl, WindowContent wc, Point offset)
 {
     InternalConstruct(callingControl, Source.WindowContent, null, wc, null, wc.DockingManager, offset);
 }
Example #8
0
 public RedockerContent(Control callingControl, Content c, WindowContent wc, Point offset)
 {
     InternalConstruct(callingControl, Source.ContentInsideWindow, c, wc, null, c.DockingManager, offset);
 }
Example #9
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);
        }
Example #10
0
        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.Contains(_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.Contains(_previous))
                    {
                        if (index > beforeIndex)
                        {
                            beforeIndex = index;
                        }
                    }

                    // If the WindowContent contains a Content next to the target
                    if (wc.Contents.Contains(_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);
            }
        }