Ejemplo n.º 1
0
        public void LayoutItems(ERect bound, bool force)
        {
            if (_allocatedSize.Width <= 0 || _allocatedSize.Height <= 0)
            {
                return;
            }

            // TODO : need to optimization. it was frequently called with similar bound value.
            if (!ShouldRearrange(bound) && !force)
            {
                return;
            }

            _isLayouting = true;
            _last        = bound;

            int padding    = Span;
            int startIndex = Math.Max(GetStartIndex(bound) - padding, 0);
            int endIndex   = Math.Min(GetEndIndex(bound) + padding, CollectionView.Count - 1);

            foreach (var index in _realizedItem.Keys.ToList())
            {
                if (index < startIndex || index > endIndex)
                {
                    CollectionView.UnrealizeView(_realizedItem[index].View);
                    _realizedItem.Remove(index);
                }
            }

            var parent = CollectionView.ParentPosition;

            for (int i = startIndex; i <= endIndex; i++)
            {
                EvasObject itemView = null;
                if (!_realizedItem.ContainsKey(i))
                {
                    var view = CollectionView.RealizeView(i);

                    _realizedItem[i] = new RealizedItem
                    {
                        View  = view,
                        Index = i,
                    };
                    itemView = view;
                }
                else
                {
                    itemView = _realizedItem[i].View;
                }

                var itemBound = GetItemBound(i);
                itemBound.X      += parent.X;
                itemBound.Y      += parent.Y;
                itemView.Geometry = itemBound;
            }
            _isLayouting = false;
        }
Ejemplo n.º 2
0
 public void ItemUpdated(int index)
 {
     if (_realizedItem.ContainsKey(index))
     {
         var bound = _realizedItem[index].View.Geometry;
         CollectionView.UnrealizeView(_realizedItem[index].View);
         var view = CollectionView.RealizeView(index);
         _realizedItem[index].View = view;
         view.Geometry             = bound;
     }
 }