public static Rectangle GetStartMenuRect() { Rectangle screenRect = ScreenPixelHelper.GetScreenSize(); Rectangle waRect = ScreenPixelHelper.GetScreenWorkingArea(); //the taskbar might be located other than the bottom of the screen default //But it doesn't matter since we are showing this overlay form return(new Rectangle(0, waRect.Bottom, 48, screenRect.Bottom - waRect.Bottom)); //value measured with pixel ruler }
public bool WithinRect(Point p, ZOOMBOX_RECT_T rect_t) { if (!active) { return(false); } Rectangle rect = GetActiveRectFromType(rect_t); Rectangle screenSize = ScreenPixelHelper.GetScreenSize(); p = BoundPointToRect(p, screenSize, 5); if (p.X >= rect.Left && p.X <= rect.Right && p.Y >= rect.Top && p.Y <= rect.Bottom) { return(true); } return(false); }
protected override void OnPaint(PaintEventArgs e) { User32.SetFormTransparent(this.Handle); //Convert the current warp point a point on the screen Point wp = warpPointer.GetWarpPoint(); wp.Offset(calibrationAdjuster.GetCalibrationAdjustment(wp)); Point screenPoint = wz.ConvertToScreenPoint(wp); Rectangle screenSize = ScreenPixelHelper.GetScreenSize(); if (ConfigManager.zoomboxGrid) { //Draw a vertical line e.Graphics.DrawLine(Pens.Black, new Point(screenPoint.X, screenSize.Top), new Point(screenPoint.X, screenSize.Bottom)); //Draw a horizontal line e.Graphics.DrawLine(Pens.Black, new Point(screenSize.Left, screenPoint.Y), new Point(screenSize.Right, screenPoint.Y)); } else { DrawApplicableCursorSymbol(e, screenPoint); } }
public Point limitToScreenBounds(Point p) { Rectangle screenSize = ScreenPixelHelper.GetScreenSize(); int margin = 5; if (p.X < margin) { p.X = margin; } if (p.Y < margin) { p.Y = margin; } if (p.X >= screenSize.Width - margin) { p.X = screenSize.Width - margin; } if (p.Y >= screenSize.Height - margin - 5) { p.Y = screenSize.Height - margin - 5; } return(p); }
//NOTE: it doesn't really matter if user's taskbar is arranged elsewhere since we are using this hider form public static Point GetStartMenuLocation() { return(new Point(ScreenPixelHelper.ConvertMmToPixels(3), ScreenPixelHelper.GetScreenSize().Height - ScreenPixelHelper.ConvertMmToPixels(4))); }
//It is hardcoded to set to the right side private void ABSetPos() { Rectangle screenSize = ScreenPixelHelper.GetScreenSize(); try { APPBARDATA abd = new APPBARDATA(); abd.cbSize = Marshal.SizeOf(abd); abd.hWnd = this.Handle; abd.uEdge = (int)ABEdge.ABE_RIGHT; if (abd.uEdge == (int)ABEdge.ABE_LEFT || abd.uEdge == (int)ABEdge.ABE_RIGHT) { abd.rc.top = 0; abd.rc.bottom = screenSize.Height; if (abd.uEdge == (int)ABEdge.ABE_LEFT) { abd.rc.left = 0; abd.rc.right = Size.Width; } else { abd.rc.right = screenSize.Width; abd.rc.left = abd.rc.right - Size.Width; } } else { abd.rc.left = 0; abd.rc.right = screenSize.Width; if (abd.uEdge == (int)ABEdge.ABE_TOP) { abd.rc.top = 0; abd.rc.bottom = Size.Height; } else { abd.rc.bottom = screenSize.Height; abd.rc.top = abd.rc.bottom - Size.Height; } } // Query the system for an approved size and position. SHAppBarMessage((int)ABMsg.ABM_QUERYPOS, ref abd); // Adjust the rectangle, depending on the edge to which the // appbar is anchored. switch (abd.uEdge) { case (int)ABEdge.ABE_LEFT: abd.rc.right = abd.rc.left + Size.Width; break; case (int)ABEdge.ABE_RIGHT: abd.rc.left = abd.rc.right - Size.Width; break; case (int)ABEdge.ABE_TOP: abd.rc.bottom = abd.rc.top + Size.Height; break; case (int)ABEdge.ABE_BOTTOM: abd.rc.top = abd.rc.bottom - Size.Height; break; } // Pass the final bounding rectangle to the system. SHAppBarMessage((int)ABMsg.ABM_SETPOS, ref abd); // Move and size the appbar so that it conforms to the // bounding rectangle passed to the system. MoveWindow(abd.hWnd, abd.rc.left, abd.rc.top, abd.rc.right - abd.rc.left, abd.rc.bottom - abd.rc.top, true); } catch (Exception ex) { Logger.WriteError(ex.ToString()); } }
public static Rectangle GetScreenSize() { return(ScreenPixelHelper.GetScreenSize()); }
public void Show(Point p, float addedMagnification = 0) { if (active) { return; } Logger.WriteEvent(); active = true; Rectangle screenSize = ScreenPixelHelper.GetScreenSize(); p = BoundPointToRect(p, screenSize, 5); zoomPct = ConfigManager.zoomWindowMagnificationPct + addedMagnification; activeRectPctScreen = ConfigManager.zoomWindowPctScreen; activeRectPaddedPctScreen = activeRectPctScreen + 15; aciveRectSrcPctScreen = (float)activeRectPctScreen * 100 / (float)zoomPct; //Calculate the size and position of the source rectangle float w = (float)screenSize.Width * aciveRectSrcPctScreen / 100; float h = (float)screenSize.Height * aciveRectSrcPctScreen / 100; //Check based on the height, width, and p if we need to shift to fit on screen activeRectSrcCenter = CalculateRectCenterToFitScreen(p, w, h); int xScreen = activeRectSrcCenter.X - Convert.ToInt32(w / 2); int yScreen = activeRectSrcCenter.Y - Convert.ToInt32(h / 2); activeRectSrc = new Rectangle(xScreen, yScreen, Convert.ToInt32(w), Convert.ToInt32(h)); float activeRectWidth = (float)screenSize.Width * activeRectPctScreen / 100; float activeRectHeight = (float)screenSize.Height * activeRectPctScreen / 100; activeRectCenter = CalculateRectCenterToFitScreen(p, activeRectWidth, activeRectHeight); xScreen = activeRectCenter.X - Convert.ToInt32((activeRectWidth / 2)); yScreen = activeRectCenter.Y - Convert.ToInt32((activeRectHeight / 2)); activeRect = new Rectangle(xScreen, yScreen, Convert.ToInt32(activeRectWidth), Convert.ToInt32(activeRectHeight)); //Calculate the padded activeRect so that within this padding the zoombox does not cancel when user looks away float activeRectWidthPadded = screenSize.Width * activeRectPaddedPctScreen / 100; float activeRectHeightPadded = screenSize.Height * activeRectPaddedPctScreen / 100; xScreen = activeRectCenter.X - Convert.ToInt32((activeRectWidthPadded / 2)); yScreen = activeRectCenter.Y - Convert.ToInt32((activeRectHeightPadded / 2)); activeRectPadded = new Rectangle(xScreen, yScreen, Convert.ToInt32(activeRectWidthPadded), Convert.ToInt32(activeRectHeightPadded)); //Allows drawing cursor icons underneath the WinzoomForm. wzuf = new WinzoomUnderlayForm(warpPointer, calibrationAdjuster, this); wzuf.StartPosition = FormStartPosition.Manual; wzuf.WindowState = FormWindowState.Maximized; wzuf.AllowTransparency = true; wzuf.TransparencyKey = wzuf.BackColor; wzuf.TopMost = true; wzuf.Show(); //zbf.BackColor = Color.FromArgb(216,249,107); //a very unusual light green color wzf = new WinzoomForm(this); wzf.magnification = (float)zoomPct / 100; wzf.mag.magnification = (float)zoomPct / 100; wzf.Width = Convert.ToInt32(activeRectWidth); wzf.Height = Convert.ToInt32(activeRectHeight); wzf.StartPosition = FormStartPosition.Manual; wzf.Location = new Point(activeRect.X, activeRect.Y); wzf.mag.SetSourceRect(activeRectSrc); wzf.mag.SetActiveRect(activeRect); wzf.Show(); }
public Point ConvertToScreenPoint(Point p) { Rectangle screenSize = ScreenPixelHelper.GetScreenSize(); p = BoundPointToRect(p, screenSize, 5); int delta = ScreenPixelHelper.ConvertMmToPixels(1); //We want to find the "center" which is the focal point of where magnified and system cursor intersect //on the winzoom box. It is different whether edge or corner, or if winzoom box is in middle of screen int x = 0; if (Math.Abs(activeRect.Left - activeRectSrc.Left) < delta) { x = 0; } else if (Math.Abs(activeRect.Right - activeRectSrc.Right) < delta) { x = screenSize.Width; } else if (activeRect.Left < delta) //only activeRect is left aligned { //Experimentally and analytically determined this formula x = Convert.ToInt32((Convert.ToDouble(activeRectSrc.Left) * zoomPct / (zoomPct - 100))); } else if (Math.Abs(activeRect.Right - screenSize.Width) < delta) //only activeRect is right aligned { int xdiff = (activeRect.Right - activeRectSrc.Right); //this will be a positive number int xDiffScaled = Convert.ToInt32((Convert.ToDouble(xdiff) * zoomPct / (zoomPct - 100))); x = activeRect.Right - xDiffScaled; } else { x = activeRectSrcCenter.X; } int y = 0; if (Math.Abs(activeRect.Top - activeRectSrc.Top) < delta) { y = 0; } else if (Math.Abs(activeRect.Bottom - activeRectSrc.Bottom) < delta) { y = screenSize.Height; } else if (activeRect.Top < delta) //only activeRect is left aligned { y = Convert.ToInt32((activeRectSrc.Top * zoomPct / (zoomPct - 100))); } else if (Math.Abs(activeRect.Bottom - screenSize.Width) < delta) //only activeRect is right aligned { int ydiff = (activeRect.Bottom - activeRectSrc.Bottom); //this will be a positive number int yDiffScaled = Convert.ToInt32((ydiff * zoomPct / (zoomPct - 100))); y = activeRect.Bottom - yDiffScaled; } else { y = activeRectSrcCenter.Y; } //This center is essentially the focal point of the magnified cursor and system cursor Point center = new Point(x, y); Point diff = new Point(p.X - center.X, p.Y - center.Y); //The magnified cursor and the actively controlled cursor are the same point in top left corner of activeRectSrc //As main cursor moves, magnified cursor moves away twice as fast if we return p and do no adjustments //Therefore we need to divide the distance of gaze point from top left corner by zoomFactor to get magnified and gaze point to be same return(new Point(center.X + Convert.ToInt32((float)diff.X / ((float)zoomPct / (float)100)), center.Y + Convert.ToInt32((float)diff.Y / ((float)zoomPct / (float)100))));; }
private Point getScreenCenter() { Rectangle screenSize = ScreenPixelHelper.GetScreenSize(); return(new Point(screenSize.Width / 2, screenSize.Height / 2)); }