protected override void DisplayCustomPoiInfo(Object modelObject) { ExampleApp.SearchResultModelCLI model = modelObject as ExampleApp.SearchResultModelCLI; YelpResultModel yelpResultModel = YelpResultModel.FromResultModel(model); var mainGrid = (Application.Current.MainWindow as MainWindow).MainGrid; var screenWidth = mainGrid.ActualWidth; m_closing = false; TitleText = model.Title; AddressText = model.Subtitle.Replace(", ", "," + Environment.NewLine); PhoneText = yelpResultModel.Phone; HumanReadableTagsText = string.Join(", ", model.HumanReadableTags); ReviewText = string.Join(Environment.NewLine, yelpResultModel.Reviews); TagIcon = SearchResultPoiViewIconProvider.GetIconForTag(model.IconKey); PoiViewRatingCountText = yelpResultModel.ReviewCount > 0 ? yelpResultModel.ReviewCount.ToString() : string.Empty; RatingsImage.Source = null; m_contentContainer.ScrollToTop(); if (yelpResultModel.ReviewCount > 0 && !string.IsNullOrEmpty(yelpResultModel.RatingsImageUrl)) { RatingsImage.Source = new BitmapImage(ViewHelpers.MakeUriForImage(string.Format("{0}.png", yelpResultModel.RatingsImageUrl))); } if (string.IsNullOrEmpty(yelpResultModel.ImageUrl)) { m_previewImageSpinner.Visibility = Visibility.Hidden; m_imageGradient.Visibility = Visibility.Collapsed; m_poiImageAndGradientContainer.Visibility = Visibility.Collapsed; m_detailsContainer.Height = Double.NaN; } else { m_previewImageSpinner.Visibility = Visibility.Visible; m_imageGradient.Visibility = Visibility.Visible; m_poiImageAndGradientContainer.Visibility = Visibility.Visible; m_detailsContainer.Height = 250; } RatingCountVisibility = !string.IsNullOrEmpty(yelpResultModel.RatingsImageUrl) && yelpResultModel.ReviewCount > 0 ? Visibility.Visible : Visibility.Collapsed; Url = yelpResultModel.WebUrl; if (string.IsNullOrEmpty(ReviewText)) { m_reviewsIcon.Visibility = Visibility.Hidden; } else { m_reviewsIcon.Visibility = Visibility.Visible; } m_poiImageContainer.Visibility = Visibility.Visible; m_poiImage.Visibility = Visibility.Hidden; ShowAll(); }
public override void DisplayPoiInfo(Object modelObject, bool isPinned) { ExampleApp.SearchResultModelCLI model = modelObject as ExampleApp.SearchResultModelCLI; YelpResultModel yelpResultModel = YelpResultModel.FromResultModel(model); m_closing = false; TitleText = model.Title; AddressText = model.Subtitle.Replace(", ", Environment.NewLine); PhoneText = yelpResultModel.Phone; HumanReadableCategoriesText = string.Join(Environment.NewLine, model.HumanReadableCategories); ReviewText = string.Join(Environment.NewLine, yelpResultModel.Reviews); CategoryIcon = StartupResourceLoader.GetBitmap(SearchResultCategoryMapper.GetIconImageName(model.Category)); PoiViewRatingCountText = yelpResultModel.ReviewCount.ToString(); RatingsImage = null; if (yelpResultModel.ReviewCount > 0 && !string.IsNullOrEmpty(yelpResultModel.RatingsImageUrl)) { RatingsImage = new BitmapImage(ViewHelpers.MakeUriForImage(string.Format("{0}.png", yelpResultModel.RatingsImageUrl))); } RatingCountVisibility = string.IsNullOrEmpty(yelpResultModel.ImageUrl) && !string.IsNullOrEmpty(yelpResultModel.RatingsImageUrl) && yelpResultModel.ReviewCount > 0 ? Visibility.Visible : Visibility.Collapsed; Url = yelpResultModel.WebUrl; if (string.IsNullOrEmpty(ReviewText)) { m_reviewsIcon.Visibility = Visibility.Hidden; } else { m_reviewsIcon.Visibility = Visibility.Visible; } m_poiImage.Source = new BitmapImage(new Uri("/ExampleAppWPF;component/Assets/poi_placeholder.png", UriKind.Relative)); m_isPinned = isPinned; OnPropertyChanged("IsPinned"); ShowAll(); }
protected override void DisplayCustomPoiInfo(Object modelObject) { ExampleApp.SearchResultModelCLI model = modelObject as ExampleApp.SearchResultModelCLI; YelpResultModel yelpResultModel = YelpResultModel.FromResultModel(model); var mainGrid = (Application.Current.MainWindow as MainWindow).MainGrid; var screenWidth = mainGrid.ActualWidth; m_closing = false; TitleText = model.Title; AddressText = model.Subtitle.Replace(", ", "," + Environment.NewLine); PhoneText = yelpResultModel.Phone; HumanReadableCategoriesText = string.Join(Environment.NewLine, model.HumanReadableCategories); ReviewText = string.Join(Environment.NewLine, yelpResultModel.Reviews); CategoryIcon = SearchResultPoiViewIconProvider.GetIconForCategory(model.Category); PoiViewRatingCountText = yelpResultModel.ReviewCount > 0 ? yelpResultModel.ReviewCount.ToString() : string.Empty; RatingsImage = null; if (yelpResultModel.ReviewCount > 0 && !string.IsNullOrEmpty(yelpResultModel.RatingsImageUrl)) { RatingsImage = new BitmapImage(ViewHelpers.MakeUriForImage(string.Format("{0}.png", yelpResultModel.RatingsImageUrl))); } RatingCountVisibility = !string.IsNullOrEmpty(yelpResultModel.RatingsImageUrl) && yelpResultModel.ReviewCount > 0 ? Visibility.Visible : Visibility.Collapsed; Url = yelpResultModel.WebUrl; if (string.IsNullOrEmpty(ReviewText)) { m_reviewsIcon.Visibility = Visibility.Hidden; } else { m_reviewsIcon.Visibility = Visibility.Visible; } m_poiImage.Source = new BitmapImage(new Uri("/ExampleAppWPF;component/Assets/poi_placeholder.png", UriKind.Relative)); ShowAll(); }
public static YelpResultModel FromResultModel(ExampleApp.SearchResultModelCLI model) { MemoryStream stream = new MemoryStream(Encoding.Unicode.GetBytes(model.JsonData)); DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(YelpResultModel)); stream.Position = 0; YelpResultModel result = (YelpResultModel)serializer.ReadObject(stream); string ratingString = result.m_rating.ToString(); if (!ratingString.Contains(".")) { ratingString += ".0"; } ratingString = ratingString.Replace('.', '_'); result.RatingsImageUrl = "stars_" + ratingString; result.Reviews = new List <string>(); result.Reviews.Add(result.m_snippetText); return(result); }