示例#1
0
 private async void Download_btn_Click(object sender, EventArgs e)
 {
     music_list.Hide();
     if (account.IsAuthorized)
     {
         try
         {
             this.Hide();
             this.title_btn_general.Text = new string(' ', 4) + download_btn.Text;
             LoadBar bar = new LoadBar(Properties.Resources.WhileDownloadingText + " \n\r        Plaese Wait...");
             bar.Font         = new Font("Segoe UI", 24f);
             bar.TextPosition = new Point(154, 460);
             bar.Show();
             Task t = new Task(() =>
             {
                 Client.DownloadAllMusic();
             });
             t.Start();
             await t;
             bar.Close();
             MusicMessageBox box = new MusicMessageBox();
             box.ShowWindow(this, MessageFlags.Success);
             box.Show();
             downloaded = true;
         }
         catch (Exception ex)
         {
             MusicMessageBox box = new MusicMessageBox();
             box.Show();
             box.ShowWindow(this, ex.Message);
         }
     }
 }
示例#2
0
 private async void login_btn_Click(object sender, EventArgs e)
 {
     music_list.Hide();
     if (!account.IsAuthorized)
     {
         BassCore.Stop();
         PlayerDefaultSet(true);
         play_btn.Image = Properties.Resources.play_gray;
         using (var stream = new FileStream(Properties.Resources.UserDataJSONPath, FileMode.Open))
         {
             using (var stream2 = new FileStream(Properties.Resources.SecretUserJSONDataPath, FileMode.Open))
             {
                 using (var reader = new StreamReader(stream))
                 {
                     UserDataJSON = reader.ReadToEnd();
                     if (string.IsNullOrEmpty(UserDataJSON))
                     {
                         var form = new Sign_in_form(this);
                         form.Show();
                         this.Hide();
                         form.BringToFront();
                     }
                     else
                     {
                         LoadBar bar = new LoadBar();
                         this.Hide();
                         bar.Show();
                         SecretUserJSON = new StreamReader(stream2).ReadToEnd();
                         Client         = new VKManager();
                         Task t = new Task(() =>
                         {
                             account = Client.AuthentificateFromFile(UserDataJSON, SecretUserJSON);
                         });
                         t.Start();
                         await t;
                         this.Show();
                         RefreshLoginPanel();
                         bar.Close();
                     }
                 }
             }
         }
     }
     if (account.IsAuthorized && closed)
     {
         login_btn.Location   = new Point(0, 0);
         userPicture.Location = new Point(5, 0);
     }
     Refresh();
 }