private List <Fragment> CaptureFragments(Form form) { var fragments = new List <Fragment>(); var context = new CapturingContext(form); CaptureFragments(context, form, fragments, slice: 0); return(fragments); }
private static Point GetRelativeLocation(CapturingContext context, Control control) { var controlLocationOnScreen = control.PointToScreen(Point.Empty); var result = new Point( controlLocationOnScreen.X - context.FormClientAreaLocationOnScreen.X, controlLocationOnScreen.Y - context.FormClientAreaLocationOnScreen.Y); System.Diagnostics.Debug.WriteLine($"{control.Name}: Relative location is {result}"); return(result); }
private void CaptureFragments(CapturingContext context, Control current, List <Fragment> fragments, int slice) { var fragment = CaptureFragment(context, current, slice); // fragment should not be shown (could be a hidden tabpage) -> skip it with all of its children if (fragment == null) { return; } fragments.Add(fragment); foreach (Control control in current.Controls) { CaptureFragments(context, control, fragments, slice + 1); } }
private Fragment CaptureFragment(CapturingContext context, Control control, int slice) { if (!FragmentSelector.ShouldShowFragment(control)) { return(null); } var location = control is Form ? Point.Empty : GetRelativeLocation(context, control); return(new Fragment() { Control = control, OriginallyVisible = control.Visible, Location = location, Slice = slice, Stamp = DateTime.UtcNow.Ticks }); }