Ejemplo n.º 1
0
        private async void LoginButtonClick(object sender, RoutedEventArgs e)
        {
            var username = UserBox.Text;
            var email    = EmailBox.Text;
            var password = PasswordBox.Password;

            if (string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password))
            {
                CurtainPrompt.ShowError("Looks like you forgot to fill out everything.");
            }
            else
            {
                App.SupressBackEvent -= HardwareButtonsOnBackPressed;
                UiBlockerUtility.Block("Creating account...");

                var regResp = await App.Locator.AudioticaService.RegisterAsync(username, password, email);

                if (regResp.Success)
                {
                    emailTask.SetResult(true);
                    emailTask = null;
                }
                else
                {
                    App.SupressBackEvent += HardwareButtonsOnBackPressed;
                    CurtainPrompt.ShowError(regResp.Message ?? "Problem creating account.");
                }

                UiBlockerUtility.Unblock();
            }
        }
Ejemplo n.º 2
0
        private async void LoginButtonClick(object sender, RoutedEventArgs e)
        {
            var username = UsernameBox.Text;
            var password = PasswordBox.Password;

            if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password))
            {
                CurtainPrompt.ShowError("Looks like you forgot your email/password.");
            }
            else
            {
                App.SupressBackEvent -= HardwareButtonsOnBackPressed;
                UiBlockerUtility.Block("Signing in...");

                var regResp = await App.Locator.AudioticaService.LoginAsync(username, password);

                if (regResp.Success)
                {
                    emailTask.SetResult(true);
                    emailTask = null;
                }
                else
                {
                    App.SupressBackEvent += HardwareButtonsOnBackPressed;
                    CurtainPrompt.ShowError(regResp.Message ?? "Problem signing you in.");
                }

                UiBlockerUtility.Unblock();
            }
        }
Ejemplo n.º 3
0
        private async void Import()
        {
            using (var handle = Insights.TrackTime("Import Music"))
            {
                UiBlockerUtility.Block("Scanning...");
                var localMusic = await LocalMusicHelper.GetFilesInMusicAsync();

                handle.Data.Add("TotalCount", localMusic.Count.ToString());
                var failedCount = 0;

                App.Locator.CollectionService.Songs.SuppressEvents   = true;
                App.Locator.CollectionService.Artists.SuppressEvents = true;
                App.Locator.CollectionService.Albums.SuppressEvents  = true;

                App.Locator.SqlService.BeginTransaction();
                for (var i = 0; i < localMusic.Count; i++)
                {
                    StatusBarHelper.ShowStatus(
                        string.Format("Importing {0} of {1} items", i + 1, localMusic.Count),
                        (double)i / localMusic.Count);
                    try
                    {
                        await LocalMusicHelper.SaveTrackAsync(localMusic[i]);
                    }
                    catch
                    {
                        failedCount++;
                    }
                }

                App.Locator.SqlService.Commit();

                App.Locator.CollectionService.Songs.Reset();
                App.Locator.CollectionService.Artists.Reset();
                App.Locator.CollectionService.Albums.Reset();

                UiBlockerUtility.Unblock();

                if (failedCount > 0)
                {
                    CurtainPrompt.ShowError("Couldn't import {0} song(s).", failedCount);
                    handle.Data.Add("Failed", failedCount.ToString());
                }
            }

            await CollectionHelper.DownloadAlbumsArtworkAsync();

            await CollectionHelper.DownloadArtistsArtworkAsync();
        }
Ejemplo n.º 4
0
 private void ImportButton_Click(object sender, RoutedEventArgs e)
 {
     if (!App.Locator.CollectionService.IsLibraryLoaded)
     {
         UiBlockerUtility.Block("Loading collection...");
         App.Locator.CollectionService.LibraryLoaded += (o, args) =>
         {
             UiBlockerUtility.Unblock();
             Import();
         };
     }
     else
     {
         Import();
     }
 }
Ejemplo n.º 5
0
        private async void LoginButtonClicked()
        {
            if (IsLoggedIn)
            {
                _service.Logout();
                CurtainPrompt.Show("AuthLogoutSuccess".FromLanguageResource());
                LastFmUsername = null;
                LastFmPassword = null;
                IsLoggedIn     = false;
                Scrobble       = false;
                Insights.Track("Logged out from Last.FM");
            }
            else
            {
                if (string.IsNullOrEmpty(LastFmUsername) ||
                    string.IsNullOrEmpty(LastFmPassword))
                {
                    CurtainPrompt.ShowError("AuthLoginErrorForgot".FromLanguageResource());
                }

                else
                {
                    UiBlockerUtility.Block("GenericWait".FromLanguageResource());
                    if (await _service.AuthenticaAsync(LastFmUsername, LastFmPassword))
                    {
                        CurtainPrompt.Show("AuthLoginSuccess".FromLanguageResource());
                        IsLoggedIn = true;
                        Scrobble   = true;
                        Insights.Track("Logged in Last.FM");
                    }
                    else
                    {
                        CurtainPrompt.ShowError("AuthLoginError".FromLanguageResource());
                    }
                    UiBlockerUtility.Unblock();
                }

                // update the player also
                var msg = new ValueSet {
                    { PlayerConstants.LastFmLoginChanged, string.Empty }
                };
                BackgroundMediaPlayer.SendMessageToBackground(msg);
            }
        }
