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);
        }
        /// <summary>
        /// If the plug-in settings can be changed by the user,
        /// SDL Trados Studio will display a Settings button.
        /// By clicking this button, users raise the plug-in user interface,
        /// in which they can modify any applicable settings, in our implementation
        /// the delimiter character and the list file name.
        /// </summary>
        /// <param name="owner"></param>
        /// <param name="translationProvider"></param>
        /// <param name="languagePairs"></param>
        /// <param name="credentialStore"></param>
        /// <returns></returns>

        public bool Edit(IWin32Window owner, ITranslationProvider translationProvider, LanguagePair[] languagePairs, ITranslationProviderCredentialStore credentialStore)
        {
            var editProvider = translationProvider as MtTranslationProvider;

            if (editProvider == null)
            {
                return(false);
            }

            // Implement error display
            if (languagePairs.Length > 1)
            {
                return(false);
            }

            //get credentials
            var getCred = GetMyCredentials(credentialStore, "argostranslateprovider:///");

            if (getCred != null)
            {
                editProvider.Options.ApiKey       = getCred.Credential;
                editProvider.Options.PersistCreds = getCred.Persist;
            }

            var dialog = new MtProviderConfDialog(editProvider.Options, 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)
            {
                SetCredentials(credentialStore, dialog.Options.ApiKey, dialog.Options.PersistCreds);
                return(true);
            }

            return(false);
        }
        /// <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>

        public bool GetCredentialsFromUser(IWin32Window owner, Uri translationProviderUri, string translationProviderState, ITranslationProviderCredentialStore credentialStore)
        {
            var options = new MtTranslationOptions(translationProviderUri);
            var caption = "Credentials"; //default in case any problem retrieving localized resource below

            caption = PluginResources.PromptForCredentialsCaption;

            var dialog = new MtProviderConfDialog(options, caption, credentialStore);

            if (dialog.ShowDialog(owner) == DialogResult.OK)
            {
                SetCredentials(credentialStore, dialog.Options.ApiKey, dialog.Options.PersistCreds);
                return(true);
            }
            return(false);
        }