Beispiel #1
0
 private async void signInButton_Click(object sender, EventArgs e)
 {
     if (!authenticatable.IsAuthenticated)
     {
         var authenticatableAsync = service.AsAuthenticatableAsync();
         if (authenticatableAsync == null)
         {
             var dlg = new CredentialsForm(service);
             dlg.ShowDialog();
             servicePlugin.SettingsFile.Save();
         }
         else
         {
             await authenticatableAsync.AuthenticateAsync();
         }
         signInStatusLabel.Text = String.Format(sspSignInStatus.Get(authenticatable.IsAuthenticated),
                                                LocalisableAccountNameFormat.GetFormattedName(authenticatable.Account));
         sspSignInButton.Update(authenticatable.IsAuthenticated);
     }
     else
     {
         authenticatable.Reset();
         sspSignInStatus.Update(false);
         sspSignInButton.Update(false);
     }
 }
Beispiel #2
0
        public ServiceSettingsView(PluginInstance servicePlugin)
        {
            this.servicePlugin = servicePlugin;
            service            = servicePlugin.Service;
            authenticatable    = service.AsAuthenticatable();
            if (authenticatable == null)
            {
                throw new ArgumentException("Service instance passed must implement IAuthenticatable", nameof(service));
            }
            InitializeComponent();
            sspSignInStatus = new SplitStringParser(signInStatusLabel);
            sspSignInButton = new SplitStringParser(signInButton);
            if (authenticatable.IsAuthenticated)
            {
                signInStatusLabel.Text = String.Format(sspSignInStatus.Get(authenticatable.IsAuthenticated),
                                                       LocalisableAccountNameFormat.GetFormattedName(authenticatable.Account));
            }
            else
            {
                sspSignInStatus.Update(false);
            }
            sspSignInButton.Update(authenticatable.IsAuthenticated);
            var control = service.GetSettingsControl();

            control.Dock = DockStyle.Fill;
            servicePanel.Controls.Add(control);
        }
 private void signInButton_Click(object sender, EventArgs e)
 {
     if (!service.IsAuthenticated)
     {
         var dlg    = new CredentialsForm(service);
         var result = dlg.ShowDialog();
         if (result != DialogResult.OK)
         {
             return;
         }
         signInStatusLabel.Text = String.Format(sspSignInStatus.Get(true), dlg.Result.UserName);
         sspSignInButton.Update(true);
     }
     else
     {
         service.ClearSession();
         sspSignInStatus.Update(false);
         sspSignInButton.Update(false);
     }
 }
        public ServiceSettingsView(MusicService service)
        {
            this.service = service;
            InitializeComponent();
            sspSignInStatus = new SplitStringParser(signInStatusLabel);
            sspSignInButton = new SplitStringParser(signInButton);
            if (service.IsAuthenticated)
            {
                signInStatusLabel.Text = String.Format(sspSignInStatus.Get(service.IsAuthenticated),
                                                       service.Settings.Response.UserName);
            }
            else
            {
                sspSignInStatus.Update(false);
            }
            sspSignInButton.Update(service.IsAuthenticated);
            var control = service.GetSettingsControl();

            control.Dock = DockStyle.Fill;
            servicePanel.Controls.Add(control);
        }