public YTMenuMovingComponent(Menu menu, MovingMode mode) { _Menu = menu; _MovingMode = mode; _MovingState = MovingState.Static; _ScreenWidth = (int)WindowsHandler.GetScreenWidth(); _ScreenHeight = (int)WindowsHandler.GetScreenHeight(); _xQueue = new Queue <double>(); _yQueue = new Queue <double>(); _ShakingQueue = new Queue <double>(); }
public static void MoveWindow(IntPtr hwnd, int xOffset, int yOffset) { if (hwnd != IntPtr.Zero) { WinApiManager.RECT rect = new WinApiManager.RECT(); WinApiManager.GetWindowRect(hwnd, out rect); int width = Math.Abs(rect.Right - rect.Left); int height = Math.Abs(rect.Bottom - rect.Top); int x = Math.Max(0 - width / 2, Math.Min((int)WindowsHandler.GetScreenWidth() + width / 2, rect.Left + xOffset)); int y = Math.Max(0, Math.Min((int)WindowsHandler.GetScreenHeight(), rect.Top + yOffset)); WinApiManager.SetWindowPos(hwnd, IntPtr.Zero, x, y, 0, 0, WinApiManager.SWP_NOSIZE | WinApiManager.SWP_NOACTIVATE | WinApiManager.SWP_NOZORDER | WinApiManager.SWP_SHOWWINDOW); } }