Exemple #1
0
        public LoginViewModel(
            BeGlobalTranslationOptions options,
            LanguagePair[] languagePairs,
            LanguageMappingsViewModel languageMappingsViewModel,
            BeGlobalWindowViewModel beGlobalWindowViewModel)
        {
            _normalizeSourceTextHelper = new NormalizeSourceTextHelper();
            _languagePairs             = languagePairs;
            LanguageMappingsViewModel  = languageMappingsViewModel;
            BeGlobalWindowViewModel    = beGlobalWindowViewModel;
            Options = options;

            AuthenticationOptions = new List <Authentication>
            {
                new Authentication
                {
                    DisplayName = Constants.ClientAuthentication,
                    Type        = Constants.Client
                },
                new Authentication
                {
                    DisplayName = Constants.UserAuthentication,
                    Type        = Constants.User
                }
            };
            SelectedOption = options.UseClientAuthentication ? AuthenticationOptions[0] : AuthenticationOptions[1];
            LoginMethod    = SelectedOption.Type;
            GetEngines();
        }
        public BeGlobalWindowViewModel(BeGlobalWindow mainWindow, BeGlobalTranslationOptions options,
                                       TranslationProviderCredential credentialStore, LanguagePair[] languagePairs)
        {
            LanguageMappingsViewModel = new LanguageMappingsViewModel(options);
            LoginViewModel            = new LoginViewModel(options, languagePairs, LanguageMappingsViewModel, this);
            Options     = options;
            _mainWindow = mainWindow;

            if (credentialStore == null)
            {
                return;
            }
            if (options.UseClientAuthentication)
            {
                _mainWindow.LoginTab.ClientIdBox.Password     = options.ClientId;
                _mainWindow.LoginTab.ClientSecretBox.Password = options.ClientSecret;
            }
            else
            {
                LoginViewModel.Email = options.ClientId;
                _mainWindow.LoginTab.UserPasswordBox.Password = options.ClientSecret;
            }
        }
Exemple #3
0
        public BeGlobalWindowViewModel(BeGlobalTranslationOptions options, LanguagePair[] languagePairs, TranslationProviderCredential credentials)
        {
            SelectedTabIndex           = 0;
            Options                    = options;
            LoginViewModel             = new LoginViewModel(options);
            LanguageMappingsViewModel  = new LanguageMappingsViewModel(options);
            _languagePairs             = languagePairs;
            _normalizeSourceTextHelper = new NormalizeSourceTextHelper();
            _credentials               = credentials;

            TranslationOptions = new ObservableCollection <TranslationModel>();
            _messageBoxService = new MessageBoxService();
            if (Options != null)
            {
                ReSendChecked = options.ResendDrafts;
            }

            if (credentials == null)
            {
                return;
            }
            var credential = _credentials.Credential.Replace("sdlmachinetranslationcloudprovider:///", string.Empty);

            if (credential.Contains("#"))
            {
                var splitedCredentials = credentials.Credential.Split('#');
                if (splitedCredentials.Length == 2 && !string.IsNullOrEmpty(splitedCredentials[0]) && !string.IsNullOrEmpty(splitedCredentials[1]))
                {
                    var beGlobalTranslator = new BeGlobalV4Translator(Options, _messageBoxService, _credentials);
                    var accountId          = beGlobalTranslator.GetUserInformation();
                    var subscriptionInfo   = beGlobalTranslator.GetLanguagePairs(accountId.ToString());
                    GetEngineModels(subscriptionInfo);
                    SetEngineModel();
                    SetAuthenticationOptions();
                }
            }
        }