コード例 #1
0
        /// <summary>
        /// Realiza a busca em toda a estrutura carregada de quizes, para não alterar a instância utilizada na lógica do quiz irei duplicar os registros encontrados.
        /// </summary>
        /// <param name="search"></param>
        /// <returns></returns>
        public static void ProcessQueryText(string search)
        {

            Win8CatalogApplication.Instance.SearchResult.Clear();

            ObservableCollection<Categoria> categories = Win8CatalogApplication.Instance.Categorias;


            foreach (Categoria categoria in categories)
            {
                Categoria searchCategory = null;
                bool founded;

                foreach (Item item in categoria.Items)
                {
                    founded = false;

                    if (item.Nome.IndexOf(search, StringComparison.CurrentCultureIgnoreCase) > -1
                        || item.Descricao.IndexOf(search, StringComparison.CurrentCultureIgnoreCase) > -1
                        || item.SubTitulo.IndexOf(search, StringComparison.CurrentCultureIgnoreCase) > -1
                        || item.Categoria.Descricao.IndexOf(search, StringComparison.CurrentCultureIgnoreCase) > -1
                        || item.SubTitulo.IndexOf(search, StringComparison.CurrentCultureIgnoreCase) > -1
                        || item.Categoria.Nome.IndexOf(search, StringComparison.CurrentCultureIgnoreCase) > -1
                    )
                    {
                        founded = true;
                    }

                    if (founded)
                    {
                        if (searchCategory == null)
                        {
                            searchCategory = new Categoria(item.Categoria.ID, item.Categoria.Nome, item.Categoria.SubTitulo, item.Categoria.Descricao, item.Categoria.ImageUrl);
                            searchCategory.Items = new ObservableCollection<Item>();
                        }

                        searchCategory.Items.Add(item);
                    }

                }

                if (searchCategory != null)
                {
                    Win8CatalogApplication.Instance.SearchResult.Add(searchCategory);
                }
            }
        }
