コード例 #1
0
        private void List_words_ItemTapped(object sender, ItemTappedEventArgs e)
        {
            //showing an alert with the definition
            var clickedItem = e.Item as WordDefinition;
            var wordDef     = app.getDefinitionsByName(clickedItem.Name);

            //in case of more than one definition, a text format will be made
            if (wordDef.Count > 1)
            {
                string defText = textFormat(wordDef);

                DisplayAlert(wordDef.First().Name, defText, "OK");
            }
            else
            {
                WordDefinition def = wordDef.First();
                DisplayAlert(def.Name, def.Definition, "OK");
            }

            //unmarking item
            ((ListView)sender).SelectedItem = null;

            //add the clicked item to history list if it's not duplicated
            if (!UserProperties.HistoryList.Contains(clickedItem.Name))
            {
                UserProperties.HistoryList.Push(clickedItem.Name);
            }

            //Send a message to HistoryPage to refresh their screen with this new word
            MessagingCenter.Send <SearchPage>(this, "newWordHistory");
        }
コード例 #2
0
        private void HistoryList_ItemTapped(object sender, ItemTappedEventArgs e)
        {
            //showing an alert with the definition
            var clickedItem = e.Item as string;
            var wordDef     = app.getDefinitionsByName(clickedItem);

            //in case of more than one definition, a text format will be made
            if (wordDef.Count > 1)
            {
                string defText = textFormat(wordDef);

                DisplayAlert(wordDef.First().Name, defText, "OK"); //show alert on screen
            }
            else
            {
                WordDefinition def = wordDef.First();

                DisplayAlert(def.Name, def.Definition, "OK"); //show alert on screen
            }

            //unmarking item
            ((ListView)sender).SelectedItem = null;
        }
コード例 #3
0
        private void List_words_ItemTapped(object sender, ItemTappedEventArgs e)
        {
            if (isCategoriesOnScreen)
            {
                var clickedItem = e.Item as string;

                //remove list on the screen
                layout.Children.Remove(list_words);

                list_words = new ListView
                {
                    ItemTemplate = new DataTemplate(typeof(TextCell))
                    {
                        Bindings =
                        {
                            { TextCell.TextProperty, new Binding("Name") }
                        }
                    },

                    GroupDisplayBinding   = new Binding("Key"),
                    GroupShortNameBinding = new Binding("Key"),
                    IsGroupingEnabled     = true,
                    ItemsSource           = ListingByCategory(clickedItem), //Listing by Categories here
                };

                //add on screen after setup
                layout.Children.Add(list_words);
                //call this same method again, because now there is a new list on Screen, then a new method is required
                list_words.ItemTapped += List_words_ItemTapped;
                //prevent to get in this IF statement again
                isCategoriesOnScreen = false;
            }
            else
            {
                //showing an alert with the definition
                var clickedItem = e.Item as WordDefinition;
                var wordDef     = app.getDefinitionsByName(clickedItem.Name);

                //in case of more than one definition, a text format will be made
                if (wordDef.Count > 1)
                {
                    string defText = textFormat(wordDef);

                    DisplayAlert(wordDef.First().Name, defText, "OK");
                }
                else
                {
                    WordDefinition def = wordDef.First();
                    DisplayAlert(def.Name, def.Definition, "OK");
                }

                //add the clicked item to history list if it's not duplicated
                if (!UserProperties.HistoryList.Contains(clickedItem.Name))
                {
                    UserProperties.HistoryList.Push(clickedItem.Name);
                }

                //Send a message to HistoryPage to refresh their screen with this new word
                MessagingCenter.Send <SearchPage>(new SearchPage(), "newWordHistory");
            }


            //unmarking item
            ((ListView)sender).SelectedItem = null;
        }