Exemple #1
0
        protected void InternalConstruct(Control callingControl,
                                         Source source,
                                         Content c,
                                         WindowContent wc,
                                         FloatingForm ff,
                                         DockingManager dm,
                                         Point offset)
        {
            // Store the starting state
            _callingControl = callingControl;
            _source         = source;
            _content        = c;
            _windowContent  = wc;
            _dockingManager = dm;
            _container      = _dockingManager.Container;
            _floatingForm   = ff;
            _hotZones       = null;
            _currentHotZone = null;
            _insideRect     = new Rectangle();
            _outsideRect    = new Rectangle();
            _offset         = offset;

            // Begin tracking straight away
            EnterTrackingMode();
        }
Exemple #2
0
        public Content(XmlTextReader xmlIn, int formatVersion)
        {
            // Define the initial object state
            _control             = null;
            _title               = "";
            _fullTitle           = "";
            _imageList           = null;
            _icon                = null;
            _imageIndex          = -1;
            _manager             = null;
            _parentWindowContent = null;
            _displaySize         = new Size(_defaultDisplaySize, _defaultDisplaySize);
            _autoHideSize        = new Size(_defaultAutoHideSize, _defaultAutoHideSize);
            _floatingSize        = new Size(_defaultFloatingSize, _defaultFloatingSize);
            _displayLocation     = new Point(_defaultLocation, _defaultLocation);
            _order               = _counter++;
            _tag             = null;
            _visible         = false;
            _defaultRestore  = null;
            _autoHideRestore = null;
            _floatingRestore = null;
            _dockingRestore  = null;
            _autoHidePanel   = null;
            _docked          = true;
            _captionBar      = true;
            _closeButton     = true;
            _hideButton      = true;
            _autoHidden      = false;
            _closeOnHide     = false;

            // Overwrite default with values read in
            LoadFromXml(xmlIn, formatVersion);
        }
Exemple #3
0
        public Content(XmlTextReader xmlIn, int formatVersion)
        {
            // Define the initial object state
            _control = null;
            _title = "";
            _fullTitle = "";
            _imageList = null;
            _icon = null;
            _imageIndex = -1;
            _manager = null;
            _parentWindowContent = null;
            _displaySize = new Size(_defaultDisplaySize, _defaultDisplaySize);
            _autoHideSize = new Size(_defaultAutoHideSize, _defaultAutoHideSize);
            _floatingSize = new Size(_defaultFloatingSize, _defaultFloatingSize);
            _displayLocation = new Point(_defaultLocation, _defaultLocation);
            _order = _counter++;
            _tag = null;
            _visible = false;
            _defaultRestore = null;
            _autoHideRestore = null;
            _floatingRestore = null;
            _dockingRestore = null;
            _autoHidePanel = null;
            _docked = true;
            _captionBar = true;
            _closeButton = true;
            _hideButton = true;
            _autoHidden = false;
            _closeOnHide = false;

            // Overwrite default with values read in
            LoadFromXml(xmlIn, formatVersion);
        }
        protected void InternalConstruct(Control callingControl, 
                                         Source source, 
                                         Content c, 
                                         WindowContent wc, 
                                         FloatingForm ff,
                                         DockingManager dm,
                                         Point offset)
        {
            // Store the starting state
            _callingControl = callingControl;
            _source = source;
            _content = c;
            _windowContent = wc;
            _dockingManager = dm;
            _container = _dockingManager.Container;
            _floatingForm = ff;
            _hotZones = null;
            _currentHotZone = null;
            _insideRect = new Rectangle();
            _outsideRect = new Rectangle();
            _offset = offset;

            // Begin tracking straight away
            EnterTrackingMode();
        }
Exemple #5
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();
            }
        }
Exemple #6
0
        protected void InternalConstruct(DockingManager manager,
                                         Control control,
                                         string title,
                                         ImageList imageList,
                                         int imageIndex,
                                         Icon icon)
        {
            // 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;
            _icon                = icon;
            _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;
            _tag         = null;
            _docked      = true;
            _captionBar  = true;
            _closeButton = true;
            _hideButton  = true;
            _autoHidden  = false;
            _closeOnHide = false;
            _fullTitle   = title;
        }
        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);
        }
Exemple #8
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);
        }
Exemple #9
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);
        }
Exemple #10
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);
        }
