コード例 #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();
        }
コード例 #2
0
 public BeGlobalWindowViewModel(BeGlobalWindow mainWindow, BeGlobalTranslationOptions options, bool tellMeAction)
 {
     LoginViewModel    = new LoginViewModel(options);
     SettingsViewModel = new SettingsViewModel(options);
     Options           = options;
     if (options != null)
     {
         var mtModel = SettingsViewModel.TranslationOptions.FirstOrDefault(m => m.Model.Equals(options.Model));
         if (mtModel != null)
         {
             var selectedModelIndex = SettingsViewModel.TranslationOptions.IndexOf(mtModel);
             SettingsViewModel.SelectedModelOption = SettingsViewModel.TranslationOptions[selectedModelIndex];
         }
         else if (SettingsViewModel.TranslationOptions.Count.Equals(0))
         {
             var translationModel = new TranslationModel
             {
                 Model       = options.Model,
                 DisplayName = options.Model
             };
             SettingsViewModel.TranslationOptions.Add(translationModel);
             SettingsViewModel.SelectedModelOption = translationModel;
         }
     }
     _mainWindow   = mainWindow;
     _tellMeAction = tellMeAction;
     _normalizeSourceTextHelper = new NormalizeSourceTextHelper();
 }
コード例 #3
0
        public BeGlobalWindowViewModel(BeGlobalWindow mainWindow, BeGlobalTranslationOptions options,
                                       TranslationProviderCredential credentialStore, LanguagePair[] languagePairs)
        {
            LoginViewModel             = new LoginViewModel(options);
            SettingsViewModel          = new SettingsViewModel(options);
            Options                    = options;
            _mainWindow                = mainWindow;
            _languagePairs             = languagePairs;
            _normalizeSourceTextHelper = new NormalizeSourceTextHelper();

            if (credentialStore == null)
            {
                return;
            }
            if (options.UseClientAuthentication)
            {
                _mainWindow.LoginTab.ClientKeyBox.Password    = options.ClientId;
                _mainWindow.LoginTab.ClientSecretBox.Password = options.ClientSecret;
            }
            else
            {
                LoginViewModel.Email = options.ClientId;
                _mainWindow.LoginTab.PasswordBox.Password = options.ClientSecret;
            }
        }
コード例 #4
0
 public BeGlobalLanguageDirection(BeGlobalTranslationProvider beGlobalTranslationProvider, LanguagePair languageDirection)
 {
     _beGlobalTranslationProvider = beGlobalTranslationProvider;
     _languageDirection           = languageDirection;
     _options = beGlobalTranslationProvider.Options;
     _normalizeSourceTextHelper = new NormalizeSourceTextHelper();
     _preTranslateHelp          = new PreTranslateTempFile();
 }
コード例 #5
0
 public BeGlobalConnecter(string clientId, string clientSecret, bool useClientAuthentication, string model)
 {
     ClientId                = clientId;
     ClientSecret            = clientSecret;
     UseClientAuthentication = useClientAuthentication;
     _model = model;
     _normalizeTextHelper = new NormalizeSourceTextHelper();
 }
コード例 #6
0
 public BeGlobalLanguageDirection(BeGlobalTranslationProvider beGlobalTranslationProvider, LanguagePair languageDirection)
 {
     _beGlobalTranslationProvider = beGlobalTranslationProvider;
     _languageDirection           = languageDirection;
     _options = beGlobalTranslationProvider.Options;
     _normalizeSourceTextHelper = new NormalizeSourceTextHelper();
     _translationUnits          = new List <TranslationUnit>();
 }
コード例 #7
0
        public void NormalizeText(bool removeTabs, string expected, string toBeNormalized)
        {
            // Arrange
            var normalizeSourceTextHelper = new NormalizeSourceTextHelper();
            var expectedText = expected;

            // Act
            var actualText = normalizeSourceTextHelper.NormalizeText(toBeNormalized, removeTabs);

            // Assert
            Assert.Equal(expectedText, actualText);
        }
コード例 #8
0
        public BeGlobalWindowViewModel(BeGlobalWindow mainWindow, BeGlobalTranslationOptions options, LanguagePair[] languagePairs)
        {
            Options                    = options;
            _mainWindow                = mainWindow;
            _languagePairs             = languagePairs;
            _normalizeSourceTextHelper = new NormalizeSourceTextHelper();
            TranslationOptions         = new ObservableCollection <TranslationModel>();

            var beGlobalTranslator = new BeGlobalV4Translator(Options?.Model);
            var accountId          = beGlobalTranslator.GetUserInformation();

            var subscriptionInfo = beGlobalTranslator.GetLanguagePairs(accountId.ToString());

            GetEngineModels(subscriptionInfo.LanguagePairs);
            SetEngineModel();
        }
コード例 #9
0
        public bool SupportsLanguageDirection(LanguagePair languageDirection)
        {
            var normalizeSourceTextHelper = new NormalizeSourceTextHelper();
            var sourceLanguage            =
                normalizeSourceTextHelper.GetCorespondingLangCode(languageDirection.SourceCulture.ThreeLetterISOLanguageName);
            var targetLanguage =
                normalizeSourceTextHelper.GetCorespondingLangCode(languageDirection.TargetCulture.ThreeLetterISOLanguageName);

            if (Options?.SubscriptionInfo?.LanguagePairs?.Count > 0)
            {
                var languagePair =
                    Options.SubscriptionInfo.LanguagePairs.FirstOrDefault(
                        l => l.SourceLanguageId.Equals(sourceLanguage) && l.TargetLanguageId.Equals(targetLanguage));
                if (languagePair != null)
                {
                    return(true);
                }
            }
            return(false);
        }
コード例 #10
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();
                }
            }
        }
コード例 #11
0
 public BeGlobalTranslationProvider(BeGlobalTranslationOptions options)
 {
     Options = options;
     _normalizeSourceTextHelper = new NormalizeSourceTextHelper();
 }