示例#1
0
        private void situationView_DoubleClick(object sender, EventArgs e)
        {
            string[] item      = fastSituationView.SelectedObject.ToString().Split(' ');
            bool     flag      = false;
            int      messageID = SituationIndex.Index[item[0]][Int32.Parse(item[1])][0];

            //tagTable.EnsureVisible(tagTable.GetItemCount() - 1);

            while (!flag)
            {
                if (chatTable.Items.Count > messageID)
                {
                    chatTable.EnsureVisible(messageID);
                    flag = true;
                }
                else
                {
                    //DialogResult res = MessageBox.Show("This will load additional messages. Proceed?");
                    //if (res == DialogResult.OK)
                    //{
                    LoadMore?.Invoke(this, EventArgs.Empty);
                    //}
                }
            }
        }
        // This happens many times a second during a scroll, so be wary of the code you place here.
        // We are given a few useful parameters to help us work out if we need to load some more data,
        // but first we check if we are waiting for the previous load to finish.
        public override void OnScrolled(RecyclerView view, int dx, int dy)
        {
            if (dy == 0)
            {
                return;
            }
            _startScrollPosition += dy;
            _gridView.RaiseOnScroll(dy / _density, _recyclerView.GetHorizontalScrollOffset() / _density, _startScrollPosition / _density, ScrollActionType.Finger);


            if (!EnableLoadMore)
            {
                return;
            }
            var lastVisibleItemPosition = 0;
            var totalItemCount          = _layoutManager.ItemCount;

            if (_layoutManager is StaggeredGridLayoutManager manager)
            {
                var lastVisibleItemPositions = manager.FindLastVisibleItemPositions(null);
                // get maximum element within the list
                lastVisibleItemPosition = GetLastVisibleItem(lastVisibleItemPositions);
            }
            else if (_layoutManager is LinearLayoutManager)
            {
                lastVisibleItemPosition = ((LinearLayoutManager)_layoutManager).FindLastVisibleItemPosition();
            }

            // If the total item count is zero and the previous isn't, assume the
            // list is invalidated and should be reset back to initial state
            if (totalItemCount < _previousTotalItemCount)
            {
                _previousTotalItemCount = totalItemCount;
                if (totalItemCount == 0)
                {
                    _loading = true;
                }
            }
            // If it’s still loading, we check to see if the dataset count has
            // changed, if so we conclude it has finished loading and update the current page
            // number and total item count.
            if (_loading && (totalItemCount > _previousTotalItemCount))
            {
                _loading = false;
                _previousTotalItemCount = totalItemCount;
            }

            // If it isn’t currently loading, we check to see if we have breached
            // the visibleThreshold and need to reload more data.
            // If we do need to reload some more data, we execute onLoadMore to fetch the data.
            // threshold should reflect how many total columns there are too
            if (_loading || (lastVisibleItemPosition + _visibleThreshold) <= totalItemCount)
            {
                return;
            }

            LoadMore?.Invoke();
            _loading = true;
        }
示例#3
0
 private void ScrollViewer_ViewChanged(object sender, ScrollViewerViewChangedEventArgs e)
 {
     if (_scrollViewer.VerticalOffset == 0)
     {
         LoadMore?.Invoke(this, new EventArgs());
         _isLoadMore = true;
     }
 }
        private void chatTable_Scroll(object sender, ScrollEventArgs e)
        {
            scrollCount = e.NewValue;
            Console.WriteLine(scrollCount);

            if ((scrollCount - 988) % 100 == 0 || ((scrollCount - 984) % 100 == 0) && scrollCount != 0) //i promise i will learn what wndproc is one day...
            {
                LoadMore?.Invoke(this, EventArgs.Empty);
            }
        }
示例#5
0
        void InfiniteListView_ItemAppearing(object sender, ItemVisibilityEventArgs e)
        {
            var items = ItemsSource as IList;

            if (items != null && e.Item == items[items.Count - 1] && !IsRefreshing)
            {
                LoadMore?.Invoke(this, new EventArgs());
                LoadMoreCommand?.Execute(null);
            }
        }
示例#6
0
        private void ScrollViewer_ViewChanged(object sender, ScrollViewerViewChangedEventArgs e)
        {
            var scrollViewer           = sender as ScrollViewer;
            var verticalOffsetValue    = scrollViewer.VerticalOffset;
            var maxVerticalOffsetValue = scrollViewer.ExtentHeight - scrollViewer.ViewportHeight;

            if (maxVerticalOffsetValue < 0 || verticalOffsetValue == maxVerticalOffsetValue)
            {
                LoadMore?.Invoke(this, new EventArgs());
            }
        }
        // This happens many times a second during a scroll, so be wary of the code you place here.
        // We are given a few useful parameters to help us work out if we need to load some more data,
        // but first we check if we are waiting for the previous load to finish.
        public override void OnScrolled(RecyclerView recyclerView, int dx, int dy)
        {
            var lastVisibleItemPosition = mLayoutManager.FindFirstVisibleItemPosition();

            if (lastVisibleItemPosition < visibleThreshold)
            {
                LoadMore?.Invoke(this, new LoadMoreEventArgs {
                    Page = lastVisibleItemPosition, TotalItemsCount = 0
                });
            }
        }
