public MainWindow()
        {
            InitializeComponent();

            mediaPlayer = new MediaPlayer();

            musicLib = new MusicLib();

            musicLib.PrintAllTables();


            // Console.WriteLine("Total songs = " + musicDataSet.Tables["song"].Rows.Count);

            // Get a list of all song IDs
            //DataTable songs = musicDataSet.Tables["song"];
            //var ids = from row in songs.AsEnumerable()
            //          orderby row["id"]
            //          select row["id"].ToString();

            // Put the ids in an ObservableCollection, which has Add & Remove methods for use later.
            // The UI will update itself automatically if any changes are made to this collection.
            songIds = new ObservableCollection <string>(musicLib.SongIds);

            // Bind the song IDs to the combo box
            songIdComboBox.ItemsSource = songIds;

            // Select the first item
            if (songIdComboBox.Items.Count > 0)
            {
                songIdComboBox.SelectedItem = songIdComboBox.Items[0];
            }
        }
Beispiel #2
0
        public MainWindow()
        {
            InitializeComponent();


            mediaPlayer = new MediaPlayer();

            try
            {
                musicLib = new MusicLib();
            }
            catch (Exception e)
            {
                DisplayError("Error loading file: " + e.Message);
            }

            songIds = new ObservableCollection <string>(musicLib.SongIds);

            // Bind the song IDs to the combo box
            songIdComboBox.ItemsSource = songIds;

            // Select the first item
            if (songIdComboBox.Items.Count > 0)
            {
                songIdComboBox.SelectedItem = songIdComboBox.Items[0];
            }
        }
Beispiel #3
0
        public MainWindow()
        {
            InitializeComponent();

            musicLib    = new MusicLib();
            mediaPlayer = new MediaPlayer();

            // Put the ids to a ObservableCollection which has a Remove method for use later.
            // The UI will update itself automatically if any changes are made to this collection.
            ObservableCollection <string> items = new ObservableCollection <string>(musicLib.SongIds);

            // Bind the song IDs to the combo box
            songIdComboBox.ItemsSource = items;

            // Select the first item
            if (songIdComboBox.Items.Count > 0)
            {
                songIdComboBox.SelectedItem = songIdComboBox.Items[0];
                deleteButton.IsEnabled      = true;
            }
        }
        public MainWindow()
        {
            InitializeComponent();

            mediaPlayer = new MediaPlayer();
            musicLib    = new MusicLib();

            musicLib.PrintAllTables();
            songIds = new ObservableCollection <string>(musicLib.SongIds);

            Console.WriteLine("Total songs = " + songIds.Count());

            // Bind the song IDs to the combo box
            songIdComboBox.ItemsSource = songIds;

            // Select the first item
            if (songIdComboBox.Items.Count > 0)
            {
                songIdComboBox.SelectedItem = songIdComboBox.Items[0];
            }
        }
Beispiel #5
0
        public MainWindow()
        {
            InitializeComponent();

            musicLib = new MusicLib();

            mediaPlayer = new MediaPlayer();

            try
            {
                musicDataSet = new DataSet();
                musicDataSet.ReadXmlSchema("music.xsd");
                musicDataSet.ReadXml("music.xml");
            }
            catch (Exception e)
            {
                DisplayError("Error loading file: " + e.Message);
            }

            musicLib.PrintAllTables();

            Console.WriteLine("Total songs = " + musicDataSet.Tables["song"].Rows.Count);

            // Get a list of all song IDs
            DataTable songs = musicDataSet.Tables["song"];
            var       ids   = musicLib.SongIds;

            // Put the ids in an ObservableCollection, which has Add & Remove methods for use later.
            // The UI will update itself automatically if any changes are made to this collection.
            songIds = new ObservableCollection <string>(ids);

            // Bind the song IDs to the combo box
            songIdComboBox.ItemsSource = songIds;

            // Select the first item
            if (songIdComboBox.Items.Count > 0)
            {
                songIdComboBox.SelectedItem = songIdComboBox.Items[0];
            }
        }