public SubMenuListItem(string json, int zIndex)
            : base(json, false, zIndex)
        {
            JObject parsed = JObject.Parse(json);
            JToken  iconField;

            if (parsed.TryGetValue("icon", out iconField))
            {
                var iconCategoryName = iconField.Value <string>();
                m_icon = SearchMenuResultIconProvider.GetIconForCategory(iconCategoryName);
            }

            JToken detailsField;

            if (parsed.TryGetValue("details", out detailsField))
            {
                m_details        = detailsField.Value <string>();
                DetailVisibility = "Visible";
                TitleTextColor   = Colour.black;
            }
        }
Exemple #2
0
        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"] != null ? jObject["name"].Value <string>() : string.Empty;
                item.Details = jObject["details"] != null ? jObject["details"].Value <string>() : string.Empty;

                JToken iconStringToken;
                var    iconCategoryName = jObject.TryGetValue("icon", out iconStringToken) ? iconStringToken.Value <string>() : "";
                item.Icon = SearchMenuResultIconProvider.GetIconForCategory(iconCategoryName);
                itemsSource.Add(item);

                groups.Add(str);
                groupsExpandable.Add(false);

                if (!groupToChildren.ContainsKey(str))
                {
                    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;
        }