Exemplo n.º 1
0
        public WindowContent InsertContentIntoWindowContent(int pos, Content c, WindowContent wc)
        {
            // Validate the incoming Content instance is a valid reference
            // and is a current instance within our internal collection
            if ((c == null) || !_contents.Contains(c))
                return null;

            // Validate the incoming WindowContent instance is a valid reference
            if (wc == null)
                return null;

            // Is Content already part of given Window then nothing to do
            if (c.ParentWindowContent == wc)
                return wc;
            else
            {
                bool valid = true;

                // Do not generate hiding/hidden/shown events
                _surpressVisibleEvents++;

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

                if (c.ParentWindowContent != null)
                {
                    // Is there a change in docking state?
                    if (c.ParentWindowContent.ParentZone.State != wc.ParentZone.State)
                    {
                        // If it used to be in a floating mode, then record state change
                        if (c.ParentWindowContent.ParentZone.State == State.Floating)
                            c.ContentLeavesFloating();
                        else
                            c.ContentBecomesFloating();
                    }

                    // Remove the Content from its current WindowContent
                    c.ParentWindowContent.Contents.Remove(c);
                }
                else
                {
                    // If a window content is in AutoHide then it will not have a parent zone
                    if (wc.ParentZone != null)
                    {
                        // If adding to a floating window then it is not docked
                        if (wc.ParentZone.State == State.Floating)
                            c.Docked = false;
                    }
                    else
                    {
                        // Cannot dynamically add into an autohide parent
                        valid = false;
                    }
                }

                if (valid)
                {
                    // Add the existing Content to this instance
                    wc.Contents.Insert(pos, c);
                }

                // Enable generation hiding/hidden/shown events
                _surpressVisibleEvents--;

                if (valid)
                {
                    // Generate event to indicate content is now visible
                    OnContentShown(c);
                }

                return wc;
            }
        }
Exemplo n.º 2
0
        public Window AddContentToZone(Content c, Zone z, int index)
        {
            // Validate the incoming Content instance is a valid reference
            // and is a current instance within our internal collection
            if ((c == null) || !_contents.Contains(c))
                return null;

            // Validate the incoming Zone instance is a valid reference
            if (z == null)
                return null;

            // Do not generate hiding/hidden/shown events
            _surpressVisibleEvents++;

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

            // Is the window already part of a WindowContent?
            if (c.ParentWindowContent != null)
            {
                // Is there a change in docking state?
                if (c.ParentWindowContent.ParentZone.State != z.State)
                {
                    // If it used to be in a floating mode, then record state change
                    if (c.ParentWindowContent.ParentZone.State == State.Floating)
                        c.ContentLeavesFloating();
                    else
                        c.ContentBecomesFloating();
                }

                // Remove the Content from its current WindowContent
                c.ParentWindowContent.Contents.Remove(c);
            }
            else
            {
                // If target zone is floating window then we are no longer docked
                if (z.State == State.Floating)
                    c.Docked = false;
            }

            // Create a new WindowContent instance according to our style
            Window w = CreateWindowForContent(c);

            // Add the Window to the Zone at given position
            z.Windows.Insert(index, w);

            // Enable generation hiding/hidden/shown events
            _surpressVisibleEvents--;

            // Generate event to indicate content is now visible
            OnContentShown(c);

            return w;
        }