示例#8
0
        public override void OnScrolled(RecyclerView view, int dx, int dy)
        {
            if (dy == 0)
            {
                return;
            }
            _startScrollPosition += dy;
            _fastGridView.RaiseOnScroll(dy / _density, _recyclerView.GetHorizontalScrollOffset() / _density,
                                        _startScrollPosition / _density, ScrollActionType.Finger);


            if (!EnableLoadMore)
            {
                return;
            }
            var lastVisibleItemPosition = 0;
            var totalItemCount          = _layoutManager.ItemCount;

            switch (_layoutManager)
            {
            case StaggeredGridLayoutManager manager:
                var lastVisibleItemPositions = manager.FindLastVisibleItemPositions(null);
                lastVisibleItemPosition = GetLastVisibleItem(lastVisibleItemPositions);
                break;

            case LinearLayoutManager _:
                lastVisibleItemPosition = ((LinearLayoutManager)_layoutManager).FindLastVisibleItemPosition();
                break;
            }

            if (totalItemCount < _previousTotalItemCount)
            {
                _previousTotalItemCount = totalItemCount;
                if (totalItemCount == 0)
                {
                    _loading = true;
                }
            }

            if (_loading && (totalItemCount > _previousTotalItemCount))
            {
                _loading = false;
                _previousTotalItemCount = totalItemCount;
            }

            if (_loading || (lastVisibleItemPosition + _visibleThreshold) <= totalItemCount)
            {
                return;
            }

            LoadMore?.Invoke();
            _loading = true;
        }
示例#9
0
        void InfiniteListView_ItemAppearing(object sender, ItemVisibilityEventArgs e)
        {
            var items = ItemsSource as IList;

            if (items != null && e.Item == items[items.Count - 1])
            {
                if (LoadMoreCommand != null && LoadMoreCommand.CanExecute(null))
                {
                    LoadMoreCommand.Execute(null);
                }

                LoadMore?.Invoke(this, null);
            }
        }
示例#10
0
        public override void OnScrolled(int dx, int dy)
        {
            base.OnScrolled(dx, dy);
            Scroll?.Invoke(this, new ScrollEventArgs(dx, dy));
            if (dy <= 0)
            {
                return;
            }
            var visibleItemCount  = ViewLayoutManager.ChildCount;
            var totalItemCount    = ViewLayoutManager.ItemCount;
            var pastVisiblesItems = (ViewLayoutManager is LinearLayoutManager ? ViewLayoutManager as LinearLayoutManager : ViewLayoutManager is GridLayoutManager ? ViewLayoutManager as GridLayoutManager : null).FindFirstVisibleItemPosition();

            if ((visibleItemCount + pastVisiblesItems) >= totalItemCount - 3)
            {
                LoadMore?.Invoke(this, new EventArgs());
            }
        }
        public void EnsureMessageIsVisible(int id)
        {
            bool flag = false;

            while (!flag)
            {
                if (chatTable.Items.Count > id)
                {
                    chatTable.EnsureVisible(id);
                    //chatTable.SelectedObjects.Add(chatTable.GetModelObject(id));
                    flag = true;
                }
                else
                {
                    //DialogResult res = MessageBox.Show("This will load additional messages. Proceed?");
                    //if (res == DialogResult.OK)
                    //{
                    LoadMore?.Invoke(this, EventArgs.Empty);
                    //}
                }
            }
        }
        // This happens many times a second during a scroll, so be wary of the code you place here.
        // We are given a few useful parameters to help us work out if we need to load some more data,
        // but first we check if we are waiting for the previous load to finish.
        public override void OnScrolled(RecyclerView recyclerView, int dx, int dy)
        {
            int lastVisibleItemPosition = 0;
            int totalItemCount          = mLayoutManager.ItemCount;

            if (mLayoutManager is StaggeredGridLayoutManager staggeredGridLayoutManager)
            {
                int[] lastVisibleItemPositions = staggeredGridLayoutManager.FindLastVisibleItemPositions(null);
                // get maximum element within the list
                lastVisibleItemPosition = GetLastVisibleItem(lastVisibleItemPositions);
            }
            else if (mLayoutManager is GridLayoutManager gridLayoutManager)
            {
                lastVisibleItemPosition = gridLayoutManager.FindLastVisibleItemPosition();
            }
            else if (mLayoutManager is LinearLayoutManager linearLayoutManager)
            {
                lastVisibleItemPosition = linearLayoutManager.FindLastVisibleItemPosition();
            }

            // If the total item count is zero and the previous isn't, assume the
            // list is invalidated and should be reset back to initial state
            if (totalItemCount < previousTotalItemCount)
            {
                this.currentPage            = this.startingPageIndex;
                this.previousTotalItemCount = totalItemCount;
                if (totalItemCount == 0)
                {
                    this.loading = true;
                }
            }
            // If it’s still loading, we check to see if the dataset count has
            // changed, if so we conclude it has finished loading and update the current page
            // number and total item count.
            if (loading && (totalItemCount > previousTotalItemCount))
            {
                loading = false;
                previousTotalItemCount = totalItemCount;
            }

            // If it isn’t currently loading, we check to see if we have breached
            // the visibleThreshold and need to reload more data.
            // If we do need to reload some more data, we execute onLoadMore to fetch the data.
            // threshold should reflect how many total columns there are too
            if (!loading && (lastVisibleItemPosition + visibleThreshold) > totalItemCount)
            {
                currentPage++;
                LoadMore?.Invoke(this, new LoadMoreEventArgs {
                    Page = currentPage, TotalItemsCount = totalItemCount
                });
                loading = true;
            }

            if (lastVisibleItemPosition == totalItemCount - 1)
            {
                LastItemVisibleEvent?.Invoke(this, new LastItemVisibleEventArgs {
                    IsLastItemVisible = true
                });
            }
            else
            {
                LastItemVisibleEvent?.Invoke(this, new LastItemVisibleEventArgs {
                    IsLastItemVisible = false
                });
            }
        }
示例#13
0
 public void SendLoadMore()
 {
     LoadMore?.Invoke(this, new EventArgs());
 }
示例#14
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     LoadMore?.Invoke(this, new EventArgs());
     _isLoadMore = true;
 }