コード例 #1
0
        public static void GetVisibleItems <T>(this IEnumerable <T> items, FrameworkElement viewport, Orientation orientation, out List <T> beforeItems, out List <T> visibleItems, out List <T> afterItems) where T : FrameworkElement
        {
            beforeItems  = new List <T>();
            visibleItems = new List <T>();
            afterItems   = new List <T>();
            ExtensionMethods.VisibleSearchMode visibleSearchMode = ExtensionMethods.VisibleSearchMode.Before;
            foreach (T obj in items)
            {
                switch (visibleSearchMode)
                {
                case ExtensionMethods.VisibleSearchMode.Before:
                    if (ExtensionMethods.TestVisibility((FrameworkElement)obj, viewport, orientation, false))
                    {
                        beforeItems.Add(obj);
                        break;
                    }
                    else
                    {
                        visibleItems.Add(obj);
                        visibleSearchMode = ExtensionMethods.VisibleSearchMode.During;
                        break;
                    }

                case ExtensionMethods.VisibleSearchMode.During:
                    if (ExtensionMethods.TestVisibility((FrameworkElement)obj, viewport, orientation, true))
                    {
                        visibleItems.Add(obj);
                        break;
                    }
                    else
                    {
                        afterItems.Add(obj);
                        visibleSearchMode = ExtensionMethods.VisibleSearchMode.After;
                        break;
                    }

                default:
                    afterItems.Add(obj);
                    break;
                }
            }
        }
コード例 #2
0
 public static IEnumerable <T> GetVisibleItems <T>(this IEnumerable <T> items, FrameworkElement viewport, Orientation orientation) where T : FrameworkElement
 {
     return(Enumerable.TakeWhile <T>(Enumerable.SkipWhile <T>(items, (Func <T, bool>)(item => ExtensionMethods.TestVisibility((FrameworkElement)item, viewport, orientation, false))), (Func <T, bool>)(item => ExtensionMethods.TestVisibility((FrameworkElement)item, viewport, orientation, true))));
 }