Exemple #11
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);
        }
        public MainForm(string strOpenFileName)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            m_dkm = new DockingManager(this, VisualStyle.IDE);
            Globals.ActiveDocumentChanged += new EventHandler(OnActiveDocumentChanged);
            m_doc = Globals.ActiveDocument;
            Globals.MainForm = this;

            // Create all the "Contents" used to display the various animation components

            m_ctlPreviewPanel = new PreviewPanel(m_doc);
            Globals.PreviewControl = m_ctlPreviewPanel.PreviewControl;
            m_ctlPreviewPanel.Dock = DockStyle.Fill;
            Controls.Add(m_ctlPreviewPanel);
            m_dkm.InnerControl = m_ctlPreviewPanel;

            m_frmStrips = new StripsForm(m_doc);
            Globals.StripsForm = m_frmStrips;
            m_tntStrips = m_dkm.Contents.Add(m_frmStrips, m_frmStrips.Text);
            m_tntStrips.DisplaySize = new Size(ClientSize.Width / 4, ClientSize.Height / 2);
            m_wcStrips = m_dkm.AddContentWithState(m_tntStrips, State.DockLeft);

            m_frmBitmaps = new BitmapsForm(m_doc);
            m_tntBitmaps = m_dkm.Contents.Add(m_frmBitmaps, m_frmBitmaps.Text);
            m_tntBitmaps.DisplaySize = new Size(ClientSize.Width / 4, ClientSize.Height / 2);
            m_dkm.AddContentWithState(m_tntBitmaps, State.DockTop);

            // Add the Bitmaps form to the StripForm's Zone

            m_dkm.AddContentToZone(m_tntBitmaps, m_wcStrips.ParentZone, 1);

            m_frmFrames = new StripForm(m_doc);
            Globals.StripForm = m_frmFrames;
            m_tntFrames = m_dkm.Contents.Add(m_frmFrames, m_frmFrames.Text);
            m_frmFrames.Content = m_tntFrames;
            int cx = ClientSize.Width - (ClientSize.Width / 4);
            int cy = ClientSize.Height / 3;
            m_tntFrames.DisplaySize = new Size(cx, cy);
            m_dkm.AddContentWithState(m_tntFrames, State.DockBottom);

            m_frmCombiner = new CombinerForm();
            m_tntCombiner = m_dkm.Contents.Add(m_frmCombiner, m_frmCombiner.Text);
            m_tntCombiner.DisplaySize = new Size(ClientSize.Width / 2, ClientSize.Height / 2);
            //			m_dkm.AddContentWithState(m_tntCombiner, State.Floating);
            //			m_dkm.HideContent(m_tntCombiner);

            // Do a little wiring

            ((StripControl)Globals.StripControl).FrameOffsetChanged +=
                    new FrameOffsetEventHandler(((PreviewControl)Globals.PreviewControl).OnFrameOffsetChanged);
            ((PreviewControl)Globals.PreviewControl).FrameOffsetChanged +=
                new FrameOffsetEventHandler(((StripControl)Globals.StripControl).OnFrameOffsetChanged);

            // We always have a document around

            if (strOpenFileName == null)
                NewDocument();
            else
                OpenDocument(strOpenFileName);
        }
Exemple #13
0
        protected void InternalConstruct(DockingManager manager, 
            Control control,
            string title,
            ImageList imageList,
            int imageIndex,
            Icon icon)
        {
            // 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;
            _icon = icon;
            _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;
            _tag = null;
            _docked = true;
            _captionBar = true;
            _closeButton = true;
            _hideButton = true;
            _autoHidden = false;
            _closeOnHide = false;
            _fullTitle = title;
        }
Exemple #14
0
        protected virtual void InvertAutoHideWindowContent(WindowContent wc)
        {
            // Do not generate hiding/hidden/shown events
            _surpressVisibleEvents++;

            // Create a collection of the Content in the same window
            ContentCollection cc = new ContentCollection();

            // Add all Content into collection
            foreach(Content c in wc.Contents)
                cc.Add(c);

            // Add to the correct AutoHidePanel
            AutoHideContents(cc, wc.State);

            // Enable generate hiding/hidden/shown events
            _surpressVisibleEvents--;
        }
Exemple #15
0
 public RedockerContent(Control callingControl, Content c, WindowContent wc, Point offset)
 {
     InternalConstruct(callingControl, Source.ContentInsideWindow, c, wc, null, c.DockingManager, offset);
 }
Exemple #16
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);
            }
        }
		public void ShowPad(IPadContent content)
		{
			if (contentHash[content] == null) 
			{
				IProperties properties = (IProperties)propertyService.GetProperty("Workspace.ViewMementos", new DefaultProperties());
				string type = content.GetType().ToString();
				content.Control.Dock = DockStyle.None;
				Content c1;
				if (content.Icon != null) 
				{
					ImageList imgList = new ImageList();
					imgList.Images.Add(content.Icon);
					c1 = dockManager.Contents.Add(content.Control, content.Title, imgList, 0);
				} 
				else 
				{
					c1 = dockManager.Contents.Add(content.Control, content.Title);
				}

                c1.DisplaySize = new Size(270, 200);

				contentHash[content] = c1;


                if (properties.GetProperty(type, "Left") == "Left")
                {
                    if (leftContent == null)
                    {
                        leftContent = dockManager.AddContentWithState(c1, State.DockLeft);
                    }
                    else
                    {
                        dockManager.AddContentToWindowContent(c1, leftContent);
                    }
                }
                else if (properties.GetProperty(type, "Left") == "Bottom")
                {
                    if (bottomContent == null)
                    {
                        bottomContent = dockManager.AddContentWithState(c1, State.DockBottom);
                    }
                    else
                    {
                        dockManager.AddContentToWindowContent(c1, bottomContent);
                    }
                }
			} 
			else 
			{
				Content c = (Content)contentHash[content];
				if (c != null) 
				{
					dockManager.ShowContent(c);
				}
			}
		}
Exemple #18
0
 public RedockerContent(Control callingControl, WindowContent wc, Point offset)
 {
     InternalConstruct(callingControl, Source.WindowContent, null, wc, null, wc.DockingManager, offset);
 }
Exemple #19
0
 public RedockerContent(Control callingControl, Content c, WindowContent wc, Point offset)
 {
     InternalConstruct(callingControl, Source.ContentInsideWindow, c, wc, null, c.DockingManager, offset);
 }
Exemple #20
0
 public RedockerContent(Control callingControl, WindowContent wc, Point offset)
 {
     InternalConstruct(callingControl, Source.WindowContent, null, wc, null, wc.DockingManager, offset);
 }
Exemple #21
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;
            }
        }
Exemple #22
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);
        }