using System; using System.Collections.Generic; using System.Linq; using System.Windows.Forms; namespace Shadowsocks.Util { public static class ViewUtils { public static IEnumerable GetChildControls(this Control control) where TControl : Control { if (control.Controls.Count == 0) { return Enumerable.Empty(); } var children = control.Controls.OfType().ToList(); return children.SelectMany(GetChildControls).Concat(children); } } }