示例#1
0
 public RECT(RECT rcSrc)
 {
     this.left = rcSrc.left;
     this.top = rcSrc.top;
     this.right = rcSrc.right;
     this.bottom = rcSrc.bottom;
 }
示例#2
0
 public RECT(RECT rcSrc)
 {
     left = rcSrc.left;
     top = rcSrc.top;
     right = rcSrc.right;
     bottom = rcSrc.bottom;
 }
示例#3
0
 /// <summary>
 /// Returns monitor in witch control is placed
 /// </summary>
 /// <param name="control">Control</param>
 /// <returns>Workarea in witch control is placed</returns>
 public static Rect GetControlMonitor(FrameworkElement control)
 {
     var tabItemPos = control.PointToScreen(new Point(0, 0));
     var tabItemRect = new RECT();
     tabItemRect.left = (int)tabItemPos.X;
     tabItemRect.top = (int)tabItemPos.Y;
     tabItemRect.right = (int)tabItemPos.X + (int)control.ActualWidth;
     tabItemRect.bottom = (int)tabItemPos.Y + (int)control.ActualHeight;
     const uint MONITOR_DEFAULTTONEAREST = 0x00000002;
     var monitor = NativeMethods.MonitorFromRect(ref tabItemRect, MONITOR_DEFAULTTONEAREST);
     if (monitor != IntPtr.Zero)
     {
         var monitorInfo = new MONITORINFO();
         monitorInfo.cbSize = Marshal.SizeOf(monitorInfo);
         NativeMethods.GetMonitorInfo(monitor, monitorInfo);
         return new Rect(monitorInfo.rcMonitor.left, monitorInfo.rcMonitor.top, monitorInfo.rcMonitor.right - monitorInfo.rcMonitor.left, monitorInfo.rcMonitor.bottom - monitorInfo.rcMonitor.top);
     }
     return new Rect();
 }
 internal static extern bool GetWindowRect(IntPtr hWnd, out RECT lpRect);
示例#5
0
        private static int GetEdge(RECT rc)
        {
            int uEdge;

            if (rc.top == rc.left
                && rc.bottom > rc.right)
            {
                uEdge = (int)ABEdge.ABE_LEFT;
            }
            else if (rc.top == rc.left
                && rc.bottom < rc.right)
            {
                uEdge = (int)ABEdge.ABE_TOP;
            }
            else if (rc.top > rc.left)
            {
                uEdge = (int)ABEdge.ABE_BOTTOM;
            }
            else
            {
                uEdge = (int)ABEdge.ABE_RIGHT;
            }

            return uEdge;
        }
        /// <summary>
        /// Implements custom placement for ribbon popup
        /// </summary>
        /// <param name="popupsize"></param>
        /// <param name="targetsize"></param>
        /// <param name="offset"></param>
        /// <returns></returns>
        private CustomPopupPlacement[] CustomPopupPlacementMethod(Size popupsize, Size targetsize, Point offset)
        {
            if (this.DropDownPopup == null
                || this.SelectedTabItem == null)
            {
                return null;
            }

            // Get current workarea                
            var tabItemPos = this.SelectedTabItem.PointToScreen(new Point(0, 0));
            var tabItemRect = new RECT
            {
                left = (int)tabItemPos.X,
                top = (int)tabItemPos.Y,
                right = (int)tabItemPos.X + (int)this.SelectedTabItem.ActualWidth,
                bottom = (int)tabItemPos.Y + (int)this.SelectedTabItem.ActualHeight
            };

            const uint MONITOR_DEFAULTTONEAREST = 0x00000002;

            var monitor = NativeMethods.MonitorFromRect(ref tabItemRect, MONITOR_DEFAULTTONEAREST);
            if (monitor == IntPtr.Zero)
            {
                return null;
            }

            var monitorInfo = new MONITORINFO();
            monitorInfo.cbSize = Marshal.SizeOf(monitorInfo);
            UnsafeNativeMethods.GetMonitorInfo(monitor, monitorInfo);

            var startPoint = this.PointToScreen(new Point(0, 0));
            if (this.FlowDirection == FlowDirection.RightToLeft)
            {
                startPoint.X -= this.ActualWidth;
            }

            var inWindowRibbonWidth = monitorInfo.rcWork.right - Math.Max(monitorInfo.rcWork.left, startPoint.X);

            var actualWidth = this.ActualWidth;
            if (startPoint.X < monitorInfo.rcWork.left)
            {
                actualWidth -= monitorInfo.rcWork.left - startPoint.X;
                startPoint.X = monitorInfo.rcWork.left;
            }

            // Set width and prevent negative values
            this.DropDownPopup.Width = Math.Max(0, Math.Min(actualWidth, inWindowRibbonWidth));
            return new[]
            {
                new CustomPopupPlacement(new Point(startPoint.X - tabItemPos.X + offset.X, targetsize.Height + offset.Y), PopupPrimaryAxis.Vertical),
                new CustomPopupPlacement(new Point(startPoint.X - tabItemPos.X + offset.X, -1 * (targetsize.Height + offset.Y + ((ScrollViewer)this.SelectedContent).ActualHeight)), PopupPrimaryAxis.Vertical)
            };
        }