예제 #1
0
        public SettingsViewModel(IAnimeService animeService, IMangaService mangaService, IRunJobs <DWOneImportJob> dwOneImportJob, IRunJobs <UpdateDbEntries> updateDbEntriesJob, IDefineCanvasRoutines <Chart> canvasRoutines)
        {
            this.animeService       = animeService;
            this.mangaService       = mangaService;
            this.dwOneImportJob     = dwOneImportJob;
            this.updateDbEntriesJob = updateDbEntriesJob;
            this.canvasRoutines     = canvasRoutines;

            LogEvent.LogLineReceived += LogLineReceivedFunc;
        }
예제 #2
0
        public MainWindowViewModel(AnimeViewModel animeViewModel, MangaViewModel mangaViewModel, SettingsViewModel settingsViewModel, IRunJobs <UpdateDbEntries> updateDbEntries)
        {
            _animeViewModel    = animeViewModel;
            _mangaViewModel    = mangaViewModel;
            _settingsViewModel = settingsViewModel;
            _updateDbEntries   = updateDbEntries;

            ViewModels = new ObservableCollection <BaseViewModel>()
            {
                _animeViewModel,
                _mangaViewModel,
                _settingsViewModel
            };
            ViewModelsView = CollectionViewSource.GetDefaultView(ViewModels);

            if (AppHelpers.CheckRootDir())
            {
                InitApp();
            }
            else
            {
                ConsentBoxVisibility = Visibility.Visible;
            }

            ToastEvent.ToastMessageRecieved += (sender, args) => {
                ToastMessage     = args.Message;
                ToastMessageType = args.MessageType;
            };

            JobEvent.JobStarted += (sender, args) => {
                IsJobRunning       = true;
                JobDescription     = args.JobDescription;
                JobProgressMaximum = args.JobLength;
            };

            JobEvent.JobProgressChanged += (sender, args) => {
                JobProgressCurrent = args.IsIncremental
                                        ? (JobProgressCurrent + args.Progress)
                                        : args.Progress;

                if (args.StageDescriptor != null)
                {
                    JobStage = args.StageDescriptor;
                }
            };

            JobEvent.JobEnded += (sender) => {
                JobProgressCurrent = 0;
                IsJobRunning       = false;
            };
        }