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 CursorOverlayForm() { InitializeComponent(); FormBorderStyle = FormBorderStyle.None; this.Size = ScreenPixelHelper.GetScreenWorkingArea().Size; User32.SetWindowPos(this.Handle, User32.HWND_TOPMOST, 0, 0, 0, 0, (User32.SWP_NOMOVE | User32.SWP_NOSIZE | User32.SWP_SHOWWINDOW)); UpArrowImage = Properties.Resources.uparrow; DownArrowImage = Properties.Resources.downarrow; Logger.WriteMsg("CursorOverlayForm instantiated."); }
private void DockForm_Load(object sender, EventArgs e) { //1. Setup dock so that form window takes calculated user-amount of space on right side int dockWidth = ScreenPixelHelper.ConvertMmToPixels(ConfigManager.dockFormMaxWidthMm); //Calculate dock height Rectangle wa = ScreenPixelHelper.GetScreenWorkingArea(); int dockHeight = wa.Height; //calculate dock location Point dockLocation = new Point(wa.Right - dockWidth, wa.Top); this.Location = dockLocation; this.Size = new Size(dockWidth, dockHeight); this.BackColor = Color.Black; //Add all the buttons for the dock AddGazeButtons(); SetActiveGazeButton(GAZE_BUTTON_TYPE.NONE); Logger.WriteMsg("About to register dockbar."); //Now let's dock the window RegisterDockbar(); }
public Point ClipToBox(Point gp) { //Check if LinkDict is not populated if (ClippedBox == null) { if (!boxesInitComplete || boxes.Count < 1) { return(gp); } //We also want to make sure that the gp is not near the Windows Taskbar, otherwise have difficulty using start menu or switching applications Rectangle workingArea = ScreenPixelHelper.GetScreenWorkingArea(); //We also want to make sure browser navigation buttons can be clicked comfortably int topBar = 105; if (gp.X < workingArea.Left || gp.X > workingArea.Right || gp.X < (workingArea.Top + topBar - 15) || gp.Y > workingArea.Bottom) { winzoomAvailable = true; return(gp); } List <Box> nearby = new List <Box>(); nearby.AddRange(getNearBoxes(gp)); if (nearby.Count == 0) { winzoomAvailable = true; return(gp); } if (nearby.Count == 1)//if no box around, we keep the cursor where it is { //We clip to the center of the clickable element winzoomAvailable = false; ClippedBox = nearby[0]; return(ClippedBox.center()); } else { if (!CheckAllBoxesLargeEnough(nearby)) { winzoomAvailable = true; ClippedBox = null; return(gp); } ClippedBox = findClosestBox(gp, nearby);//closest Box winzoomAvailable = false; return(ClippedBox.center()); } } else //box was previously clipped { /* * if(no box around) * ruturn ClippedBox.center or (-100,-100)either exit or stay * else * if GP is in direction of anotherBox * return changeBox() * else * either exit or stay */ //no other box around, //exit List <Box> otherNearby = getNearBoxes(gp); if (otherNearby.Contains(ClippedBox)) { otherNearby.Remove(ClippedBox); } //remove the clipped box as it is itself if (otherNearby.Count == 0) { return(StayOrExitBox(gp)); } else { if (!CheckAllBoxesLargeEnough(otherNearby)) { //must use winzoom and exit since we've approached a really small box, force exit from box winzoomAvailable = true; ClippedBox = null; return(gp); } if (ClippedBox.ContainsPoint(gp)) { return(ClippedBox.center()); } //Check if gp is contained by any of the otherNearby boxes, and if so is it at least changeBoxPercThresh into it foreach (Box b in otherNearby) { //If it's a large box then a few pixels should be enough to enter it... and for a small box use a small percentage of it if (b.ContainsPointPercentageWithin(ClippedBox, gp, ConfigManager.cursorMagnetClippingChangeBoxIntoPerc) || b.ContainsPointPixelsWithin(ClippedBox, gp, ScreenPixelHelper.ConvertMmToPixels(ConfigManager.cursorMagnetClippingExitThresholdMm)) ) { winzoomAvailable = false; ClippedBox = b; return(b.center()); } } //the gazepoint has not met the criteria for changing to a different box, see if it should stay or exit return(StayOrExitBox(gp)); } } }