Exemple #1
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"].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;
        }
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;
        }
        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 RefreshListData(List<string> groups, List<bool> groupsExpandable, Dictionary<string, List<string>> groupToChildrenMap)
        {
            List<string> searchData;

            if (groupToChildrenMap.TryGetValue("Search", out searchData))
            {
                var itemsSource = new List<SearchMenuListItem>();
                var jsonObjects = from json in searchData select JObject.Parse(json);

                foreach (var jsonObject in jsonObjects)
                {
                    var item = new SearchMenuListItem();
                    item.Name = jsonObject["name"].Value<string>();
                    item.Details = jsonObject["details"].Value<string>();

                    JToken iconStringToken;
                    var iconString = jsonObject.TryGetValue("icon", out iconStringToken) ? iconStringToken.Value<string>() : "misc";
                    item.Icon = new BitmapImage(ViewHelpers.MakeUriForImage(string.Format("icon1_{0}.png", iconString)));
                    itemsSource.Add(item);
                }

                m_list.ItemsSource = itemsSource;
            }
        }