コード例 #1
0
ファイル: Player.cs プロジェクト: davomelkumyan40/MusicPlayer
 private void My_music_Click(object sender, EventArgs e)
 {
     random_play_btn.Enabled = true;
     left_arrow_btn.Enabled  = true;
     play_btn.Enabled        = true;
     replay_btn.Enabled      = true;
     volume_btn.Enabled      = true;
     right_arrow_btn.Enabled = true;
     music_list.Show();
     selectedMusicIndex = -1;
     selectedMusic      = null;
     if (account.IsAuthorized && downloaded)
     {
         var audioInfos = Client.AudioList.OrderBy((c) => c.Title).ToList();
         music_list.Controls.Clear();
         foreach (var music in audioInfos)
         {
             var item = new Music_Item()
             {
                 ArtistName = music.Artist,
                 Name       = music.Title + music.Artist
             };
             item.Size        = new Size(music_list.Size.Width - 26, item.Size.Height);
             item.MouseClick += Item_MouseClick;
             music_list.Controls.Add(item);
             item.Index = music_list.Controls.IndexOf(item);
         }
     }
     else if (!account.IsAuthorized)
     {
         if (Client == null)
         {
             Client = new VKManager();
         }
         music_list.Controls.Clear();
         foreach (string music in Client.FileList)
         {
             var item = new Music_Item();
             item.Name        = Path.GetFileNameWithoutExtension(music);
             item.ArtistName  = Properties.Resources.UnknownMusicArtist;
             item.Size        = new Size(music_list.Size.Width - 26, item.Size.Height);
             item.MouseClick += Item_MouseClick;
             music_list.Controls.Add(item);
             item.Index = music_list.Controls.IndexOf(item);
         }
         Client = null;
     }
     Refresh();
 }
コード例 #2
0
ファイル: Player.cs プロジェクト: davomelkumyan40/MusicPlayer
 private void Item_MouseClick(object sender, EventArgs e)
 {
     music_control_panel.Enabled = true;
     selectedMusic = ((Music_Item)sender);
     if (prevControl != ((Music_Item)sender) && prevControl != null)
     {
         selectedMusic.BackColor = Color.FromArgb(36, 0, 47);
         prevControl.BackColor   = Color.FromArgb(44, 44, 44);
     }
     else
     {
         selectedMusic.BackColor = Color.FromArgb(36, 0, 47);
     }
     prevControl        = ((Music_Item)sender);
     selectedMusicIndex = music_list.Controls.IndexOf(((Music_Item)sender));
     newPlaying         = true;
     music_list.Refresh();
 }
コード例 #3
0
ファイル: Player.cs プロジェクト: davomelkumyan40/MusicPlayer
 private void Plus_btn_Click(object sender, EventArgs e)
 {
     if (!account.IsAuthorized)
     {
         file_open.Filter = Properties.Resources.MusicFormatString;
         if (file_open.ShowDialog() == DialogResult.OK)
         {
             string fName = $"{ Properties.Resources.PublicMusicFolder}{ Path.GetFileNameWithoutExtension(file_open.FileName)}{Path.GetExtension(file_open.FileName)}";
             if (!File.Exists(fName))
             {
                 File.Copy(file_open.FileName, fName);
             }
             var item = new Music_Item();
             item.Name       = Path.GetFileNameWithoutExtension(file_open.FileName);
             item.ArtistName = Properties.Resources.UnknownMusicArtist;
             if (!closed)
             {
                 item.Size = new Size(music_list.Size.Width - 26, item.Size.Height);
             }
             else
             {
                 item.Size = new Size(music_list.Size.Width - 493, item.Size.Height);
             }
             item.MouseClick += Item_MouseClick;
             music_list.Controls.Add(item);
             item.Index = music_list.Controls.IndexOf(item);
             music_list.Controls.Add(item);
             music_list.Show();
             random_play_btn.Enabled = true;
             left_arrow_btn.Enabled  = true;
             play_btn.Enabled        = true;
             replay_btn.Enabled      = true;
             volume_btn.Enabled      = true;
             right_arrow_btn.Enabled = true;
         }
     }
     else
     {
         MusicMessageBox box = new MusicMessageBox();
         box.ShowWindow(this, Properties.Resources.NeedToLogOutMessage);
         box.Show();
     }
 }