public ICaptureElement FindElementUnderPoint(Point point) { if (!Bounds.Contains(point)) { return(null); } foreach (CaptureElement childElement in children) { if (childElement.Bounds.Contains(point)) { ICaptureElement selectedElement = childElement.FindElementUnderPoint(point); return(selectedElement); } } return(this); }
/// <summary> /// Add a new element to the capture /// </summary> /// <param name="element">CaptureElement</param> public void AddElement(ICaptureElement element) { int match = elements.IndexOf(element); if (match >= 0) { if (elements[match].Children.Count < element.Children.Count) { elements.RemoveAt(match); elements.Add(element); } } else { elements.Add(element); } }
private void AddCaptureElementsForWindow(ICaptureElement parentElement, WindowDetails parentWindow, int level) { foreach (WindowDetails childWindow in parentWindow.Children) { // Make sure the details are retrieved once childWindow.FreezeDetails(); Rectangle childRectangle = childWindow.WindowRectangle; Size s1 = childRectangle.Size; childRectangle.Intersect(parentElement.Bounds); if (childRectangle.Width > 0 && childRectangle.Height > 0) { CaptureElement childCaptureElement = new CaptureElement(childRectangle); parentElement.Children.Add(childCaptureElement); if (level > 0) { AddCaptureElementsForWindow(childCaptureElement, childWindow, level - 1); } } } }