Beispiel #1
0
        //TreeSearch
        public void ForeachItems(ItemLoopDelegate nodeItemDelegate)
        {
            ForeachItemsRecursion(this);

            bool ForeachItemsRecursion(ITreeFolder folder)
            {
                bool breakFlag = false;

                foreach (ITreeItem item in folder.ChildItemCollection)
                {
                    nodeItemDelegate(item, ref breakFlag);

                    if (item is ITreeFolder)
                    {
                        if (!ForeachItemsRecursion(item as ITreeFolder))
                        {
                            return(false);
                        }
                    }

                    if (breakFlag)
                    {
                        return(false);
                    }
                }
                return(true);
            }
        }
Beispiel #2
0
        public void ForeachItemsOptimize(ItemLoopDelegate nodeItemDelegate)
        {
            float childContextHeight = (float)ChildItemScrollViewer.ActualHeight;

            ForeachItemsRecursion(this);

            bool ForeachItemsRecursion(ITreeFolder folder)
            {
                bool breakFlag = false;

                foreach (ITreeItem item in folder.ChildItemCollection)
                {
                    //화면 영역 밖에 벗어나면 스킵
                    FrameworkElement itemView = (FrameworkElement)item;
                    float            itemTop  = (float)item.TranslatePoint(new Point(), ChildItemScrollViewer).Y;
                    if ((itemTop < -itemView.ActualHeight || itemTop > childContextHeight))
                    {
                        continue;
                    }

                    nodeItemDelegate(item, ref breakFlag);

                    if (item is ITreeFolder)
                    {
                        if (!ForeachItemsRecursion(item as ITreeFolder))
                        {
                            return(false);
                        }
                    }

                    if (breakFlag)
                    {
                        return(false);
                    }
                }
                return(true);
            }
        }