Exemple #1
0
        public MainViewModel()
        {
            _saveFileInfo = new FileInfo(CaptureController.SavePath);

            // Initialize file watcher.
            _fileWatcher.Path   = Path.GetDirectoryName(CaptureController.SavePath);
            _fileWatcher.Filter = Path.GetFileName(CaptureController.SavePath);

            _fileWatcher.Changed            += (s, e) => OnPropertyChanged(nameof(Size));
            _fileWatcher.EnableRaisingEvents = true;

            CaptureController.StateChanged  += (s, e) => CaptureState = e.State;
            PlaybackController.StateChanged += (s, e) => PlaybackState = e.State;

            CaptureCommand = new Command(() =>
            {
                if (CaptureState == State.Idle)
                {
                    CaptureController.Start();
                }
                else
                {
                    CaptureController.Stop();
                }
            }, () => PlaybackState == State.Idle);

            CapturePauseCommand = new Command(() =>
            {
                if (CaptureState == State.Running)
                {
                    CaptureController.Pause();
                }
                else
                {
                    CaptureController.Resume();
                }

                UpdatePage();
            }, () => CaptureState != State.Idle);

            PlaybackCommand = new Command(() =>
            {
                if (PlaybackState == State.Idle)
                {
                    PlaybackController.Start();
                }
                else
                {
                    PlaybackController.Stop();
                }

                UpdatePage();
            }, () => CaptureState == State.Idle && File.Exists(CaptureController.SavePath));

            PlaybackPauseCommand = new Command(() =>
            {
                if (PlaybackState == State.Running)
                {
                    PlaybackController.Pause();
                }
                else
                {
                    PlaybackController.Resume();
                }

                UpdatePage();
            }, () => PlaybackState != State.Idle);
        }