소스 검색

Load data from server into views

Janco Kock 10 년 전
부모
커밋
85028d04a9
3개의 변경된 파일68개의 추가작업 그리고 29개의 파일을 삭제
  1. 26 11
      MusicPlayer/MusicPlayer/Main.cs
  2. 22 18
      MusicPlayer/MusicPlayer/MainForm.Designer.cs
  3. 20 0
      MusicPlayer/MusicPlayer/MainForm.cs

+ 26 - 11
MusicPlayer/MusicPlayer/Main.cs

@@ -31,21 +31,36 @@ namespace MusicPlayer
 
         private void Populate()
         {
-            table.Add(new Song("102", "Test Song 1", "Test Album 1", "Test Artist 1", api));
+            form.AlbumListView.Items.Add(" Alle albums");
+            foreach (Album a in this.api.GetAlbums())
+            {
+                form.AlbumListView.Items.Add(a.albumnaam);
+
+            }
+            form.ArtistListBox.Items.Add("Alle artiesten");
+            foreach (Artist a in this.api.GetArtists())
+            {
+                form.ArtistListBox.Items.Add(a.naam);
 
-            form.GenreListBox.Items.Add("Hardcore");
-            form.GenreListBox.Items.Add("Hardstyle");
-            form.GenreListBox.Items.Add("Pop");
+            }
+            
+            table.Add(new Song("102", "Test Song 1", "Test Album 1", "Test Artist 1", api));
+      
+            table.Add(new Song("104", "Test Song 2", "Test Album 2", "Test Artist 2", api));
+        }
 
-            form.ArtistListBox.Items.Add("Kygo");
-            form.ArtistListBox.Items.Add("Monstercat");
-            form.ArtistListBox.Items.Add("Mozart");
+        public void ArtistFilter(string artist)
+        {
+            System.Console.Write(artist);
+        }
 
-            form.AlbumListView.Items.Add("Album 1");
-            form.AlbumListView.Items.Add("Album 2");
-            form.AlbumListView.Items.Add("Album 3");
+        public void AlbumFilter(string album)
+        {
+            System.Console.Write(album);
 
-            table.Add(new Song("104", "Test Song 2", "Test Album 2", "Test Artist 2", api));
         }
     }
+
 }
+
+

+ 22 - 18
MusicPlayer/MusicPlayer/MainForm.Designer.cs

@@ -40,9 +40,9 @@
             this.saveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
             this.viewToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
             this.ControlsPanel = new System.Windows.Forms.Panel();
-            this.PlayButton = new System.Windows.Forms.Button();
-            this.PauseButton = new System.Windows.Forms.Button();
             this.StopButton = new System.Windows.Forms.Button();
+            this.PauseButton = new System.Windows.Forms.Button();
+            this.PlayButton = new System.Windows.Forms.Button();
             ((System.ComponentModel.ISupportInitialize)(this.SongsTableView)).BeginInit();
             this.MainPanel.SuspendLayout();
             this.MenuStrip.SuspendLayout();
@@ -69,6 +69,7 @@
             this.SongsTableView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
             this.SongsTableView.Size = new System.Drawing.Size(760, 148);
             this.SongsTableView.TabIndex = 0;
+            this.SongsTableView.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.SongsTableView_CellDoubleClick);
             this.SongsTableView.SelectionChanged += new System.EventHandler(this.SongsTableView_SelectionChanged);
             // 
             // GenreListBox
@@ -80,6 +81,7 @@
             this.GenreListBox.Size = new System.Drawing.Size(124, 134);
             this.GenreListBox.Sorted = true;
             this.GenreListBox.TabIndex = 1;
+            this.GenreListBox.SelectedIndexChanged += new System.EventHandler(this.GenreListBox_SelectedIndexChanged);
             // 
             // AlbumListView
             // 
@@ -92,6 +94,7 @@
             this.AlbumListView.Sorting = System.Windows.Forms.SortOrder.Ascending;
             this.AlbumListView.TabIndex = 2;
             this.AlbumListView.UseCompatibleStateImageBehavior = false;
