예제 #1
0
        private void OkButton_Click(object sender, RoutedEventArgs e)
        {
            if (UsersListBox.SelectedItem == null)
            {
                stateLabel.Content = "Choose user to proceed";
                return;
            }
            var u = UsersListBox.SelectedItem as User;

            base.Hide();
            var songsDispalayingWindow = new SongsDispalayingWindow(u);

            songsDispalayingWindow.ShowDialog();
            base.Close();
        }
예제 #2
0
        public async void DownloadAudio(CancellationToken cancellationToken, string path, SongsDispalayingWindow w)
        {
            using (var client = new HttpClient())
            {
                try
                {
                    var st = await client.GetAsync(Url, cancellationToken);

                    using (var stream = new FileStream(path + @"\" + Artist + " - " + Title + ".mp3",
                                                       FileMode.OpenOrCreate,
                                                       FileAccess.Write))
                        await st.Content.CopyToAsync(stream);
                    w.StateLabel.Text = path + @"\" + Artist + " - " + Title + ".mp3" + " loaded";
                }

                catch (OperationCanceledException)
                {
                    MessageBox.Show(@"Downloading cancelled");
                }
                finally
                {
                    w.CancelButton.IsEnabled = false;
                }
            }
        }