protected async override void OnAppearing()
        {
            base.OnAppearing();
            {
                List <wordInfo> wordsInfo = new List <wordInfo>();

                try
                {
                    //TODO:get words might want to get words in a diff part if the call is async dont want user to be waiting
                    for (int i = 0; i < MANAGER.words.Count; i++)
                    {
                        downloadMgr downloadMgr = new downloadMgr();

                        wordInfo w = await downloadMgr.getWord(MANAGER.words[i]);

                        wordsInfo.Add(w);
                    }
                    listView.ItemsSource = wordsInfo;
                }
                catch (Exception e)
                {
                    Debug.WriteLine(e.Message);
                    Debug.WriteLine(e.StackTrace);
                }
            }
        }
		public async Task<wordInfo> getWord(string word)
		{
			wordInfo WI = new wordInfo();

			var c = await new HttpClient().GetStringAsync(Constants.GoogleGetWord + word);

			GoogleParser gp = new GoogleParser(c, word);
			WI.word = word;
			WI.definition = gp.OUTPUT.definition;
			WI.partOfSpeech = gp.OUTPUT.partOfSpeech;
			WI.pronunciation = gp.OUTPUT.pronunciation;
			
			if (MANAGER.GetSynonyms)
			{
				var t = await new HttpClient().GetStringAsync(Constants.ThesarusGetSynAnt + word);
				ThesaurusParser tp = new ThesaurusParser(t);
				WI.synonyms = tp.syns;
				WI.antonyms = tp.ants;
			}

			return WI;
		}
Example #3
0
        public wordView(wordInfo w)
        {
            Title = (char.ToUpper(w.word[0]) + w.word.Substring(1));

            #region labels
            Label lblWord = new Label
            {
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                FontSize          = Device.GetNamedSize(NamedSize.Large, typeof(Label)),
            };
            lblWord.Text = w.word;

            Label lblDefinition = new Label
            {
                HorizontalOptions = LayoutOptions.CenterAndExpand,
            };
            lblDefinition.Text = w.definition;

            Label lblPartOfSpeech = new Label
            {
                HorizontalOptions = LayoutOptions.CenterAndExpand,
            };
            lblPartOfSpeech.Text = w.partOfSpeech;

            Label lblPronuc = new Label
            {
                HorizontalOptions = LayoutOptions.CenterAndExpand,
            };
            lblPronuc.Text = w.pronunciation;

            #endregion


            StackLayout synstack = new StackLayout {
                Padding = new Thickness(10),
            };
            foreach (string s in w.synonyms)
            {
                synstack.Children.Add(new Label {
                    Text = s
                });
            }

            ScrollView synScrollview = new ScrollView {
                Content = synstack
            };

            StackLayout antstack = new StackLayout {
                Padding = new Thickness(10),
            };
            foreach (string s in w.antonyms)
            {
                antstack.Children.Add(new Label {
                    Text = s
                });
            }

            ScrollView antScrollview = new ScrollView {
                Content = antstack
            };


            Content = new StackLayout
            {
                Padding  = new Thickness(25),
                Children =
                {
                    //	lblWord,
                    lblPronuc,

                    new ScrollView {
                        Content = lblDefinition,
                    },

                    lblPartOfSpeech,
                    new StackLayout {
                        Orientation = StackOrientation.Horizontal,
                        Children    =
                        {
                            new StackLayout   {
                                VerticalOptions   = LayoutOptions.StartAndExpand,
                                HorizontalOptions = LayoutOptions.CenterAndExpand,
                                Children          =
                                {
                                    new Label {
                                        Text = "Synonyms",FontSize                        = Device.GetNamedSize(NamedSize.Medium, typeof(Label)),
                                    },
                                    synScrollview
                                }
                            },
                            new StackLayout   {
                                VerticalOptions   = LayoutOptions.StartAndExpand,
                                HorizontalOptions = LayoutOptions.CenterAndExpand,
                                Children          =
                                {
                                    new Label {
                                        Text = "Antonyms",FontSize                        = Device.GetNamedSize(NamedSize.Medium, typeof(Label)),
                                    },
                                    antScrollview
                                }
                            }
                        }
                    }
                }
            };
        }