private void OnRub(ScreenEdge e) { if (Rub != null) { Rub(e); } }
private void OnCollide(ScreenEdge edge) { if (Collide != null) { Collide(edge); } }
/// <summary> /// Activate the AppBar at the given location on the screen /// </summary> /// <param name="newLocat">Location of the AppBar</param> /// <returns>True if AppBar was successfully created</returns> public bool ActivateAppBar(ScreenEdge newLocat) { DeactivateAppBar(); Func <IEdgeHandler> edgeHandlerFact; if (EdgeHandlerFactory.TryGetValue(newLocat, out edgeHandlerFact)) { edgeHandler = edgeHandlerFact(); } else { return(false); } var winBounds = Windows.GetRectangle(appbar.hWnd); AppBarDimension = edgeHandler.GetCurrentDimension(winBounds); appbar = new AppBar(appbar.hWnd); if (!appbar.CreateNew()) { return(false); } CheckDockSize(AppBarDimension); SizeToNewValues(); SystemEvents.DisplaySettingsChanged += SystemEvents_DisplaySettingsChanged; AppBarIsActive = true; return(true); }
/// <summary> /// Sets the size and screen position of an appbar. /// The message specifies a screen edge and the bounding rectangle for the appbar. /// The system may adjust the bounding rectangle so that the appbar does not interfere with the Windows taskbar or any other appbars. /// </summary> /// <param name="screenEdge">The screen edge for the appbar</param> /// <param name="screenRect">The bounding rectangle for the appbar</param> /// <returns>The adjusted bounding rectangle</returns> public System.Drawing.Rectangle SetPos(ScreenEdge screenEdge, System.Drawing.Rectangle screenRect) { appbarData.uEdge = (uint)screenEdge; appbarData.rc = (RECT)screenRect; NativeMethods.SHAppBarMessage((uint)Message.ABM_SETPOS, ref appbarData); return((System.Drawing.Rectangle)appbarData.rc); }
private int GetPosOnEdge(ScreenEdge e, Point p) { switch (e) { case ScreenEdge.Left: case ScreenEdge.Right: return(p.Y); default: return(p.X); } }
/// <summary> /// Retrieves the handle to the autohide appbar associated with an edge of the screen. /// If the system has multiple monitors, the monitor that contains the primary taskbar is used. /// </summary> /// <param name="screenEdge">The edge of the screen to retrieve the handle for</param> /// <returns>An object representing the autohide appbar, or NULL if an error occurs or if no autohide appbar is associated with the given edge.</returns> public static AppBar GetAutoHideBar(ScreenEdge screenEdge) { Data newData = new Data(); newData.cbSize = Marshal.SizeOf(typeof(Data)); newData.uEdge = (uint)screenEdge; IntPtr handle = NativeMethods.SHAppBarMessage((uint)Message.ABM_GETAUTOHIDEBAR, ref newData); if (handle == IntPtr.Zero) { return(null); } return(new AppBar(handle)); }
private void OnRubEdge(ScreenEdge edge) { if (DisableInFullscreen && IsInFullScreenMode()) { return; } var mousePressed = Native.GetAsyncKeyState(Keys.LButton) < 0 || Native.GetAsyncKeyState(Keys.RButton) < 0 || Native.GetAsyncKeyState(Keys.MButton) < 0; if (!mousePressed && EdgeRubbed != null) { EdgeRubbed(edge); } }
/// <summary> /// Retrieves the handle to the autohide appbar associated with an edge of the screen. /// This extends GetAutoHideBar by enabling you to specify a particular monitor, for use in multiple monitor situations. /// </summary> /// <param name="screenEdge">The edge of the screen to retrieve the handle for</param> /// <param name="screenRect">A Rectangle representing the screen to utilize</param> /// <returns>An object representing the autohide appbar, or NULL if an error occurs or if no autohide appbar is associated with the given edge of the given monitor.</returns> public static AppBar GetAutoHideBarEx(ScreenEdge screenEdge, System.Drawing.Rectangle screenRect) { Data newData = new Data(); newData.cbSize = Marshal.SizeOf(typeof(Data)); newData.uEdge = (uint)screenEdge; newData.rc = (RECT)screenRect; IntPtr handle = NativeMethods.SHAppBarMessage((uint)Message.ABM_GETAUTOHIDEBAREX, ref newData); if (handle == IntPtr.Zero) { return(null); } return(new AppBar(handle)); }
private int GetDistToEdge(ScreenEdge e, Point p) { switch (e) { case ScreenEdge.Left: return(p.X); case ScreenEdge.Right: return(_screenBounds.Width - p.X); case ScreenEdge.Top: return(p.Y); default: return(_screenBounds.Bottom - p.Y); } }
/// <summary> /// Registers or unregisters an autohide appbar for a given edge of the screen. /// If the system has multiple monitors, the monitor that contains the primary taskbar is used. /// </summary> /// <param name="screenEdge">The edge of the screen to register the autohide appbar for</param> /// <param name="registerNew">Whether to register (true) or unregister (false) the autohide appbar</param> /// <returns>TRUE if successful, or FALSE if an error occurs or if an autohide appbar is already registered for the given edge.</returns> public bool SetAutoHideBar(ScreenEdge screenEdge, bool registerNew) { appbarData.uEdge = (uint)screenEdge; if (registerNew) { appbarData.lParam = 1; } else { appbarData.lParam = 0; } if (NativeMethods.SHAppBarMessage((uint)Message.ABM_SETAUTOHIDEBAR, ref appbarData) == IntPtr.Zero) { return(false); } return(true); }
/// <summary> /// Registers or unregisters an autohide appbar for a given edge of the screen. /// This extends SetAutoHideBar by enabling you to specify a particular monitor, for use in multiple monitor situations. /// </summary> /// <param name="screenEdge">The edge of the screen to register the autohide appbar for</param> /// <param name="registerNew">Whether to register (true) or unregister (false) the autohide appbar</param> /// <param name="screenRect">Rectangle specifying the screen for the AutoHide Appbar</param> /// <returns>TRUE if successful, or FALSE if an error occurs or if an autohide appbar is already registered for the given edge on the given monitor.</returns> public bool SetAutoHideBarEx(ScreenEdge screenEdge, bool registerNew, System.Drawing.Rectangle screenRect) { appbarData.uEdge = (uint)screenEdge; appbarData.rc = (RECT)screenRect; if (registerNew) { appbarData.lParam = 1; } else { appbarData.lParam = 0; } if (NativeMethods.SHAppBarMessage((uint)Message.ABM_SETAUTOHIDEBAREX, ref appbarData) == IntPtr.Zero) { return(false); } return(true); }
private static float CalculateEdgePosition(ScreenEdge edge) { Camera camera = Camera.main; switch (edge) { case ScreenEdge.Left: return(camera.ScreenToWorldPoint(new Vector3(0, 0)).x); case ScreenEdge.Right: return(camera.ScreenToWorldPoint(new Vector3(Screen.width, 0)).x); case ScreenEdge.Top: return(camera.ScreenToWorldPoint(new Vector3(0, Screen.height)).y); case ScreenEdge.Bottom: return(camera.ScreenToWorldPoint(new Vector3(0, 0)).y); } return(0f); }
public void HoldToEdge(Transform target, Bounds bounds, ScreenEdge screenEdge) { Vector3 position = target.position; switch (screenEdge) { case ScreenEdge.left: position.x = LeftBorder(bounds); break; case ScreenEdge.top: position.y = TopBorder(bounds); break; case ScreenEdge.right: position.x = RightBorder(bounds); break; case ScreenEdge.bottom: position.y = BottomBorder(bounds); break; } target.position = position; }
private void Spawn(ScreenEdge beyond) { Vector3 positionForInstaniate; Direction directionMove; //define a direction for move and a start position switch (beyond) { case ScreenEdge.Bottom: directionMove = Direction.Up; positionForInstaniate = new Vector3(0, ScreenUtils.ScreenBottom - 0.5f * colliderHight, 0); break; case ScreenEdge.Top: directionMove = Direction.Down; positionForInstaniate = new Vector3(0, ScreenUtils.ScreenTop + 0.5f * colliderHight, 0); break; case ScreenEdge.Left: directionMove = Direction.Right; positionForInstaniate = new Vector3(ScreenUtils.ScreenLeft - 0.5f * colliderWidth, 0, 0); break; case ScreenEdge.Right: directionMove = Direction.Left; positionForInstaniate = new Vector3(ScreenUtils.ScreenRight + 0.5f * colliderWidth, 0, 0); break; default: throw new KeyNotFoundException("Unknow ScreenEdge"); } //Сreate new asteroid with desired direction and position var currentObject = Instantiate(AsteroidPrefab, positionForInstaniate, Quaternion.identity); var currentScripteObject = currentObject.GetComponent <Asteroid>(); currentScripteObject.Initialize(directionMove); }
private void PathTracker_EdgeRubbed(ScreenEdge edge) { if (!EnableRubEdge) { return; } Debug.WriteLine("RubEdge: " + edge); //HACK: 似乎有必要重构此实现方式 // corners & edges 的command 依次存放在一个8元素数组中。 // 4 + edge == 实际对应的cmd var cmd = IntentFinder.IntentStore.HotCornerCommands[4 + (int)edge]; if (cmd != null) { var shouldInit = cmd as INeedInit; if (shouldInit != null && !shouldInit.IsInitialized) { shouldInit.Init(); } cmd.Execute(); } }
//---------------------------------------------------------------------------------------- /// <summary> /// Positions the window near the given coordinates. Horizontal and vertical /// centering around that location is determined by taskbar docking edge. /// </summary> /// <param name="point">The "upper-left" point of the system tray</param> /// <param name="docking">The edge of the screen to which the taskbar is docked</param> public void SetPositionRelativeTo(Point point, ScreenEdge docking) { var height = (int)Math.Round(Height); var width = (int)Math.Round(Width); if ((docking == ScreenEdge.Bottom) || (docking == ScreenEdge.Top)) { Left = point.X - (width / 2.0) - DefaultWindowMargin; Top = docking == ScreenEdge.Bottom ? point.Y - height - DefaultWindowMargin : point.Y + DefaultWindowMargin; } else // Left|Right { Left = docking == ScreenEdge.Left ? point.X + DefaultWindowMargin : point.X - DefaultWindowMargin - width; Top = point.Y - (int)Math.Round(height / 2.0); } Logger.Debug($"SetPosition x,y={Left},{Top} relative to x,y={point.X},{point.Y} at w={width} h={height}"); }
public void SetSpawnPosition(Vector3 value) { _spawnPosition.Value = value; SpawnEdge = _screenSizeModel.OutsideVectorToScreenEdge(value); }
public static Transform SetLocalPositionRelativeToScreenEdge(this Transform transform, ScreenEdge edge, float offset) { float edgePosition = CalculateEdgePosition(edge); switch (edge) { case ScreenEdge.Left: transform.SetLocalX(edgePosition + offset); break; case ScreenEdge.Right: transform.SetLocalX(edgePosition + offset); break; case ScreenEdge.Top: transform.SetLocalY(edgePosition + offset); break; case ScreenEdge.Bottom: transform.SetLocalY(edgePosition + offset); break; } return(transform); }
public Vector3 GetPosProjection(ScreenEdge sEdge, float newXOffset, float newYOffset) { Vector3 newPosition = transform.localPosition; float transformSizeX = transform.renderer.bounds.size.x; float transformSizeY = transform.renderer.bounds.size.y; switch (sEdge) { case ScreenEdge.TopOnly: newXOffset = 0; newPosition.y = camera.orthographicSize - (transformSizeY / 2) + newYOffset; break; case ScreenEdge.TopCenter: newPosition.x = newXOffset; newPosition.y = camera.orthographicSize - (transformSizeY / 2) + newYOffset; break; case ScreenEdge.TopLeft: newPosition.x = -camera.aspect * camera.orthographicSize + (transformSizeX / 2) + newXOffset; newPosition.y = camera.orthographicSize - (transformSizeY / 2) + newYOffset; break; case ScreenEdge.TopRight: newPosition.x = camera.aspect * camera.orthographicSize - (transformSizeX / 2) + newXOffset; newPosition.y = camera.orthographicSize - (transformSizeY / 2) + newYOffset; break; case ScreenEdge.BottomOnly: newXOffset = 0; newPosition.y = -camera.orthographicSize + (transformSizeY / 2) + newYOffset; break; case ScreenEdge.BottomCenter: newPosition.x = newXOffset; newPosition.y = -camera.orthographicSize + (transformSizeY / 2) + newYOffset; break; case ScreenEdge.BottomLeft: newPosition.x = -camera.aspect * camera.orthographicSize + (transformSizeX / 2) + newXOffset; newPosition.y = -camera.orthographicSize + (transformSizeY / 2) + newYOffset; break; case ScreenEdge.BottomRight: newPosition.x = camera.aspect * camera.orthographicSize - (transformSizeX / 2) + newXOffset; newPosition.y = -camera.orthographicSize + (transformSizeY / 2) + newYOffset; break; case ScreenEdge.LeftOnly: newPosition.x = -camera.aspect * camera.orthographicSize + (transformSizeX / 2) + newXOffset; newYOffset = 0; break; case ScreenEdge.LeftCenter: newPosition.x = -camera.aspect * camera.orthographicSize + (transformSizeX / 2) + newXOffset; newPosition.y = newYOffset; break; case ScreenEdge.RightOnly: newPosition.x = camera.aspect * camera.orthographicSize - (transformSizeX / 2) + newXOffset; newYOffset = 0; break; case ScreenEdge.RightCenter: newPosition.x = camera.aspect * camera.orthographicSize - (transformSizeX / 2) + newXOffset; newPosition.y = newYOffset; break; } return(newPosition); }
private void EdgeDetector_Rub(ScreenEdge edge) { Post(WM.RUB_EDGE, (int)edge); }