Exemple #1
0
        public MainViewModel(
            IAudioService audioService,
            IOptionsService optionsService,
            ICommandLineService commandLineService,
            IRecordingDestinationService destService,
            ICopyRecordingsService copyRecordingsService,
            ISnackbarService snackbarService,
            IPurgeRecordingsService purgeRecordingsService,
            ISilenceService silenceService)
        {
            if (commandLineService.NoGpu)
            {
                // disable hardware (GPU) rendering so that it's all done by the CPU...
                RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly;
            }

            // subscriptions...
            Messenger.Default.Register <NavigateMessage>(this, OnNavigate);
            Messenger.Default.Register <AlwaysOnTopChanged>(this, OnAlwaysOnTopChanged);

            _pages = new Dictionary <string, FrameworkElement>();

            _optionsService         = optionsService;
            _audioService           = audioService;
            _snackbarService        = snackbarService;
            _purgeRecordingsService = purgeRecordingsService;

            // set up pages...
            SetupPage(
                RecordingPageViewModel.PageName,
                new RecordingPage(),
                new RecordingPageViewModel(
                    audioService,
                    optionsService,
                    commandLineService,
                    destService,
                    copyRecordingsService,
                    snackbarService,
                    silenceService));

            SetupPage(
                SettingsPageViewModel.PageName,
                new SettingsPage(),
                new SettingsPageViewModel(audioService, optionsService, commandLineService));

            var state = new RecordingPageNavigationState
            {
                ShowSplash     = !optionsService.Options.StartMinimized,
                StartRecording = optionsService.Options.StartRecordingOnLaunch,
            };

            GetVersionData();

            Messenger.Default.Send(new NavigateMessage(
                                       null, RecordingPageViewModel.PageName, state));
        }
Exemple #2
0
        public RecordingPageViewModel(
            IAudioService audioService,
            IOptionsService optionsService,
            ICommandLineService commandLineService,
            IRecordingDestinationService destinationService,
            ICopyRecordingsService copyRecordingsService,
            ISnackbarService snackbarService,
            ISilenceService silenceService)
        {
            Messenger.Default.Register <BeforeShutDownMessage>(this, OnShutDown);
            Messenger.Default.Register <SessionEndingMessage>(this, OnSessionEnding);

            _commandLineService    = commandLineService;
            _copyRecordingsService = copyRecordingsService;
            _snackbarService       = snackbarService;
            _silenceService        = silenceService;

            _stopwatch = new Stopwatch();

            _audioService = audioService;
            _audioService.StartedEvent           += AudioStartedHandler;
            _audioService.StoppedEvent           += AudioStoppedHandler;
            _audioService.StopRequested          += AudioStopRequestedHandler;
            _audioService.RecordingProgressEvent += AudioProgressHandler;

            _optionsService     = optionsService;
            _destinationService = destinationService;
            _recordingStatus    = RecordingStatus.NotRecording;

            _statusStr = Properties.Resources.NOT_RECORDING;

            // bind commands...
            StartRecordingCommand       = new RelayCommand(StartRecording);
            StopRecordingCommand        = new RelayCommand(StopRecording);
            NavigateSettingsCommand     = new RelayCommand(NavigateSettings);
            ShowRecordingsCommand       = new RelayCommand(ShowRecordings);
            SaveToRemovableDriveCommand = new RelayCommand(SaveToRemovableDrives);

            Messenger.Default.Register <RemovableDriveMessage>(this, OnRemovableDriveMessage);
        }