Пример #1
0
        public void Clear_HistoryGetsEmptyed_CallsJobHistoryStorageSaveWithEmptyHistory_CallsHistoryChanged()
        {
            var wasCalled = false;

            _jobHistoryManager.HistoryChanged += (sender, args) => wasCalled = true;

            _jobHistoryManager.Clear();

            Assert.IsEmpty(_jobHistoryManager.History);
            _jobHistoryStorage.Received().Save(Arg.Is <IList <HistoricJob> >(x => x.Count == 0));
            Assert.IsTrue(wasCalled, "Did not call HistoryChanged");
        }
Пример #2
0
        public HomeViewModel(IInteractionInvoker interactionInvoker, IFileConversionAssistant fileConversionAssistant, ITranslationUpdater translationUpdater,
                             IPrinterHelper printerHelper, ISettingsProvider settingsProvider, IJobHistoryManager jobHistoryManager, IDispatcher dispatcher,
                             ICommandLocator commandLocator)
            : base(translationUpdater)
        {
            _interactionInvoker      = interactionInvoker;
            _fileConversionAssistant = fileConversionAssistant;
            _printerHelper           = printerHelper;
            _settingsProvider        = settingsProvider;
            _commandLocator          = commandLocator;

            JobHistory = CollectionViewSource.GetDefaultView(jobHistoryManager.History);
            jobHistoryManager.HistoryChanged += (sender, args) =>
            {
                dispatcher.BeginInvoke(JobHistory.Refresh);
                RaisePropertyChanged(nameof(NumberOfHistoricJobs));
            };
            JobHistory.MoveCurrentTo(null); //unselect first item

            ConvertFileCommand = new DelegateCommand(o => ConvertFileExecute());

            ClearHistoryCommand         = new DelegateCommand(o => jobHistoryManager.Clear());
            RefreshHistoryCommand       = new DelegateCommand(o => jobHistoryManager.Refresh());
            RemoveHistoricJobCommand    = new DelegateCommand <HistoricJob>(jobHistoryManager.Remove);
            ToggleHistoryEnabledCommand = new DelegateCommand <HistoricJob>(hj => HistoryEnabled = !HistoryEnabled);

            DeleteHistoricFilesCommand = commandLocator.CreateMacroCommand()
                                         .AddCommand <DeleteHistoricFilesCommand>()
                                         .AddCommand(RefreshHistoryCommand)
                                         .Build();

            StartQuickActionCommand = new DelegateCommand(StartQuickActionCommandExecute);

            QuickActionOpenList = new List <QuickActionListItemVo>
            {
                GetQuickActionItem <QuickActionOpenWithPdfArchitectCommand>(Translation.OpenPDFArchitect),
                GetQuickActionItem <QuickActionOpenWithDefaultCommand>(Translation.OpenDefaultProgram),
                GetQuickActionItem <QuickActionOpenExplorerLocationCommand>(Translation.OpenExplorer),
                GetQuickActionItem <QuickActionPrintWithPdfArchitectCommand>(Translation.PrintWithPDFArchitect),
                GetQuickActionItem <QuickActionOpenMailClientCommand>(Translation.OpenMailClient)
            };
        }