コード例 #1
0
ファイル: FloatingForm.cs プロジェクト: zhaoyin/officeOBA
        /// <summary>
        /// Restore the zone.
        /// </summary>
        protected void Restore()
        {
            if (_zone != null)
            {
                ContentCollection cc = ZoneHelper.Contents(_zone);

                // Record restore object for each Content
                foreach (Content c in cc)
                {
                    c.RecordFloatingRestore();
                    c.Docked = true;
                }

                // Ensure each content is removed from any Parent
                foreach (Content c in cc)
                {
                    _dockingManager.HideContent(c, false, true);
                }

                // Now restore each of the Content
                foreach (Content c in cc)
                {
                    _dockingManager.ShowContent(c);
                }

                // Finished all changes, no its safe to update inside fill
                _dockingManager.UpdateInsideFill();
                _dockingManager.CheckResized();
            }

            this.Close();
        }
コード例 #2
0
ファイル: FloatingForm.cs プロジェクト: zhaoyin/officeOBA
        /// <summary>
        /// Close each of the content that are allowed to be removed.
        /// </summary>
        /// <param name="e">A CancelEventArgs structure contained event data.</param>
        protected override void OnClosing(CancelEventArgs e)
        {
            if (_zone != null)
            {
                ContentCollection cc = ZoneHelper.Contents(_zone);

                // Record restore object for each Content
                foreach (Content c in cc)
                {
                    c.RecordRestore();
                }

                // Ensure each content is removed from any Parent
                foreach (Content c in cc)
                {
                    // Is content allowed to be hidden?
                    if (!_dockingManager.OnContentHiding(c))
                    {
                        // Hide the content always
                        _dockingManager.HideContent(c, false, true);

                        // Do we also remove the content?
                        if (c.CloseOnHide)
                        {
                            // Remove the content from the collection
                            _dockingManager.Contents.Remove(c);

                            // Dispose of the contained control/form
                            if (c.Control != null)
                            {
                                c.Control.Dispose();
                            }
                        }
                    }
                    else
                    {
                        // At least one Content refuses to die, so do not
                        // let the whole floating form be closed down
                        e.Cancel = true;
                    }
                }
            }

            // Must set focus back to the main application Window
            if (this.Owner != null)
            {
                // Unhook from owner events
                this.Owner.VisibleChanged -= new EventHandler(OnOwnerVisibleChanged);

                // Set focus back again
                this.Owner.Activate();
            }

            base.OnClosing(e);

            // Get the main application to check if restored content affects sizing
            _dockingManager.CheckResized();
        }
コード例 #3
0
        /// <summary>
        /// Perform a restore using provided docking manager.
        /// </summary>
        /// <param name="dm">Reference to source.</param>
        public override void PerformRestore(DockingManager dm)
        {
            // Create collection of Contents to auto hide
            ContentCollection cc = new ContentCollection();

            // In this case, there is only one
            cc.Add(Content);

            // Add to appropriate AutoHidePanel based on _state
            dm.AutoHideContents(cc, State, null);
        }
コード例 #4
0
        /// <summary>
        /// Return a new ContentCollection with same content references.
        /// </summary>
        /// <returns>New ContentCollection instance.</returns>
        public ContentCollection Copy()
        {
            ContentCollection clone = new ContentCollection();

            // Copy each reference across
            foreach (Content c in base.List)
            {
                clone.Add(c);
            }

            return(clone);
        }
コード例 #5
0
        /// <summary>
        /// Determines whether any of a group of Content is in the collection.
        /// </summary>
        /// <param name="values">The group of Content to locate in the collection.</param>
        /// <returns>true if an item is found in the collection; otherwise, false.</returns>
        public bool Contains(ContentCollection values)
        {
            foreach (Content c in values)
            {
                // Use base class to process actual collection operation
                if (Contains(c))
                {
                    return(true);
                }
            }

            return(false);
        }
コード例 #6
0
ファイル: FloatingForm.cs プロジェクト: zhaoyin/officeOBA
        /// <summary>
        /// Floating form is about to exit.
        /// </summary>
        public void ExitFloating()
        {
            if (_zone != null)
            {
                ContentCollection cc = ZoneHelper.Contents(_zone);

                // Record restore object for each Content
                foreach (Content c in cc)
                {
                    c.RecordFloatingRestore();
                    c.Docked = true;
                }
            }
        }
コード例 #7
0
ファイル: WindowContent.cs プロジェクト: zhaoyin/officeOBA
        /// <summary>
        /// Initializes a new instance of the WindowContent class.
        /// </summary>
        /// <param name="manager">Parent docking manager instance.</param>
        /// <param name="vs">Visual style for drawing.</param>
        public WindowContent(DockingManager manager, VisualStyle vs)
            : base(manager)
        {
            // Remember state
            _style = vs;

            // Create collection of window details
            _contents = new ContentCollection();

            // We want notification when contents are added/removed/cleared
            _contents.Clearing += new CollectionClear(OnContentsClearing);
            _contents.Inserted += new CollectionChange(OnContentInserted);
            _contents.Removing += new CollectionChange(OnContentRemoving);
            _contents.Removed  += new CollectionChange(OnContentRemoved);
        }
コード例 #8
0
ファイル: FloatingForm.cs プロジェクト: zhaoyin/officeOBA
        /// <summary>
        /// Update each zone content with new position.
        /// </summary>
        /// <param name="e">An EventArgs structure containing the event data.</param>
        protected override void OnMove(EventArgs e)
        {
            Point newPos = this.Location;

            // Grab the aggregate collection of all Content objects in the Zone
            ContentCollection cc = ZoneHelper.Contents(_zone);

            // Update each one with the new FloatingForm location
            foreach (Content c in cc)
            {
                c.DisplayLocation = newPos;
            }

            base.OnMove(e);
        }
コード例 #9
0
ファイル: FloatingForm.cs プロジェクト: zhaoyin/officeOBA
        /// <summary>
        /// Update each zone content with new size.
        /// </summary>
        /// <param name="e"></param>
        protected override void OnResize(System.EventArgs e)
        {
            // Grab the aggregate collection of all Content objects in the Zone
            ContentCollection cc = ZoneHelper.Contents(_zone);

            // Do not include the caption height of the tool window in the saved height
            Size newSize = new Size(this.Width, this.Height - SystemInformation.ToolWindowCaptionHeight);

            // Update each one with the new FloatingForm location
            foreach (Content c in cc)
            {
                c.FloatingSize = newSize;
            }

            base.OnResize(e);
        }
コード例 #10
0
ファイル: ZoneHelper.cs プロジェクト: zhaoyin/officeOBA
        /// <summary>
        /// Find collection of content instances inside a Zone.
        /// </summary>
        /// <param name="z">Zone to use.</param>
        /// <returns>Collection of content.</returns>
        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);
        }