Example #1
0
        public OptionsWindowModel(OptionsWindow window, SdlMTCloudTranslationOptions options,
                                  TranslationProviderCredential credentialStore, LanguagePair[] languagePairs, Languages.Provider.Languages languages)
        {
            _languages = languages;


            Options = options;
            LanguageMappingsViewModel = new LanguageMappingsViewModel(options, this, languagePairs, _languages);

            LoginViewModel = new LoginViewModel(options, languagePairs, LanguageMappingsViewModel, this);
            _window        = window;

            if (credentialStore == null)
            {
                return;
            }

            if (options.AuthenticationMethod.Equals("ClientLogin"))
            {
                _window.LoginTab.ClientIdBox.Password     = options.ClientId;
                _window.LoginTab.ClientSecretBox.Password = options.ClientSecret;
                LoginViewModel.SelectedOption             = LoginViewModel.AuthenticationOptions[0];
            }
            else
            {
                LoginViewModel.Email = options.ClientId;
                _window.LoginTab.UserPasswordBox.Password = options.ClientSecret;
                LoginViewModel.SelectedOption             = LoginViewModel.AuthenticationOptions[1];
            }

            var projectController = AppInitializer.GetProjectController();

            projectController.ProjectsChanged += ProjectController_ProjectsChanged;
        }
Example #2
0
        public LoginViewModel(
            SdlMTCloudTranslationOptions options,
            LanguagePair[] languagePairs,
            LanguageMappingsViewModel languageMappingsViewModel,
            OptionsWindowModel beGlobalWindowViewModel)
        {
            _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
                }
            };

            if (!string.IsNullOrEmpty(options.AuthenticationMethod))
            {
                SelectedOption = options.AuthenticationMethod.Equals("ClientLogin")
                                        ? AuthenticationOptions[0]
                                        : AuthenticationOptions[1];
            }
            else
            {
                SelectedOption = AuthenticationOptions[1];
            }

            LoginMethod = SelectedOption.Type;
        }