private Rectangle GetTaskbarPopupLocation(TaskbarLocation tl, Size sSize, Size sOffset) { int left = tl.WorkArea.Left; int right = tl.WorkArea.Right; int top = tl.WorkArea.Top; int bottom = tl.WorkArea.Bottom; switch (tl.Edge) { case TaskbarLocationEdge.Left: left += sOffset.Width; right = left + sSize.Width; bottom -= sOffset.Height; top = bottom - sSize.Height; break; case TaskbarLocationEdge.Right: right -= sOffset.Width; left = right - sSize.Width; bottom -= sOffset.Height; top = bottom - sSize.Height; break; case TaskbarLocationEdge.Top: right -= sOffset.Width; left = right - sSize.Width; top += sOffset.Height; bottom = top + sSize.Height; break; case TaskbarLocationEdge.Bottom: right -= sOffset.Width; left = right - sSize.Width; bottom -= sOffset.Height; top = bottom - sSize.Height; break; default: throw new Exception("Could not calculate popup location"); } return(new Rectangle(left, top, right - left, bottom - top)); }
private void CalculatePopupRect() { var sPopupSize = _current.Size; var sOffset = _current.BorderOffset; var rc = new Rectangle(); var tl = TaskbarLocation.Detect(); rc = GetTaskbarPopupLocation(tl, sPopupSize, sOffset); _current.Location = rc; _edge = tl.Edge; var pt = new Point( rc.Left + rc.Width / 2, rc.Top + rc.Height / 2 ); _popupScreen = Screen.FromPoint(pt); }
private void UpdatePosition() { var location = TaskbarLocation.Detect(); var bounds = location.WorkArea; bounds.Inflate(-10, -10); int top = bounds.Top; int left = bounds.Left; int right = bounds.Right; int bottom = bounds.Bottom; switch (location.Edge) { case TaskbarLocationEdge.Top: bottom = top + Height; break; default: top = bottom - Height; break; } switch (location.Edge) { case TaskbarLocationEdge.Left: right = left + Width; break; default: left = right - Width; break; } SetBounds(left, top, right - left, bottom - top); }
private Rectangle GetTaskbarPopupLocation(TaskbarLocation tl, Size sSize, Size sOffset) { int left = tl.WorkArea.Left; int right = tl.WorkArea.Right; int top = tl.WorkArea.Top; int bottom = tl.WorkArea.Bottom; switch (tl.Edge) { case TaskbarLocationEdge.Left: left += sOffset.Width; right = left + sSize.Width; bottom -= sOffset.Height; top = bottom - sSize.Height; break; case TaskbarLocationEdge.Right: right -= sOffset.Width; left = right - sSize.Width; bottom -= sOffset.Height; top = bottom - sSize.Height; break; case TaskbarLocationEdge.Top: right -= sOffset.Width; left = right - sSize.Width; top += sOffset.Height; bottom = top + sSize.Height; break; case TaskbarLocationEdge.Bottom: right -= sOffset.Width; left = right - sSize.Width; bottom -= sOffset.Height; top = bottom - sSize.Height; break; default: throw new Exception("Could not calculate popup location"); } return new Rectangle(left, top, right - left, bottom - top); }
private bool ShouldShowPopup() { var popupScreen = Screen.FromPoint(TaskbarLocation.Detect().WorkArea.Location); return(PopupUtil.ShouldShowPopup(this, popupScreen)); }