/// <summary> /// Cross-platform handy method to get the size of the screen /// </summary> /// <returns>SIZE measures of the screen of primary monitor</returns> public SciterSize GetPrimaryScreenSize() { var nScreenWidth = PInvokeWindows.GetSystemMetrics(PInvokeWindows.SystemMetric.SM_CXSCREEN); var nScreenHeight = PInvokeWindows.GetSystemMetrics(PInvokeWindows.SystemMetric.SM_CYSCREEN); return(new SciterSize(nScreenWidth, nScreenHeight)); }
/// <summary> /// Centers the window in the screen. You must call it after the window is created, but before it is shown to avoid flickering /// </summary> public void CenterTopLevelWindow() { #if WINDOWS IntPtr hwndParent = PInvokeWindows.GetDesktopWindow(); PInvokeUtils.RECT rectWindow, rectParent; PInvokeWindows.GetWindowRect(_hwnd, out rectWindow); PInvokeWindows.GetWindowRect(hwndParent, out rectParent); int nWidth = rectWindow.right - rectWindow.left; int nHeight = rectWindow.bottom - rectWindow.top; int nX = ((rectParent.right - rectParent.left) - nWidth) / 2 + rectParent.left; int nY = ((rectParent.bottom - rectParent.top) - nHeight) / 2 + rectParent.top; int nScreenWidth = PInvokeWindows.GetSystemMetrics(PInvokeWindows.SystemMetric.SM_CXSCREEN); int nScreenHeight = PInvokeWindows.GetSystemMetrics(PInvokeWindows.SystemMetric.SM_CYSCREEN); if (nX < 0) { nX = 0; } if (nY < 0) { nY = 0; } if (nX + nWidth > nScreenWidth) { nX = nScreenWidth - nWidth; } if (nY + nHeight > nScreenHeight) { nY = nScreenHeight - nHeight; } PInvokeWindows.MoveWindow(_hwnd, nX, nY, nWidth, nHeight, false); #elif GTKMONO int screen_width = PInvokeGTK.gdk_screen_width(); int screen_height = PInvokeGTK.gdk_screen_height(); int window_width, window_height; PInvokeGTK.gtk_window_get_size(_gtkwindow, out window_width, out window_height); int nX = (screen_width - window_width) / 2; int nY = (screen_height - window_height) / 2; PInvokeGTK.gtk_window_move(_gtkwindow, nX, nY); #elif OSX _nsview.Window.Center(); #endif }
/// <summary> /// Cross-platform handy method to get the size of the screen /// </summary> /// <returns>SIZE measures of the screen of primary monitor</returns> public static PInvokeUtils.SIZE GetPrimaryMonitorScreenSize() { #if WINDOWS int nScreenWidth = PInvokeWindows.GetSystemMetrics(PInvokeWindows.SystemMetric.SM_CXSCREEN); int nScreenHeight = PInvokeWindows.GetSystemMetrics(PInvokeWindows.SystemMetric.SM_CYSCREEN); return(new PInvokeUtils.SIZE() { cx = nScreenWidth, cy = nScreenHeight }); #elif GTKMONO int screen_width = PInvokeGTK.gdk_screen_width(); int screen_height = PInvokeGTK.gdk_screen_height(); return(new PInvokeUtils.SIZE() { cx = screen_width, cy = screen_height }); #elif OSX return(new PInvokeUtils.SIZE()); // TODO #endif }