예제 #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();
        }
예제 #2
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();
        }
예제 #3
0
파일: Restore.cs 프로젝트: Zekka/labyrinth3
        public override void PerformRestore(DockingManager dm)
        {
            // Grab a list of all floating forms
            Form[] owned = dm.Container.FindForm().OwnedForms;

            FloatingForm target = null;

            // Find the match to one of our best friends
            foreach (Form f in owned)
            {
                FloatingForm ff = f as FloatingForm;

                if (ff != null)
                {
                    if (ZoneHelper.ContentNames(ff.Zone).Contains(_best))
                    {
                        target = ff;
                        break;
                    }
                }
            }

            // If no friends then try associates as second best option
            if (target == null)
            {
                // Find the match to one of our best friends
                foreach (Form f in owned)
                {
                    FloatingForm ff = f as FloatingForm;

                    if (ff != null)
                    {
                        if (ZoneHelper.ContentNames(ff.Zone).Contains(_associates))
                        {
                            target = ff;
                            break;
                        }
                    }
                }
            }

            // If we found a friend/associate, then restore to it
            if (target != null)
            {
                // We should have a child and be able to restore to its Zone
                _child.PerformRestore(target.Zone);
            }
            else
            {
                // Restore its location/size
                _content.DisplayLocation = _location;
                _content.DisplaySize     = _size;

                // Use the docking manage method to create us a new Floating Window at correct size/location
                dm.AddContentWithState(_content, State.Floating);
            }
        }
예제 #4
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);
        }
예제 #5
0
        public WindowContent AddContentWithState(Content c, State newState)
        {
            // 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;

            // 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)
            {
                // If it used to be in a floating mode, then record state change
                if (c.ParentWindowContent.ParentZone.State == State.Floating)
                    c.ContentLeavesFloating();

                // Remove the Content from its current WindowContent
                c.ParentWindowContent.Contents.Remove(c);
            }

            // Create a new Window instance appropriate for hosting a Content object
            Window w = CreateWindowForContent(c);

            ContainerControl destination = null;

            if (newState != State.Floating)
            {
                destination = _container;
                destination.SuspendLayout();
            }

            // Create a new Zone capable of hosting a WindowContent
            Zone z = CreateZoneForContent(newState, destination);

            if (newState == State.Floating)
            {
                // Content is not in the docked state
                c.Docked = false;

                // destination a new floating form
                destination = new FloatingForm(this, z, new ContextHandler(OnShowContextMenu));

                // Define its location
                destination.Location = c.DisplayLocation;

                // ...and its size, add the height of the caption bar to the requested content size
                destination.Size = new Size(c.FloatingSize.Width,
                                            c.FloatingSize.Height + SystemInformation.ToolWindowCaptionHeight);
            }

            // Add the Window to the Zone
            z.Windows.Add(w);

            if (newState != State.Floating)
            {
                // Set the Zone to be the least important of our Zones
                ReorderZoneToInnerMost(z);

                UpdateInsideFill();

                destination.ResumeLayout();
            }
            else
                destination.Show();

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

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

            return w as WindowContent;
        }
        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;
        }
예제 #7
0
 public RedockerContent(FloatingForm ff, Point offset)
 {
     InternalConstruct(ff, Source.FloatingForm, null, null, ff, ff.DockingManager, offset);
 }
예제 #8
0
 public RedockerContent(FloatingForm ff, Point offset)
 {
     InternalConstruct(ff, Source.FloatingForm, null, null, ff, ff.DockingManager, offset);
 }