public Snapshot ProcessGetSnapshot(Snapshot snapshot) { snapshot.Details.Screens = Screen.AllScreens.Select(screen => { return(new DTO.ScreenInfo() { Rectangle = new NativeMethods.RECT( screen.Bounds.Left, screen.Bounds.Top, screen.Bounds.Right, screen.Bounds.Bottom), IsPrimary = screen.Primary, Name = screen.DeviceName }); }).ToArray(); foreach (var windowEntry in snapshot.Windows) { if (windowEntry.Name.StartsWith("@@")) { continue; } var handle = windowEntry.NativeId; NativeMethods.RECT rect; NativeMethods.GetWindowRect(handle, out rect); var offset = 8; // Check if the corners are visible as a crude // edge detection system var topLeftHit = HitTest(handle, new Point(rect.left + offset, rect.top + offset)); var topRightHit = HitTest(handle, new Point(rect.right - offset, rect.top + offset)); var bottomLeftHit = HitTest(handle, new Point(rect.left + offset, rect.bottom - offset)); var bottomRightHit = HitTest(handle, new Point(rect.right - offset, rect.bottom - offset)); var visibleEdges = new EdgeVisibility(); visibleEdges.Top = topLeftHit && topRightHit; visibleEdges.Bottom = bottomLeftHit && bottomRightHit; visibleEdges.Left = topLeftHit && bottomLeftHit; visibleEdges.Right = topRightHit && bottomRightHit; // Window Rect will be in unscaled, physical coordinates windowEntry.Rectangle = rect; windowEntry.VisibleEdges = visibleEdges; } // Sort the windows by their Z-Order, Highest appears first in list var allWindowsSorted = NativeMethods.EnumWindows(IntPtr.Zero); snapshot.Windows = allWindowsSorted .Join(snapshot.Windows, nativeId => nativeId, windowEntry => windowEntry.NativeId, (key, item) => item) .ToArray(); return(snapshot); }
public void AcceptAttributeEdgeVisibility(EdgeVisibility edgeVisibility, PrintContext parameter) { parameter.WriteLine("Edge Visibility: {0}", edgeVisibility.Visibility); }
public virtual void AcceptAttributeEdgeVisibility(EdgeVisibility edgeVisibility, T parameter) { // intentionally left blank }