public static void UpdateOverlayPositionAndSize(IntPtr thisWindowHandle, Process process) { var processWindowHandle = process.MainWindowHandle; var procRect = new RECT(); GetClientRect(processWindowHandle, ref procRect); var procPos = new System.Drawing.Point(); ClientToScreen(processWindowHandle, ref procPos); if (procPos != prevProcPos || !procRect.Equals(prevProcRect)) { GameService.Graphics.Resolution = new Point( procRect.Right - procRect.Left, procRect.Bottom - procRect.Top ); SetWindowPos( thisWindowHandle, HWND_TOPMOST, procPos.X, procPos.Y, procRect.Right - procRect.Left, procRect.Bottom - procRect.Top, SWP_SHOWWINDOW ); prevProcPos = procPos; prevProcRect = procRect; } }
public void TestStructness() { RECT r0 = new RECT(0, 0, 10, 10); RECT r1 = r0; r1.x0 = 100; Assertion.Assert(!r0.Equals(r1)); Assertion.AssertEquals(r0.x0, 0); }
public override bool UpdateRect(RECT r) { if (r.Left == Rect.Left && r.Top == Rect.Top) { return(r.Equals(Rect)); } RecalcDeltaWithHeight(); return(TryUpdateChildRect(0, Childs.Count, out _)); }
//Updates the size, transparency and position of the form protected void updateOverlayFrame(Object obj, EventArgs eve) { GetWindowRect(handle, out rect); if (!rect.Equals(oldrect)) { oldrect = rect; setTransparency(); setSize(); setPosition(); } }
public RECT getWindowPadding(SystemWindow window) { RECT positionWithPadding = window.Rectangle; RECT positionWithoutPadding = getAccuratePosition(window); //custom-drawn windows (like Office, Visual Studio, Photoshop, and Vivaldi) don't have the 1px semitransparent border //traditional windows (like notepad or UWP apps) get a semitransparent 1px border that we want to exclude here, because abutting windows should not show the desktop between them bool isCustomDrawnWindow = positionWithPadding.Equals(positionWithoutPadding); int borderThickness = isCustomDrawnWindow ? 0 : BORDER_LINE_THICKNESS; return(new RECT( left_: positionWithoutPadding.Left - positionWithPadding.Left + borderThickness, top_: positionWithPadding.Top - positionWithoutPadding.Top + borderThickness, right_: positionWithPadding.Right - positionWithoutPadding.Right + borderThickness, bottom_: positionWithPadding.Bottom - positionWithoutPadding.Bottom + borderThickness)); }
protected virtual void OnLocationChanged(object sender, WinEventProcEventArgs e) { MouseInput.GetMousePoint(); WindowHelper.GetWindowRect(e._hwnd, ref currentWindowRECT); if (IsStartDragging && e._hwnd == WindowDraggingHWND) { if (currentWindowRECT.Equals(lastWindowRECT) == false) { int currentWidth = currentWindowRECT.Right - currentWindowRECT.Left; int currentHeight = currentWindowRECT.Bottom - currentWindowRECT.Top; int lastWidth = lastWindowRECT.Right - lastWindowRECT.Left; int lastHeight = lastWindowRECT.Bottom - lastWindowRECT.Top; if (currentWidth == lastWidth && currentHeight == lastHeight) { OnWindowMoveStart(sender, new MouseWindowEventArgs() { HWND = e._hwnd, MousePoint = MouseInput.mousePoint }); WindowDraggingHWND = e._hwnd; IsWindowMoving = true; IsStartDragging = false; } else { OnWindowSizeStart(sender, new MouseWindowEventArgs() { HWND = e._hwnd, MousePoint = MouseInput.mousePoint }); WindowDraggingHWND = e._hwnd; IsWindowSizing = true; IsStartDragging = false; } } } }
internal void UpdateCore(RECT rect) { if (lastUpdateCoreRect.Equals(rect)) { return; } lastUpdateCoreRect = rect; if (CanUpdateCore() == false) { return; } // we can handle this._owner.WindowState == WindowState.Normal // or use NOZORDER too // todo: direct z-order NativeMethods.SetWindowPos(windowHandle, ownerWindowHandle, (int)getLeft(rect), (int)getTop(rect), (int)getWidth(rect), (int)getHeight(rect), SWP.NOACTIVATE | SWP.NOZORDER); }
public override bool Equals(object?obj) { return(obj is Slide slide && EqualityComparer <Screen> .Default.Equals(Screen, slide.Screen) && _screen.Equals(slide._screen)); }
public void EqualsTest1() { var r1 = new RECT(1, 1, 4, 4); Assert.That(!r1.Equals((object)null)); Assert.That(r1.Equals(r1)); Assert.That(r1.Equals(new RECT(1, 1, 4, 4))); Assert.That(r1.Equals((object)new RECT(1, 1, 4, 4))); Assert.That(!r1.Equals(new RECT(1, 2, 4, 4))); Assert.That(r1.Equals(new PRECT(1, 1, 4, 4))); Assert.That(r1.Equals((object)new PRECT(1, 1, 4, 4))); Assert.That(!r1.Equals(new PRECT(1, 2, 1, 4))); Assert.That(r1.Equals(new Rectangle(1, 1, 3, 3))); Assert.That(r1.Equals((object)new Rectangle(1, 1, 3, 3))); Assert.That(!r1.Equals(new Rectangle(1, 2, 2, 2))); Assert.That(!r1.Equals(new Size(1, 2))); }