Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/24/13 20:22:11 (11 years ago)
Author:
ascheibe
Message:

#2030 merged trunk into hive performance branch

Location:
branches/HivePerformance/sources
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/HivePerformance/sources

  • branches/HivePerformance/sources/HeuristicLab.MainForm.WindowsForms/3.3/Controls/ControlExtensions.cs

    r9539 r9655  
    2121
    2222using System;
     23using System.Collections.Generic;
    2324using System.Runtime.InteropServices;
    2425using System.Windows.Forms;
     
    4546      }
    4647    }
     48
     49    public static IEnumerable<Control> GetNestedControls(this Control control, Func<Control, bool> condition = null) {
     50      if (control == null) yield break;
     51      if (condition == null) condition = (c) => true;
     52
     53      Queue<Control> unprocessed = new Queue<Control>();
     54      unprocessed.Enqueue(control);
     55
     56      while (unprocessed.Count > 0) {
     57        Control c = unprocessed.Dequeue();
     58        if (condition(c)) yield return c;
     59        foreach (Control child in c.Controls)
     60          unprocessed.Enqueue(child);
     61      }
     62    }
    4763  }
    4864}
Note: See TracChangeset for help on using the changeset viewer.