Example #1
0
        public void Shot(ShotCmdOptions ShotOptions)
        {
            _settings.IncludeCursor = ShotOptions.Cursor;

            // Screenshot Window with Transparency
            if (ShotOptions.Source != null && Regex.IsMatch(ShotOptions.Source, @"win:\d+"))
            {
                var ptr = int.Parse(ShotOptions.Source.Substring(4));

                try
                {
                    var bmp = _screenShotModel.ScreenShotWindow(new Window(new IntPtr(ptr)));

                    _screenShotModel.SaveScreenShot(bmp, ShotOptions.FileName).Wait();
                }
                catch
                {
                    // Suppress Errors
                }
            }
            else
            {
                HandleVideoSource(ShotOptions);

                _screenShotModel.CaptureScreenShot(ShotOptions.FileName);
            }
        }
Example #2
0
        public void Shot(ShotCmdOptions ShotOptions)
        {
            _settings.IncludeCursor = ShotOptions.Cursor;

            // Screenshot Window with Transparency
            if (Regex.IsMatch(ShotOptions.Source, @"win:\d+"))
            {
                var ptr = int.Parse(ShotOptions.Source.Substring(4));

                try
                {
                    var win = _platformServices.GetWindow(new IntPtr(ptr));
                    var bmp = _screenShotModel.ScreenShotWindow(win);

                    _screenShotModel.SaveScreenShot(bmp, ShotOptions.FileName).Wait();
                }
                catch
                {
                    // Suppress Errors
                }
            }
            else
            {
                var videoSourceKind = HandleVideoSource(ShotOptions);

                var bmp = _screenShotModel.GetScreenShot(videoSourceKind).Result;

                _screenShotModel.SaveScreenShot(bmp, ShotOptions.FileName).Wait();
            }
        }
        public ScreenShotViewModel(LanguageManager loc,
                                   Settings settings,
                                   DiskWriter diskWriter,
                                   ClipboardWriter clipboardWriter,
                                   ImageUploadWriter imgurWriter,
                                   ScreenShotModel screenShotModel,
                                   VideoSourcesViewModel videoSourcesViewModel,
                                   IPlatformServices platformServices) : base(settings, loc)
        {
            DiskWriter      = diskWriter;
            ClipboardWriter = clipboardWriter;
            ImgurWriter     = imgurWriter;

            ScreenShotCommand = videoSourcesViewModel
                                .ObserveProperty(sourcesViewModel => sourcesViewModel.SelectedVideoSourceKind)
                                .Select(videoSourceProvider => !(videoSourceProvider is NoVideoSourceProvider))
                                .ToReactiveCommand()
                                .WithSubscribe(() => screenShotModel.CaptureScreenShot());

            async Task ScreenShotWindow(IWindow window)
            {
                var img = screenShotModel.ScreenShotWindow(window);

                await screenShotModel.SaveScreenShot(img);
            }

            ScreenShotActiveCommand  = new DelegateCommand(async() => await ScreenShotWindow(platformServices.ForegroundWindow));
            ScreenShotDesktopCommand = new DelegateCommand(async() => await ScreenShotWindow(platformServices.DesktopWindow));
            ScreenshotRegionCommand  = new DelegateCommand(async() => await screenShotModel.ScreenshotRegion());
            ScreenshotWindowCommand  = new DelegateCommand(async() => await screenShotModel.ScreenshotWindow());
            ScreenshotScreenCommand  = new DelegateCommand(async() => await screenShotModel.ScreenshotScreen());
        }