public ITranslationProvider[] Browse(IWin32Window owner, LanguagePair[] languagePairs, ITranslationProviderCredentialStore credentialStore)
        {
            DlgBrowse dlg = new DlgBrowse(new Settings(), credentialStore, DlgBrowse.DialogMode.Create);

            if (dlg.ShowDialog(owner) == DialogResult.OK)
            {
                Settings settings = dlg.GetSettings();
                if (settings == null)
                {
                    return(null);
                }

                var googleProvider = new GoogleTranslationProviderPlugin(settings);

                // Store API Key in main credential store
                if (!string.IsNullOrEmpty(settings.ApiKey))
                {
                    credentialStore.AddCredential(settings.CredentialsUri, new TranslationProviderCredential(settings.ApiKey, true));
                }

                return(new ITranslationProvider[] { googleProvider });
            }

            return(null);
        }
        public bool Edit(IWin32Window owner, ITranslationProvider translationProvider, LanguagePair[] languagePairs, ITranslationProviderCredentialStore credentialStore)
        {
            var googleTranslationProvider = translationProvider as GoogleTranslationProviderPlugin;

            if (googleTranslationProvider != null)
            {
                var       oldSettings = googleTranslationProvider.Settings;
                DlgBrowse dlg         = new DlgBrowse(oldSettings, credentialStore, DlgBrowse.DialogMode.Edit);

                if (dlg.ShowDialog(owner) == DialogResult.OK)
                {
                    Settings googleSettings = dlg.GetSettings();
                    if (googleSettings == null)
                    {
                        return(false);
                    }

                    googleTranslationProvider.UpdateSettings(googleSettings);

                    // Store API Key in main credential store
                    if (!string.IsNullOrEmpty(googleSettings.ApiKey))
                    {
                        credentialStore.AddCredential(googleSettings.CredentialsUri, new TranslationProviderCredential(googleSettings.ApiKey, true));
                    }

                    return(true);
                }
            }

            return(false);
        }
        public bool GetCredentialsFromUser(IWin32Window owner, Uri translationProviderUri, string translationProviderState, ITranslationProviderCredentialStore credentialStore)
        {
            var translationProviderSettings = new Settings(translationProviderUri);

            var dlg = new DlgBrowse(translationProviderSettings, credentialStore, DlgBrowse.DialogMode.Credentials);

            if (dlg.ShowDialog(owner) == DialogResult.OK)
            {
                Settings googleSettings = dlg.GetSettings();
                if (googleSettings == null)
                {
                    return(false);
                }

                if (!string.IsNullOrEmpty(googleSettings.ApiKey))
                {
                    credentialStore.AddCredential(googleSettings.CredentialsUri, new TranslationProviderCredential(googleSettings.ApiKey, true));
                    return(true);
                }
            }

            return(false);
        }