예제 #1
0
        //Shows song suggestions in the searchbox based on what has been typed.
        private void SearchBox_TextChanged(AutoSuggestBox sender, AutoSuggestBoxTextChangedEventArgs args)
        {
            if (args.Reason == AutoSuggestionBoxTextChangeReason.UserInput)
            {
                var textresults = new List <StackPanel>();

                //Get Artists
                var artistsresults = SongListStorage.SearchArtists(SearchBox.Text);
                foreach (Artist artist in artistsresults)
                {
                    StackPanel stackpanel = new StackPanel()
                    {
                        Orientation = Orientation.Horizontal
                    };
                    stackpanel.Tag = artist;

                    SymbolIcon symbol = new SymbolIcon()
                    {
                        Symbol = Symbol.Contact,
                        Margin = new Thickness()
                        {
                            Right = 5
                        }
                    };
                    stackpanel.Children.Add(symbol);

                    TextBlock textblock = new TextBlock()
                    {
                        Text = artist.name,
                    };


                    stackpanel.Children.Add(textblock);

                    textresults.Add(stackpanel);
                }

                //Get Albums
                var albumresults = SongListStorage.SearchAlbums(SearchBox.Text, SongListStorage.Albums);
                foreach (Album album in albumresults)
                {
                    StackPanel stackpanel = new StackPanel()
                    {
                        Orientation = Orientation.Horizontal
                    };
                    stackpanel.Tag = album;

                    SymbolIcon symbol = new SymbolIcon()
                    {
                        Symbol = Symbol.Rotate,
                        Margin = new Thickness()
                        {
                            Right = 5
                        }
                    };
                    stackpanel.Children.Add(symbol);

                    TextBlock textblock = new TextBlock()
                    {
                        Text = album.Name,
                    };
                    stackpanel.Children.Add(textblock);

                    /*Button playbutton = new Button()
                     * {
                     *  Content = new SymbolIcon()
                     *  {
                     *      Symbol = Symbol.Play,
                     *      Margin = new Thickness() { Right = 5 },
                     *      Tag = album
                     *  },
                     * };
                     * playbutton.Click += Playbutton_Click;
                     * stackpanel.Children.Add(playbutton);*/


                    textresults.Add(stackpanel);
                }

                //Get Songs
                var songresults = SongListStorage.SearchSongs(SearchBox.Text);
                foreach (Song song in songresults)
                {
                    StackPanel stackpanel = new StackPanel()
                    {
                        Orientation = Orientation.Horizontal
                    };
                    stackpanel.Tag = song;

                    SymbolIcon symbol = new SymbolIcon()
                    {
                        Symbol = Symbol.Audio,
                        Margin = new Thickness()
                        {
                            Right = 5
                        }
                    };
                    stackpanel.Children.Add(symbol);

                    TextBlock textblock = new TextBlock()
                    {
                        Text = song.Title,
                    };
                    stackpanel.Children.Add(textblock);

                    /*Button playbutton = new Button()
                     * {
                     *  Content = new SymbolIcon()
                     *  {
                     *      Symbol = Symbol.Play,
                     *      Margin = new Thickness() { Right = 5 },
                     *      Tag = song
                     *  },
                     * };
                     * playbutton.Click += Playbutton_Click;
                     * stackpanel.Children.Add(playbutton);*/



                    textresults.Add(stackpanel);
                }

                SearchBox.ItemsSource = textresults;
            }
        }