public DisableForCredentialsOnly ( ) : void | ||
Результат | void |
/// <summary> /// This gets called when a TranslationProviderAuthenticationException is thrown /// Since SDL Studio doesn't pass the provider instance here and even if we do a workaround... /// any new options set in the form that comes up are never saved to the project XML... /// so there is no way to change any options, only to provide the credentials /// </summary> /// <param name="owner"></param> /// <param name="translationProviderUri"></param> /// <param name="translationProviderState"></param> /// <param name="credentialStore"></param> /// <returns></returns> #region "GetCredentialsFromUser" public bool GetCredentialsFromUser(IWin32Window owner, Uri translationProviderUri, string translationProviderState, ITranslationProviderCredentialStore credentialStore) { MtTranslationOptions options = new MtTranslationOptions(translationProviderUri); string caption = "Credentials"; //default in case any problem retrieving localized resource below if (options.SelectedProvider == MtTranslationOptions.ProviderType.GoogleTranslate) { caption = PluginResources.PromptForCredentialsCaption_Google; } else if (options.SelectedProvider == MtTranslationOptions.ProviderType.MicrosoftTranslator) { caption = PluginResources.PromptForCredentialsCaption_Microsoft; } MtProviderConfDialog dialog = new MtProviderConfDialog(options, caption, credentialStore); dialog.DisableForCredentialsOnly(); //only show controls for setting credentials, as that is the only thing that will end up getting saved if (dialog.ShowDialog(owner) == DialogResult.OK) { string apiKey = dialog.Options.apiKey; if (options.SelectedProvider == MtTranslationOptions.ProviderType.GoogleTranslate) { //set google credential SetGoogleCredentials(credentialStore, apiKey, dialog.Options.persistGoogleKey); } else if (options.SelectedProvider == MtTranslationOptions.ProviderType.MicrosoftTranslator) { //set mst cred GenericCredentials creds2 = new GenericCredentials(dialog.Options.ClientID, dialog.Options.ClientSecret); SetMstCredentials(credentialStore, creds2, dialog.Options.persistMicrosoftCreds); } return(true); } return(false); }
public bool GetCredentialsFromUser(IWin32Window owner, Uri translationProviderUri, string translationProviderState, ITranslationProviderCredentialStore credentialStore) { MtTranslationOptions options = new MtTranslationOptions(translationProviderUri); string caption = "Credentials"; //default in case any problem retrieving localized resource below if (options.SelectedProvider == MtTranslationOptions.ProviderType.GoogleTranslate) caption = PluginResources.PromptForCredentialsCaption_Google; else if (options.SelectedProvider == MtTranslationOptions.ProviderType.MicrosoftTranslator) caption = PluginResources.PromptForCredentialsCaption_Microsoft; MtProviderConfDialog dialog = new MtProviderConfDialog(options, caption, credentialStore); dialog.DisableForCredentialsOnly(); //only show controls for setting credentials, as that is the only thing that will end up getting saved if (dialog.ShowDialog(owner) == DialogResult.OK) { string apiKey = dialog.Options.apiKey; if (options.SelectedProvider == MtTranslationOptions.ProviderType.GoogleTranslate) { //set google credential SetGoogleCredentials(credentialStore, apiKey, dialog.Options.persistGoogleKey); } else if (options.SelectedProvider == MtTranslationOptions.ProviderType.MicrosoftTranslator) { //set mst cred GenericCredentials creds2 = new GenericCredentials(dialog.Options.ClientID, dialog.Options.ClientSecret); SetMstCredentials(credentialStore, creds2, dialog.Options.persistMicrosoftCreds); } return true; } return false; }