Ejemplo n.º 6
0
        public async void ContinueFileOpenPicker(FileOpenPickerContinuationEventArgs args)
        {
            var file = args.Files.FirstOrDefault();

            if (file == null)
            {
                CurtainPrompt.ShowError("No backup file picked.");
                return;
            }

            UiBlockerUtility.Block("Preparing...");
            App.Locator.AudioPlayerHelper.FullShutdown();
            App.Locator.SqlService.Dispose();
            App.Locator.BgSqlService.Dispose();

            using (var stream = await file.OpenStreamForReadAsync())
            {
                if (AutcpFormatHelper.ValidateHeader(stream))
                {
                    stream.Seek(0, SeekOrigin.Begin);
                    var restoreFile = await StorageHelper.CreateFileAsync("_current_restore.autcp");

                    using (var restoreStream = await restoreFile.OpenAsync(FileAccess.ReadAndWrite))
                    {
                        await stream.CopyToAsync(restoreStream);
                    }

                    UiBlockerUtility.Unblock();

                    await
                    MessageBox.ShowAsync(
                        "To finish applying the restore the app will close. Next time you start the app, it will finish restoring.",
                        "Application Restart Required");

                    App.Locator.AppSettingsHelper.Write("Restore", true);
                    Application.Current.Exit();
                }
                else
                {
                    CurtainPrompt.ShowError("Not a valid backup file.");
                }
            }
        }
Ejemplo n.º 7
0
        public async void ContinueFileSavePicker(FileSavePickerContinuationEventArgs args)
        {
            var file = args.File;

            if (file == null)
            {
                CurtainPrompt.ShowError("Backup cancelled.");
                return;
            }

            using (Insights.TrackTime("Create Backup"))
            {
                UiBlockerUtility.Block("Backing up (this may take a bit)...");

                App.Locator.SqlService.Dispose();
                App.Locator.BgSqlService.Dispose();

                try
                {
                    var data = await AutcpFormatHelper.CreateBackup(ApplicationData.Current.LocalFolder);

                    using (var stream = await file.OpenStreamForWriteAsync())
                    {
                        await stream.WriteAsync(data, 0, data.Length);
                    }
                }
                catch (Exception e)
                {
                    Insights.Report(e, "Where", "Creating Backup");
                    CurtainPrompt.ShowError("Problem creating backup.");
                }

                App.Locator.SqlService.Initialize();
                App.Locator.BgSqlService.Initialize();
                UiBlockerUtility.Unblock();
            }

            CurtainPrompt.Show("Backup completed.");
        }
Ejemplo n.º 8
0
        private async void ButtonClick(object sender, RoutedEventArgs e)
        {
            var card = new AudioticaStripeCard
            {
                Name   = this.CardNameBox.Text,
                Number = this.CardNumBox.Text,
                Cvc    = this.CardSecurityCode.Text
            };

            var nameEmpty   = string.IsNullOrEmpty(card.Name);
            var numberEmpty = string.IsNullOrEmpty(card.Number);
            var cvcEmpty    = string.IsNullOrEmpty(card.Cvc);
            var expEmpty    = this.ExpMonthBox.SelectedIndex == -1 || this.ExpYearBox.SelectedIndex == -1;

            if (nameEmpty && numberEmpty && cvcEmpty && expEmpty)
            {
                CurtainPrompt.ShowError("You forgot to enter all your card information.");
            }
            else if (nameEmpty)
            {
                CurtainPrompt.ShowError("You forgot to enter the name on the card.");
            }
            else if (numberEmpty)
            {
                CurtainPrompt.ShowError("You forgot to enter the card's number.");
            }
            else if (cvcEmpty)
            {
                CurtainPrompt.ShowError("You forgot to enter the card's security code.");
            }
            else if (expEmpty)
            {
                CurtainPrompt.ShowError("You forgot to enter the card's expiration date.");
            }
            else
            {
                card.ExpMonth = int.Parse(this.ExpMonthBox.SelectedItem as string);
                card.ExpYear  = int.Parse(this.ExpYearBox.SelectedItem as string);

                var term = SubcriptionTimeFrame.Month;

                switch (this.PlanBox.SelectedIndex)
                {
                case 1:
                    term = SubcriptionTimeFrame.Biyear;
                    break;

                case 2:
                    term = SubcriptionTimeFrame.Year;
                    break;
                }

                UiBlockerUtility.Block("Subscribing...");
                var result =
                    await
                    App.Locator.AudioticaService.SubscribeAsync(
                        SubscriptionType.Silver,
                        term,
                        card,
                        this.CouponCode.Text.Trim());

                UiBlockerUtility.Unblock();

                if (result.Success)
                {
                    CurtainPrompt.Show("Welcome to the Cloud Club!");
                    App.Navigator.GoBack();
                }
                else
                {
                    CurtainPrompt.ShowError(result.Message);
                }
            }
        }