コード例 #2
0
        public SampleDataSource()
        {
            String ITEM_CONTENT = String.Format("Item Content: {0}\n\n{0}\n\n{0}\n\n{0}\n\n{0}\n\n{0}\n\n{0}",
                        "Curabitur class aliquam vestibulum nam curae maecenas sed integer cras phasellus suspendisse quisque donec dis praesent accumsan bibendum pellentesque condimentum adipiscing etiam consequat vivamus dictumst aliquam duis convallis scelerisque est parturient ullamcorper aliquet fusce suspendisse nunc hac eleifend amet blandit facilisi condimentum commodo scelerisque faucibus aenean ullamcorper ante mauris dignissim consectetuer nullam lorem vestibulum habitant conubia elementum pellentesque morbi facilisis arcu sollicitudin diam cubilia aptent vestibulum auctor eget dapibus pellentesque inceptos leo egestas interdum nulla consectetuer suspendisse adipiscing pellentesque proin lobortis sollicitudin augue elit mus congue fermentum parturient fringilla euismod feugiat");

            var group1 = new Categoria("Group-1",
                    "Automodelo On Road",
                    "Velocidade sem limites",
                    "Group Description: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus tempor scelerisque lorem in vehicula. Aliquam tincidunt, lacus ut sagittis tristique, turpis massa volutpat augue, eu rutrum ligula ante a ante",
                    "Assets/Items/Categoria2/Item1.jpg");
            group1.Items.Add(new Item("Group-1-Item-1",
                    "Lorem ipsum dolor",
                    ITEM_CONTENT,
                    "400.00",
                    "Assets/Items/Categoria1/Item1.jpg",
                    "1:10 Losi RTR",
                    "http://pt.wikipedia.org/wiki/Automodelos_off_road",
                    group1.ID));
            group1.Items.Add(new Item("Group-1-Item-2",
                    "Lorem ipsum dolor",
                    ITEM_CONTENT,
                    "480.00",
                    "Assets/Items/Categoria1/Item2.jpg",
                    "1:10 Losi RR",
                    "http://pt.wikipedia.org/wiki/Automodelos_off_road",
                    group1.ID));
            group1.Items.Add(new Item("Group-1-Item-3",
                    "Lorem ipsum dolor",
                    ITEM_CONTENT,
                    "400.00",
                    "Assets/Items/Categoria1/Item3.jpg",
                    "1:10 Traxxas",
                    "http://pt.wikipedia.org/wiki/Automodelos_off_road",
                    group1.ID));
            group1.Items.Add(new Item("Group-1-Item-4",
                    "Lorem ipsum dolor",
                    ITEM_CONTENT,
                    "900.00",
                    "Assets/Items/Categoria1/Item4.jpg",
                    "1:10 Losi XXXX",
                    "http://pt.wikipedia.org/wiki/Automodelos_off_road",
                    group1.ID));

            this.AllGroups.Add(group1);

            var group2 = new Categoria("Group-2",
                    "Automodelo OFF Road",
                    "Emoção fora das pistas",
                    "Group Description: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus tempor scelerisque lorem in vehicula. Aliquam tincidunt, lacus ut sagittis tristique, turpis massa volutpat augue, eu rutrum ligula ante a ante",
                    "Assets/Items/Categoria2/Item1.jpg");
            group2.Items.Add(new Item("Group-2-Item-1",
                    "Lorem ipsum dolor",
                    ITEM_CONTENT,
                    "400.00",
                    "Assets/Items/Categoria2/Item1.jpg",
                    "1:10 Losi RTR",
                    "http://pt.wikipedia.org/wiki/Automodelos_off_road",
                    group2.ID));
            group2.Items.Add(new Item("Group-2-Item-2",
                    "Lorem ipsum dolor",
                    ITEM_CONTENT,
                    "480.00",
                    "Assets/Items/Categoria2/Item2.jpg",
                    "1:10 Losi RR",
                    "http://pt.wikipedia.org/wiki/Automodelos_off_road",
                    group2.ID));
            group2.Items.Add(new Item("Group-2-Item-3",
                    "Lorem ipsum dolor",
                    ITEM_CONTENT,
                    "400.00",
                    "Assets/Items/Categoria2/Item3.jpg",
                    "1:10 Traxxas",
                    "http://pt.wikipedia.org/wiki/Automodelos_off_road",
                    group2.ID));
            group2.Items.Add(new Item("Group-2-Item-4",
                    "Lorem ipsum dolor",
                    ITEM_CONTENT,
                    "900.00",
                    "Assets/Items/Categoria2/Item4.jpg",
                    "1:10 Losi XXXX",
                    "http://pt.wikipedia.org/wiki/Automodelos_off_road",
                    group2.ID));

            this.AllGroups.Add(group2);

            var group3 = new Categoria("Group-3",
                    "Automodelo OFF Road",
                    "Emoção fora das pistas",
                    "Group Description: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus tempor scelerisque lorem in vehicula. Aliquam tincidunt, lacus ut sagittis tristique, turpis massa volutpat augue, eu rutrum ligula ante a ante",
                    "Assets/Items/Categoria2/Item1.jpg");
            group3.Items.Add(new Item("Group-2-Item-1",
                    "Lorem ipsum dolor",
                    ITEM_CONTENT,
                    "400.00",
                    "Assets/Items/Categoria2/Item1.jpg",
                    "1:10 Losi RTR",
                    "http://pt.wikipedia.org/wiki/Automodelos_off_road",
                    group3.ID));
            group3.Items.Add(new Item("Group-2-Item-2",
                    "Lorem ipsum dolor",
                    ITEM_CONTENT,
                    "480.00",
                    "Assets/Items/Categoria2/Item2.jpg",
                    "1:10 Losi RR",
                    "http://pt.wikipedia.org/wiki/Automodelos_off_road",
                    group3.ID));
            group3.Items.Add(new Item("Group-2-Item-3",
                    "Lorem ipsum dolor",
                    ITEM_CONTENT,
                    "400.00",
                    "Assets/Items/Categoria2/Item3.jpg",
                    "1:10 Traxxas",
                    "http://pt.wikipedia.org/wiki/Automodelos_off_road",
                    group3.ID));
            group3.Items.Add(new Item("Group-2-Item-4",
                    "Lorem ipsum dolor",
                    ITEM_CONTENT,
                    "900.00",
                    "Assets/Items/Categoria2/Item4.jpg",
                    "1:10 Losi XXXX",
                    "http://pt.wikipedia.org/wiki/Automodelos_off_road",
                    group3.ID));

            this.AllGroups.Add(group3);
        }
コード例 #3
0
        /// <summary>
        /// Retorna uma coleção de categoria, com a quantidade de itens especificada.
        /// </summary>
        /// <param name="Quantidade"></param>
        /// <returns></returns>
        public ObservableCollection<Categoria> GetTopItens(int Quantidade)
        {
            var CategoriasHome = new ObservableCollection<Categoria>();

            foreach (Categoria categoria in _categorias)
            {
                var categoria_busca = new Categoria();
                categoria_busca.ID = categoria.ID;
                categoria_busca.Nome = categoria.Nome;
                categoria_busca.SubTitulo = categoria.SubTitulo;
                categoria_busca.ImageUrl = categoria.ImageUrl;
                categoria_busca.Items =  new ObservableCollection<Item>(categoria.Items.Take(Quantidade));
                categoria_busca.Descricao = categoria.Descricao;

                CategoriasHome.Add(categoria_busca);
            }

            return CategoriasHome;
        }