+            this.AlbumListView.SelectedIndexChanged += new System.EventHandler(this.AlbumListView_SelectedIndexChanged);
             // 
             // ArtistListBox
             // 
@@ -102,6 +105,7 @@
             this.ArtistListBox.Size = new System.Drawing.Size(124, 134);
             this.ArtistListBox.Sorted = true;
             this.ArtistListBox.TabIndex = 3;
+            this.ArtistListBox.SelectedIndexChanged += new System.EventHandler(this.ArtistListBox_SelectedIndexChanged);
             // 
             // MainPanel
             // 
@@ -169,15 +173,15 @@
             this.ControlsPanel.Size = new System.Drawing.Size(784, 119);
             this.ControlsPanel.TabIndex = 4;
             // 
-            // PlayButton
+            // StopButton
             // 
-            this.PlayButton.Location = new System.Drawing.Point(12, 13);
-            this.PlayButton.Name = "PlayButton";
-            this.PlayButton.Size = new System.Drawing.Size(75, 23);
-            this.PlayButton.TabIndex = 0;
-            this.PlayButton.Text = "Play";
-            this.PlayButton.UseVisualStyleBackColor = true;
-            this.PlayButton.Click += new System.EventHandler(this.PlayButton_Click);
+            this.StopButton.Location = new System.Drawing.Point(203, 13);
+            this.StopButton.Name = "StopButton";
+            this.StopButton.Size = new System.Drawing.Size(75, 23);
+            this.StopButton.TabIndex = 2;
+            this.StopButton.Text = "Stop";
+            this.StopButton.UseVisualStyleBackColor = true;
+            this.StopButton.Click += new System.EventHandler(this.StopButton_Click);
             // 
             // PauseButton
             // 
@@ -189,15 +193,15 @@
             this.PauseButton.UseVisualStyleBackColor = true;
             this.PauseButton.Click += new System.EventHandler(this.PauseButton_Click);
             // 
-            // StopButton
+            // PlayButton
             // 
-            this.StopButton.Location = new System.Drawing.Point(203, 13);
-            this.StopButton.Name = "StopButton";
-            this.StopButton.Size = new System.Drawing.Size(75, 23);
-            this.StopButton.TabIndex = 2;
-            this.StopButton.Text = "Stop";
-            this.StopButton.UseVisualStyleBackColor = true;
-            this.StopButton.Click += new System.EventHandler(this.StopButton_Click);
+            this.PlayButton.Location = new System.Drawing.Point(12, 13);
+            this.PlayButton.Name = "PlayButton";
+            this.PlayButton.Size = new System.Drawing.Size(75, 23);
+            this.PlayButton.TabIndex = 0;
+            this.PlayButton.Text = "Play";
+            this.PlayButton.UseVisualStyleBackColor = true;
+            this.PlayButton.Click += new System.EventHandler(this.PlayButton_Click);
             // 
             // MainForm
             // 

+ 20 - 0
MusicPlayer/MusicPlayer/MainForm.cs

@@ -51,5 +51,25 @@ namespace MusicPlayer
         {
             main.audio.Stop();
         }
+        private void GenreListBox_SelectedIndexChanged(object sender, EventArgs e)
+        {
+        }
+
+        private void ArtistListBox_SelectedIndexChanged(object sender, EventArgs e)
+        {
+            if (ArtistListBox.SelectedItems.Count != 0)
+                main.ArtistFilter(ArtistListBox.SelectedItems[0].ToString());
+        }
+
+        private void AlbumListView_SelectedIndexChanged(object sender, EventArgs e)
+        {
+            if(AlbumListView.SelectedItems.Count != 0)
+                main.AlbumFilter(AlbumListView.SelectedItems[0].ToString());
+        }
+
+        private void SongsTableView_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
+        {
+            main.audio.Play(SongsTableView.CurrentRow.DataBoundItem as Song);
+        }
     }
 }