Exemplo n.º 1
0
        private void MoveCurrentByIdx(int relativeIndex)
        {
            int newPosition = TheCompletionsCollectionView.CurrentPosition + relativeIndex;

            int totalNumberItems = 0;

            foreach (var obj in TheCompletionsCollectionView)
            {
                totalNumberItems++;
            }

            if (totalNumberItems == 0)
            {
                return;
            }

            if (newPosition >= totalNumberItems)
            {
                newPosition = totalNumberItems - 1;
            }

            if (newPosition < 0)
            {
                newPosition = 0;
            }

            TheCompletionsCollectionView.MoveCurrentToPosition(newPosition);

            ScrollAsync();
        }
Exemplo n.º 2
0
        void SelectItemBasedOnTextFiltering()
        {
            string userText = UserText;

            bool foundCompletion = false;

            // if we find completion that starts with the text
            // we choose it.
            if (!string.IsNullOrEmpty(userText))
            {
                foreach (Completion completion in TheCompletionsCollectionView)
                {
                    if (completion.DisplayText?.ToLower().StartsWith(userText) == true)
                    {
                        SelectItem(completion);
                        foundCompletion = true;
                        break;
                    }
                }
            }

            // if the match by text was not found
            // we move the current item to the first of
            // items within the filtered collection
            if (!foundCompletion)
            {
                TheCompletionsCollectionView.MoveCurrentToFirst();
            }

            // we force the ListView to scroll to the
            // current item
            ScrollAsync();
        }
Exemplo n.º 3
0
        private void TextBuffer_Changed(object sender, TextContentChangedEventArgs e)
        {
            // refresh the filter
            TheCompletionsCollectionView.Refresh();

            // choose the CompletionStatus based on the new filtering
            SelectItemBasedOnTextFiltering();
        }
Exemplo n.º 4
0
 void SelectItem(Completion completionItem)
 {
     TheCompletionsCollectionView.MoveCurrentTo(completionItem);
 }
Exemplo n.º 5
0
 // force refiltering of the CollectionView
 private void Filter_PropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     TheCompletionsCollectionView.Refresh();
 }