public SettingsControl()
        {
            InitializeComponent();

            _vm = (Application.Current as App).Container.GetService <SettingsControlViewModel>();

            _vm.SaveSettings = new RelayCommand(o =>
            {
                if (Settings.GetImgurClientID() != _vm.ImgurSetting)
                {
                    MessageBox.Show("Changes to the imgur client-id require a restart to take effect.", "ImageDownloader");
                }

                Settings.SetImgurClientID(_vm.ImgurSetting);
                Settings.SetFallbackHeight(_vm.FallbackImageDimensionsForNonsupportedImageTypes_Height);
                Settings.SetFallbackWidth(_vm.FallbackImageDimensionsForNonsupportedImageTypes_Width);

                var stringcollection = new StringCollection();
                stringcollection.AddRange(_vm.SupportedExtensions.ToLower().Split(','));
                Settings.SetSupportedExtensions(stringcollection);

                Settings.Save();
                _vm.LoadSettings.Execute(null);
            });

            DataContext = _vm;
        }
Ejemplo n.º 2
0
        private MainWindowViewModel ShowProviderWindow(LanguagePair[] languagePairs,
                                                       ITranslationProviderCredentialStore credentialStore, IMtTranslationOptions loadOptions, RegionsProvider regionsProvider)
        {
            SetSavedCredentialsOnUi(credentialStore, loadOptions);

            var dialogService     = new OpenFileDialogService();
            var providerControlVm = new ProviderControlViewModel(loadOptions, regionsProvider);

            var settingsControlVm = new SettingsControlViewModel(loadOptions, dialogService, false);
            var mainWindowVm      = new MainWindowViewModel(loadOptions, providerControlVm, settingsControlVm, credentialStore, languagePairs);

            var mainWindow = new MainWindow
            {
                DataContext = mainWindowVm
            };

            mainWindowVm.CloseEventRaised += () =>
            {
                UpdateProviderCredentials(credentialStore, loadOptions);

                mainWindow.Close();
            };

            mainWindow.ShowDialog();
            return(mainWindowVm);
        }
        public SettingsControl()
        {
            InitializeComponent();

            DataContext = new SettingsControlViewModel();

            ReloadSettings();
        }
Ejemplo n.º 4
0
        public SettingsControl()
        {
            InitializeComponent();

            ViewModel = new SettingsControlViewModel();
            ViewModel.SettingsControl = this;
            DataContext = ViewModel;
        }
        public SettingsControl()
        {
            InitializeComponent();

            DiscordButton.Click += Util.OpenDiscord;
            DataContext          = new SettingsControlViewModel();

            ReloadSettings();
        }
        public SettingsControl()
        {
            InitializeComponent();

            DiscordButton.Click += SupportLinks.OpenDiscord;
            FaqButton.Click     += SupportLinks.OpenFaq;
            DataContext          = new SettingsControlViewModel();

            ReloadSettings();
        }
Ejemplo n.º 7
0
        public override void Execute()
        {
            var currentProject = SdlTradosStudio.Application.GetController <ProjectsController>().CurrentProject;

            if (currentProject == null)
            {
                MessageBox.Show(@"No project is set as active");
            }
            else
            {
                var settings = currentProject.GetTranslationProviderConfiguration();
                if (!settings.Entries.Any(entry => entry.MainTranslationProvider.Uri.OriginalString.Contains("mtenhancedprovider")))
                {
                    MessageBox.Show(
                        @"MT Enhanced Provider is not set on this project\nPlease set it in project settings before using TellMe to access it");
                }
                else
                {
                    var translationProvider = settings.Entries.FirstOrDefault(entry =>
                                                                              entry.MainTranslationProvider.Uri.OriginalString.Contains("mtenhancedprovider"));

                    if (translationProvider != null)
                    {
                        var mtTranslationOptions =
                            new MtTranslationOptions(translationProvider.MainTranslationProvider.Uri);

                        var dialogService = new OpenFileDialogService();

                        var settingsControlVm = new SettingsControlViewModel(mtTranslationOptions, dialogService, true);
                        var mainWindowVm      = new MainWindowViewModel(mtTranslationOptions, settingsControlVm, true);

                        var mainWindow = new MainWindow
                        {
                            DataContext = mainWindowVm
                        };

                        mainWindowVm.CloseEventRaised += () =>
                        {
                            settings.Entries.Find(entry =>
                                                  entry.MainTranslationProvider.Uri.ToString().Contains("mtenhancedprovider"))
                            .MainTranslationProvider
                            .Uri = mtTranslationOptions.Uri;

                            currentProject.UpdateTranslationProviderConfiguration(settings);
                            mainWindow.Close();
                        };

                        mainWindow.ShowDialog();
                    }
                }
            }
        }
        public async Task EndInit()
        {
            var fetched = false;

            while (!fetched)
            {
                try
                {
                    var res = await _core.HttpClient.GetObjectAsync <GetFreePluginsResponse>("get_versions/", allowCache : false);

                    fetched = true;
                    if (res.Success)
                    {
                        _freePlugins    = res.Result.FreePlugins;
                        _nonFreePlugins = res.Result.PaidPlugins;
                        if (AllFree)
                        {
                            _freePlugins.Add("*");
                        }
                    }
                    else
                    {
                        throw new Exception(res.Error);
                    }
                }
                catch (Exception ex)
                {
                    _core.Logger.Error(this, ex.Message);
                    await Task.Delay(5000);
                }
            }

            if (_core.TryGetUiManager(out IUiManager ui))
            {
                _settingsControl = new SettingsControlViewModel(GetBillingManager());
                ui.AddSettingsControl(_settingsControl);
            }
        }