Example #1
0
        /// <summary>
        /// Constructs the RootViewModel with the specified parameters.
        /// </summary>
        /// <param name="activationMode">How the app was launched.</param>
        /// <param name="openedFile">The file the app was opened to (or null).</param>
        /// <param name="passwordGenViewModel">The ViewModel for the password generation flyout.</param>
        /// <param name="helpViewModel">The ViewModel for the help flyout.</param>
        /// <param name="appSettingsViewModel">The ViewModel for the settings flyout.</param>
        /// <param name="clipboardViewModel">a ViewModel over a clipboard clear timer.</param>
        /// <param name="taskNotificationService">A service used to control the UI for blocking operations.</param>
        /// <param name="clipboardService">A service for accessing the clipboard.</param>
        /// <param name="settingsService">A service for accessing app settings.</param>
        /// <param name="idleTimer">A timer used for computing idle timer.</param>
        public RootViewModel(
            ActivationMode activationMode,
            ITestableFile openedFile,
            IPasswordGenViewModel passwordGenViewModel,
            IHelpViewModel helpViewModel,
            IAppSettingsViewModel appSettingsViewModel,
            IClipboardClearTimerViewModel clipboardViewModel,
            ITaskNotificationService taskNotificationService,
            ISensitiveClipboardService clipboardService,
            IAppSettingsService settingsService
            )
        {
            ActivationMode = activationMode;
            CandidateFile  = openedFile;

            PasswordGenViewModel = passwordGenViewModel ?? throw new ArgumentNullException(nameof(passwordGenViewModel));
            HelpViewModel        = helpViewModel ?? throw new ArgumentNullException(nameof(helpViewModel));
            AppSettingsViewModel = appSettingsViewModel ?? throw new ArgumentNullException(nameof(appSettingsViewModel));

            TaskNotificationService = taskNotificationService ?? throw new ArgumentNullException(nameof(taskNotificationService));

            ClipboardClearViewModel = clipboardViewModel ?? throw new ArgumentNullException(nameof(clipboardViewModel));
            this.clipboardService   = clipboardService ?? throw new ArgumentNullException(nameof(clipboardService));

            this.settingsService = settingsService;
        }
Example #2
0
        public async Task Initialize()
        {
            this.settingsService = new AppSettingsService(new InMemorySettingsProvider())
            {
                EnableClipboardTimer  = DefaultClearEnabled,
                ClearClipboardOnTimer = DefaultClearTime
            };

            this.viewModel = new SettingsBasedClipboardClearViewModel(new ThreadPoolTimerFactory(), new MockSyncContext(), this.settingsService);
            await this.viewModel.ActivateAsync();
        }
Example #3
0
        public object Convert(object value, Type targetType, object parameter, string language)
        {
            IClipboardClearTimerViewModel viewModel = value as IClipboardClearTimerViewModel;

            if (viewModel == null)
            {
                return(Visibility.Collapsed);
            }
            else
            {
                return(Visibility.Visible);
            }
        }
Example #4
0
        /// <summary>
        /// Attempts to automatically clear the clipboard after a set time period.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        private void ClipboardTimerComplete(object sender, ClipboardTimerCompleteEventArgs args)
        {
            IClipboardClearTimerViewModel vm = sender as IClipboardClearTimerViewModel;

            DebugHelper.Assert(vm != null);

            // First validate that we should still be clearing the clipboard.
            // For example, a user may have disabled the option while the timer was in-progress.
            if (args.TimerType == ClipboardOperationType.UserName && !vm.UserNameClearEnabled)
            {
                return;
            }
            else if (args.TimerType == ClipboardOperationType.Password && !vm.PasswordClearEnabled)
            {
                return;
            }

            // Attempt the clear...
            if (!this.clipboardService.TryClear())
            {
                FireClipboardClearFailed();
            }
        }