예제 #1
0
        /// <summary>
        /// When another AppBar causes an AppBar's location or size to change, the AppBar's rectangle needs to be adjusted
        /// to the appropriate new values. Discovers and returns these new values
        /// </summary>
        /// <param name="changedRect">Original AppBar Rectangle that needs to be adjusted to new values</param>
        /// <param name="dimension">Variable dimension value of the AppBar</param>
        /// <param name="appbar">Win32Api AppBar structure used to handle the lower-level AppBar processes</param>
        /// <returns>New Rectangle with the new, fixed values for the AppBar</returns>
        public System.Drawing.Rectangle FixChangedRect(System.Drawing.Rectangle changedRect, int dimension, AppBar appbar)
        {
            var retRect = new System.Drawing.Rectangle(changedRect.X, changedRect.Y, changedRect.Width, changedRect.Height);

            var getScreen = Screen.FromRectangle(retRect);

            if (getScreen.WorkingArea.Width != retRect.Width)
            {
                retRect.X     = getScreen.WorkingArea.X;
                retRect.Width = getScreen.WorkingArea.Width;
            }

            if (retRect.Bottom != getScreen.Bounds.Bottom)
            {
                var newRect = appbar.QueryPos(ScreenEdge.Bottom, retRect);
                if (newRect.Bottom == retRect.Bottom)
                {
                    newRect.Y      = getScreen.Bounds.Bottom - dimension;
                    newRect.Height = dimension;
                    newRect        = appbar.QueryPos(ScreenEdge.Bottom, newRect);
                }

                if (newRect.Bottom != retRect.Bottom)
                {
                    retRect.Y      = newRect.Bottom - dimension;
                    retRect.Height = dimension;
                }
            }

            return(retRect);
        }
        /// <summary>
        /// When another AppBar causes an AppBar's location or size to change, the AppBar's rectangle needs to be adjusted
        /// to the appropriate new values. Discovers and returns these new values
        /// </summary>
        /// <param name="changedRect">Original AppBar Rectangle that needs to be adjusted to new values</param>
        /// <param name="dimension">Variable dimension value of the AppBar</param>
        /// <param name="appbar">Win32Api AppBar structure used to handle the lower-level AppBar processes</param>
        /// <returns>New Rectangle with the new, fixed values for the AppBar</returns>
        public System.Drawing.Rectangle FixChangedRect(System.Drawing.Rectangle changedRect, int dimension, AppBar appbar)
        {
            var retRect = new System.Drawing.Rectangle(changedRect.X, changedRect.Y, changedRect.Width, changedRect.Height);

            var getScreen = Screen.FromRectangle(retRect);

            if (getScreen.WorkingArea.Height != retRect.Height)
            {
                retRect.Y      = getScreen.WorkingArea.Y;
                retRect.Height = getScreen.WorkingArea.Height;
            }

            if (retRect.Left != getScreen.Bounds.Left)
            {
                var newRect = appbar.QueryPos(ScreenEdge.Left, retRect);
                if (newRect.Left == retRect.Left)
                {
                    newRect.X     = getScreen.Bounds.Left;
                    newRect.Width = dimension;
                    newRect       = appbar.QueryPos(ScreenEdge.Left, newRect);
                }

                if (newRect.Left != retRect.Left)
                {
                    retRect.X     = newRect.X;
                    retRect.Width = dimension;
                }
            }

            return(retRect);
        }