public ITranslationProvider[] Browse(IWin32Window owner, LanguagePair[] languagePairs, ITranslationProviderCredentialStore credentialStore) { // Implement error display if (languagePairs.Length > 1) { return(null); } //construct options to send to form var loadOptions = new MtTranslationOptions(); //get saved key if there is one and put it into options //get credentials var getCred = GetMyCredentials(credentialStore, "argostranslateprovider:///"); if (getCred != null) { loadOptions.ApiKey = getCred.Credential; loadOptions.PersistCreds = getCred.Persist; } //construct form var dialog = new MtProviderConfDialog(loadOptions, credentialStore, languagePairs[0]); //we are letting user delete creds but after testing it seems that it's ok if the individual credentials are null, b/c our method will re-add them to the credstore based on the uri if (dialog.ShowDialog(owner) == DialogResult.OK) { var testProvider = new MtTranslationProvider(dialog.Options); SetCredentials(credentialStore, dialog.Options.ApiKey, dialog.Options.PersistCreds); return(new ITranslationProvider[] { testProvider }); } return(null); }
public ITranslationProvider CreateTranslationProvider(Uri translationProviderUri, string translationProviderState, ITranslationProviderCredentialStore credentialStore) { if (!SupportsTranslationProviderUri(translationProviderUri)) { throw new Exception(PluginResources.UriNotSupportedMessage); } //create options class based on URI passed to the method var loadOptions = new MtTranslationOptions(translationProviderUri); var myUri = new Uri("argostranslateprovider:///"); var creds = credentialStore.GetCredential(myUri); if (creds != null && creds.Credential != String.Empty) { loadOptions.ApiKey = creds.Credential; } var tp = new MtTranslationProvider(loadOptions); return(tp); }
/// <summary> /// Instantiates the variables and fills the list file content into /// a Dictionary collection object. /// </summary> /// <param name="provider"></param> /// <param name="languages"></param> public MtTranslationProviderLanguageDirection(MtTranslationProvider provider, LanguagePair languages) { _provider = provider; _languageDirection = languages; _options = _provider.Options; }