public SmtpActionViewModel(IInteractionRequest interactionRequest, ISmtpTest smtpTest, ITranslationUpdater updater, ICurrentSettingsProvider currentSettingsProvider, ICommandLocator commandLocator, TokenHelper tokenHelper) : base(updater, currentSettingsProvider) { _interactionRequest = interactionRequest; _smtpTest = smtpTest; _currentSettingsProvider = currentSettingsProvider; SetTokenViewModel(tokenHelper); if (currentSettingsProvider?.Settings != null) { _smtpAccounts = currentSettingsProvider.Settings.ApplicationSettings.Accounts.SmtpAccounts; SmtpAccountsView = new ListCollectionView(_smtpAccounts); SmtpAccountsView.SortDescriptions.Add(new SortDescription(nameof(SmtpAccount.AccountInfo), ListSortDirection.Ascending)); } AddAccountCommand = commandLocator.GetMacroCommand() .AddCommand <SmtpAccountAddCommand>() .AddCommand(new DelegateCommand(o => SelectNewAccountInView())); EditAccountCommand = commandLocator.GetMacroCommand() .AddCommand <SmtpAccountEditCommand>() .AddCommand(new DelegateCommand(o => RefreshAccountsView())); EditMailTextCommand = new DelegateCommand(EditMailTextExecute); TestSmtpCommand = new DelegateCommand(TextSmtpExecute); }
public SignUserControlViewModel(IInteractionRequest interactionRequest, IFile file, IOpenFileInteractionHelper openFileInteractionHelper, EditionHintOptionProvider editionHintOptionProvider, ITranslationUpdater translationUpdater, ISelectedProfileProvider selectedProfile, ICurrentSettingsProvider currentSettingsProvider, ICommandLocator commandLocator) : base(translationUpdater, selectedProfile) { _file = file; _openFileInteractionHelper = openFileInteractionHelper; _interactionRequest = interactionRequest; _currentSettingsProvider = currentSettingsProvider; if (editionHintOptionProvider != null) { OnlyForPlusAndBusiness = editionHintOptionProvider.ShowOnlyForPlusAndBusinessHint; } if (currentSettingsProvider?.Settings != null) { _timeServerAccounts = currentSettingsProvider.Settings.ApplicationSettings.Accounts.TimeServerAccounts; TimeServerAccountsView = new ListCollectionView(_timeServerAccounts); TimeServerAccountsView.SortDescriptions.Add(new SortDescription(nameof(TimeServerAccount.AccountInfo), ListSortDirection.Ascending)); } ChooseCertificateFileCommand = new DelegateCommand(ChooseCertificateFileExecute); SignaturePasswordCommand = new DelegateCommand(SignaturePasswordExecute); AddTimeServerAccountCommand = commandLocator.GetMacroCommand() .AddCommand <TimeServerAccountAddCommand>() .AddCommand(new DelegateCommand(o => SelectNewAccountInView())); EditTimeServerAccountCommand = commandLocator.GetMacroCommand() .AddCommand <TimeServerAccountEditCommand>() .AddCommand(new DelegateCommand(o => RefreshAccountsView())); }
public SettingControlsViewModel(ITranslationUpdater translationUpdater, ICommandLocator commandLocator) : base(translationUpdater) { SaveCommand = commandLocator.GetMacroCommand() .AddCommand <CheckProfileCommand>() .AddCommand <SaveApplicationSettingsChangesCommand>() .AddCommand <NavigateMainTabCommand>(); CancelCommand = commandLocator.GetMacroCommand() .AddCommand <CancelApplicationSettingsChangesCommand>() .AddCommand <NavigateMainTabCommand>(); }
public HttpActionViewModel(ITranslationUpdater translationUpdater, ICurrentSettingsProvider currentSettingsProvider, ICommandLocator commandLocator) : base(translationUpdater, currentSettingsProvider) { if (currentSettingsProvider?.Settings != null) { _httpAccounts = currentSettingsProvider.Settings.ApplicationSettings.Accounts.HttpAccounts; HttpAccountsView = new ListCollectionView(_httpAccounts); HttpAccountsView.SortDescriptions.Add(new SortDescription(nameof(HttpAccount.AccountInfo), ListSortDirection.Ascending)); } AddAccountCommand = commandLocator.GetMacroCommand() .AddCommand <HttpAccountAddCommand>() .AddCommand(new DelegateCommand(o => SelectNewAccountInView())); EditAccountCommand = commandLocator.GetMacroCommand() .AddCommand <HttpAccountEditCommand>() .AddCommand(new DelegateCommand(o => RefreshAccountsView())); }
public bool CanClose() { var macroCommand = _commandsLocator.GetMacroCommand() .AddCommand <SaveAndContinueEvaluationCommand>() .AddCommand <SaveApplicationSettingsChangesCommand>() .AddCommand(new DelegateCommand(OnCloseMainWindow)); if (macroCommand.CanExecute(null)) { var booleanMacroResult = macroCommand.ExecuteWithResult(null); return(booleanMacroResult?.Result ?? false); } return(true); }
public FtpActionViewModel(TokenHelper tokenHelper, ITranslationUpdater translationUpdater, ICurrentSettingsProvider currentSettingsProvider, ICommandLocator commandLocator) : base(translationUpdater, currentSettingsProvider) { if (tokenHelper != null) { _tokenReplacer = tokenHelper.TokenReplacerWithPlaceHolders; DirectoryTokenViewModel = new TokenViewModel(x => CurrentProfile.Ftp.Directory = x, () => CurrentProfile?.Ftp.Directory, _tokenReplacer.GetTokenNames(true), ReplaceTokens); } if (currentSettingsProvider?.Settings != null) { _ftpAccounts = currentSettingsProvider.Settings.ApplicationSettings.Accounts.FtpAccounts; FtpAccountsView = new ListCollectionView(_ftpAccounts); FtpAccountsView.SortDescriptions.Add(new SortDescription(nameof(FtpAccount.AccountInfo), ListSortDirection.Ascending)); } AddAccountCommand = commandLocator.GetMacroCommand() .AddCommand <FtpAccountAddCommand>() .AddCommand(new DelegateCommand(o => SelectNewAccountInView())); EditAccountCommand = commandLocator.GetMacroCommand() .AddCommand <FtpAccountEditCommand>() .AddCommand(new DelegateCommand(o => RefreshAccountsView())); }
public DropboxUserControlViewModel(TokenHelper tokenHelper, ITranslationUpdater translationUpdater, ICurrentSettingsProvider currentSettingsProvider, ICommandLocator commandLocator) : base(translationUpdater, currentSettingsProvider) { AddDropboxAccountCommand = commandLocator.GetMacroCommand() .AddCommand <DropboxAccountAddCommand>() .AddCommand(new DelegateCommand(SelectNewAccountInView)); DropboxAccounts = currentSettingsProvider?.Settings?.ApplicationSettings.Accounts.DropboxAccounts; if (tokenHelper != null) { TokenReplacer = tokenHelper.TokenReplacerWithPlaceHolders; SharedFolderTokenViewModel = new TokenViewModel(x => CurrentProfile.DropboxSettings.SharedFolder = x, () => CurrentProfile?.DropboxSettings.SharedFolder, tokenHelper.GetTokenListForDirectory(), ReplaceTokens); } }
public MainShellViewModel(DragAndDropEventHandler dragAndDrop, ITranslationUpdater translation, ApplicationNameProvider applicationName, IInteractionRequest interactionRequest, IEventAggregator aggregator, ICommandLocator commandsLocator, IDispatcher dispatcher, IRegionManager regionManager, IWelcomeSettingsHelper welcomeSettingsHelper, IGpoSettings gpoSettings, IUpdateAssistant updateAssistant, IEventAggregator eventAggregator) : base(translation) { _aggregator = aggregator; _commandsLocator = commandsLocator; ApplicationName = applicationName; InteractionRequest = interactionRequest; _dispatcher = dispatcher; _regionManager = regionManager; _welcomeSettingsHelper = welcomeSettingsHelper; ShowUpdate = updateAssistant.IsUpdateAvailable(); GpoSettings = gpoSettings; NavigateCommand = commandsLocator?.GetMacroCommand() .AddCommand <SaveAndContinueEvaluationCommand>() .AddCommand <SaveApplicationSettingsChangesCommand>() .AddCommand <NavigateMainTabCommand>(); DragEnterCommand = new DelegateCommand <DragEventArgs>(dragAndDrop.HandleDragEnter); DragDropCommand = new DelegateCommand <DragEventArgs>(dragAndDrop.HandleDropEvent); aggregator.GetEvent <NavigateToHomeEvent>().Subscribe(OnSettingsChanged); aggregator.GetEvent <NavigateMainTabEvent>().Subscribe(OnMainShellNavigated); aggregator.GetEvent <ForceMainShellNavigation>().Subscribe(OnForcedNavigation); aggregator.GetEvent <CloseMainWindowEvent>().Subscribe(OnCloseMainWindow); ShowUpdate = updateAssistant.ShowUpdate; eventAggregator.GetEvent <SetShowUpdateEvent>().Subscribe(value => { ShowUpdate = updateAssistant.ShowUpdate; }, true); }
public void SetUp() { _accounts = new Accounts(); _accounts.FtpAccounts = new ObservableCollection <FtpAccount>(); _accounts.FtpAccounts.Add(new FtpAccount()); _accounts.SmtpAccounts = new ObservableCollection <SmtpAccount>(); _accounts.SmtpAccounts.Add(new SmtpAccount()); _accounts.HttpAccounts = new ObservableCollection <HttpAccount>(); _accounts.HttpAccounts.Add(new HttpAccount()); _accounts.DropboxAccounts = new ObservableCollection <DropboxAccount>(); _accounts.DropboxAccounts.Add(new DropboxAccount()); _accounts.TimeServerAccounts = new ObservableCollection <TimeServerAccount>(); _accounts.TimeServerAccounts.Add(new TimeServerAccount()); _commandLocator = Substitute.For <ICommandLocator>(); _commandLocator.GetMacroCommand().Returns(x => new MacroCommand(_commandLocator)); _ftpAccountAddCommand = Substitute.For <ICommand>(); _commandLocator.GetCommand <FtpAccountAddCommand>().Returns(_ftpAccountAddCommand); _ftpAccountEditCommand = Substitute.For <ICommand>(); _commandLocator.GetCommand <FtpAccountEditCommand>().Returns(_ftpAccountEditCommand); _ftpAccountRemoveCommand = Substitute.For <ICommand>(); _commandLocator.GetCommand <FtpAccountRemoveCommand>().Returns(_ftpAccountRemoveCommand); _smtpAccountAddCommand = Substitute.For <ICommand>(); _commandLocator.GetCommand <SmtpAccountAddCommand>().Returns(_smtpAccountAddCommand); _smtpAccountEditCommand = Substitute.For <ICommand>(); _commandLocator.GetCommand <SmtpAccountEditCommand>().Returns(_smtpAccountEditCommand); _smtpAccountRemoveCommand = Substitute.For <ICommand>(); _commandLocator.GetCommand <SmtpAccountRemoveCommand>().Returns(_smtpAccountRemoveCommand); _httpAccountAddCommand = Substitute.For <ICommand>(); _commandLocator.GetCommand <HttpAccountAddCommand>().Returns(_httpAccountAddCommand); _httpAccountEditCommand = Substitute.For <ICommand>(); _commandLocator.GetCommand <HttpAccountEditCommand>().Returns(_httpAccountEditCommand); _httpAccountRemoveCommand = Substitute.For <ICommand>(); _commandLocator.GetCommand <HttpAccountRemoveCommand>().Returns(_httpAccountRemoveCommand); _dropboxAccountAddCommand = Substitute.For <ICommand>(); _commandLocator.GetCommand <DropboxAccountAddCommand>().Returns(_dropboxAccountAddCommand); _dropboxAccountRemoveCommand = Substitute.For <ICommand>(); _commandLocator.GetCommand <DropboxAccountRemoveCommand>().Returns(_dropboxAccountRemoveCommand); _timeServerAccountAddCommand = Substitute.For <ICommand>(); _commandLocator.GetCommand <TimeServerAccountAddCommand>().Returns(_timeServerAccountAddCommand); _timeServerAccountEditCommand = Substitute.For <ICommand>(); _commandLocator.GetCommand <TimeServerAccountEditCommand>().Returns(_timeServerAccountEditCommand); _timeServerAccountRemoveCommand = Substitute.For <ICommand>(); _commandLocator.GetCommand <TimeServerAccountRemoveCommand>().Returns(_timeServerAccountRemoveCommand); _saveApplicationSettingsChangesCommand = Substitute.For <ICommand>(); _commandLocator.GetCommand <SaveApplicationSettingsChangesCommand>().Returns(_saveApplicationSettingsChangesCommand); InitViewModel(); }
public AccountsViewModel(ICurrentSettingsProvider currentSettingsProvider, ICommandLocator commandLocator, ITranslationUpdater translationUpdater, IDispatcher dispatcher, IGpoSettings gpoSettings) : base(translationUpdater) { _currentSettingsProvider = currentSettingsProvider; _dispatcher = dispatcher; _gpoSettings = gpoSettings; ConflateAllAccounts(_currentSettingsProvider.Settings); FtpAccountAddCommand = commandLocator.GetMacroCommand() .AddCommand <FtpAccountAddCommand>() .AddCommand <SaveApplicationSettingsChangesCommand>(); FtpAccountRemoveCommand = commandLocator.GetMacroCommand() .AddCommand <FtpAccountRemoveCommand>() .AddCommand <SaveApplicationSettingsChangesCommand>(); FtpAccountEditCommand = commandLocator.GetMacroCommand() .AddCommand <FtpAccountEditCommand>() .AddCommand <SaveApplicationSettingsChangesCommand>(); SmtpAccountAddCommand = commandLocator.GetMacroCommand() .AddCommand <SmtpAccountAddCommand>() .AddCommand <SaveApplicationSettingsChangesCommand>(); SmtpAccountRemoveCommand = commandLocator.GetMacroCommand() .AddCommand <SmtpAccountRemoveCommand>() .AddCommand <SaveApplicationSettingsChangesCommand>(); SmtpAccountEditCommand = commandLocator.GetMacroCommand() .AddCommand <SmtpAccountEditCommand>() .AddCommand <SaveApplicationSettingsChangesCommand>(); HttpAccountAddCommand = commandLocator.GetMacroCommand() .AddCommand <HttpAccountAddCommand>() .AddCommand <SaveApplicationSettingsChangesCommand>(); HttpAccountRemoveCommand = commandLocator.GetMacroCommand() .AddCommand <HttpAccountRemoveCommand>() .AddCommand <SaveApplicationSettingsChangesCommand>(); HttpAccountEditCommand = commandLocator.GetMacroCommand() .AddCommand <HttpAccountEditCommand>() .AddCommand <SaveApplicationSettingsChangesCommand>(); DropboxAccountAddCommand = commandLocator.GetMacroCommand() .AddCommand <DropboxAccountAddCommand>() .AddCommand <SaveApplicationSettingsChangesCommand>(); DropboxAccountRemoveCommand = commandLocator.GetMacroCommand() .AddCommand <DropboxAccountRemoveCommand>() .AddCommand <SaveApplicationSettingsChangesCommand>(); TimeServerAccountAddCommand = commandLocator.GetMacroCommand() .AddCommand <TimeServerAccountAddCommand>() .AddCommand <SaveApplicationSettingsChangesCommand>(); TimeServerAccountRemoveCommand = commandLocator.GetMacroCommand() .AddCommand <TimeServerAccountRemoveCommand>() .AddCommand <SaveApplicationSettingsChangesCommand>(); TimeServerAccountEditCommand = commandLocator.GetMacroCommand() .AddCommand <TimeServerAccountEditCommand>() .AddCommand <SaveApplicationSettingsChangesCommand>(); if (_currentSettingsProvider != null) { _currentSettingsProvider.SelectedProfileChanged += CurrentSettingsProviderOnSelectedProfileChanged; } }