public bool Equals( WindowInfo other ) { if ( ReferenceEquals( null, other ) ) { return false; } return ReferenceEquals( this, other ) || other.Handle.Equals( Handle ); }
/// <summary> /// Find the next window below the specified window. /// </summary> /// <returns>The next window below the specified window, or null when the specified window is at the bottom.</returns> public static WindowInfo GetWindowBelow( WindowInfo window ) { IntPtr windowHandle = User32.GetWindow( window.Handle, User32.WindowRelationship.Next ); return windowHandle == IntPtr.Zero ? null : new WindowInfo( windowHandle ); }
/// <summary> /// Removes the passed window from the virtual desktop and hides it. /// </summary> /// <param name = "toRemove">The window to remove.</param> public void RemoveWindow( WindowInfo toRemove ) { _windows.Remove( toRemove ); toRemove.Hide(); }
/// <summary> /// Adds the passed window to the virtual desktop and activates it. /// </summary> /// <param name = "toAdd">The window to add.</param> public void AddWindow( WindowInfo toAdd ) { _windows.Add( toAdd ); toAdd.Show(); }
/// <summary> /// Cut a given window from the currently open desktop and store it in a clipboard. /// TODO: What if a window from a different desktop is passed? Should this be supported? /// </summary> /// <param name="window"></param> public void CutWindow( WindowInfo window ) { if ( IsValidWindow( window ) ) { _windowClipboard.Push( window ); CurrentDesktop.RemoveWindow( window ); } }
bool IsValidWindow( WindowInfo window ) { bool valid = !window.IsDestroyed() && window.IsVisible() && !IgnoreProcesses.Contains( new Tuple<string, string>( window.GetProcess().ProcessName, window.GetClassName() ) ) && _customWindowFilters.All( f => f( window ) ); return valid; }