/// <summary> /// Creates an ImageSource from a randomly chosen URI from the ImageSources collection and returns it. /// </summary> /// <returns>Returns an ImageSource with a randomly chosen URI from the ImageSources collection.</returns> protected async Task <TitleImage> GetSource() { if (this.ImageSources.Count == 0) { return(null); //return new TitleImage(); } int index = this.rand.Next(this.ImageSources.Count); while (!this.IsNewIndexValid(index)) { index = index = this.rand.Next(this.ImageSources.Count); } string uri = this.imageSources[index].ImageUri; if (this.CreateImageSource != null) { return(this.CreateImageSource(uri)); } ImageSource imageSource = await this.CreateDefaultImageSource(uri); TitleImage titleImage = new TitleImage(); titleImage = this.imageSources[index]; titleImage.ImageSource = imageSource; return(titleImage); }
private async void CreateImageBingUI() { TitleImage titleImage = new TitleImage(); titleImage = await this.GetSource(); if (titleImage != null) { //this.FirstImage = titleImage.ImageSource; //this.firstTitleName.Text = this.FirstTitle = titleImage.Title; //this.firstContent.Text = this.FirstContent = titleImage.Content; firstImage.Source = titleImage.ImageSource; this.firstTitleName.Text = titleImage.Title; this.firstContent.Text = titleImage.Content; //this.SecondImage = titleImage.ImageSource; //this.secondTitleName.Text = this.SecondTitle = titleImage.Title; //this.secondContent.Text = this.SecondContent = titleImage.Content; secondImage.Source = titleImage.ImageSource; this.secondTitleName.Text = titleImage.Title; this.secondContent.Text = titleImage.Content; } }