public void SetSearchSection(string category, string[] searchResults) { var groups = new List <string>(searchResults.Length); var groupsExpandable = new List <bool>(searchResults.Length); var groupToChildren = new Dictionary <string, List <string> >(); var itemsSource = new List <SearchMenuListItem>(); foreach (var str in searchResults) { var jObject = JObject.Parse(str); var item = new SearchMenuListItem(); item.Name = jObject["name"].Value <string>(); item.Details = jObject["details"].Value <string>(); JToken iconStringToken; var iconString = jObject.TryGetValue("icon", out iconStringToken) ? iconStringToken.Value <string>() : "misc"; item.Icon = new System.Windows.Media.Imaging.BitmapImage(ViewHelpers.MakeUriForImage(string.Format("icon1_{0}.png", iconString))); itemsSource.Add(item); groups.Add(str); groupsExpandable.Add(false); groupToChildren.Add(str, new List <string>()); } m_resultListAdapter.SetData(itemsSource, groups, groupsExpandable, groupToChildren); m_resultsSpinner.Visibility = Visibility.Hidden; m_resultsClearButton.Visibility = Visibility.Visible; m_searchArrow.Visibility = Visibility.Visible; m_resultsSeparator.Visibility = Visibility.Visible; m_searchInFlight = false; }
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 SubMenuListItem(string json, int zIndex) : base(json, false, zIndex) { JObject parsed = JObject.Parse(json); JToken iconField; if (parsed.TryGetValue("icon", out iconField)) { m_iconString = iconField.Value <string>(); m_icon = new BitmapImage(ViewHelpers.MakeUriForImage(string.Format("icon1_{0}.png", m_iconString))); } }
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(); }