/// <summary> /// Initializes a new instance of the <see cref="MainViewModel"/> class. /// </summary> /// public RecorderViewModel(MainViewModel main, VideoSourcePlayer2 player) { if (main == null) { throw new ArgumentNullException("main"); } if (player == null) { throw new ArgumentNullException("player"); } this.main = main; this.videoPlayer = player; this.videoPlayer.NewFrame += Player_NewFrame; this.CaptureMode = CaptureRegionOption.Primary; this.CaptureRegion = new Rectangle(0, 0, 640, 480); this.clickCapture = new CaptureClick(); this.cursorCapture = new CaptureCursor(); this.keyCapture = new CaptureKeyboard(); this.AudioCaptureDevices = new AudioViewModelCollection(RecorderViewModel.AudioDevices); // Search and mark last selected devices foreach (var dev in AudioCaptureDevices) { dev.Checked = Settings.Default.LastAudioDevices .Contains(dev.DeviceInfo.Guid.ToString()); } }
private void Cursor_Elapsed(object sender, EventArgs e) { //Get the actual position of the form. var lefttop = Dispatcher.Invoke(() => new Point((int)((Left + 9) * _dpi), (int)((Top + 34) * _dpi))); //TODO: 2 monitors. //They share the same resolution count. Position matters. //They have different DPI. //CopyFromScreen ignores DPI. So I need to adjust the position, multiplying by the DPI scalling factor: 125%, 150%. //_size matters too. //_gr.CopyFromScreen(lefttop.X, lefttop.Y, 0, 0, _size, CopyPixelOperation.CaptureBlt | CopyPixelOperation.SourceCopy); _bt = Native.Capture(_size, lefttop.X, lefttop.Y); string fileName = String.Format("{0}{1}.bmp", _pathTemp, _frameCount); ListFrames.Add(new FrameInfo(fileName, FrameRate.GetMilliseconds(_snapDelay), new CursorInfo(CaptureCursor.CaptureImageCursor(ref _posCursor), OutterGrid.PointFromScreen(_posCursor), _recordClicked, _dpi))); ThreadPool.QueueUserWorkItem(delegate { AddFrames(fileName, new Bitmap(_bt)); }); Dispatcher.Invoke(() => Title = String.Format("Screen To Gif • {0}", _frameCount)); _frameCount++; }
private async void CursorAsync_Elapsed(object sender, EventArgs e) { //Get the actual position of the form. var lefttop = Dispatcher.Invoke(() => new Point((int)((Left + Constants.LeftOffset) * _scale), (int)((Top + Constants.TopOffset) * _scale))); #region TODO: 2 monitors //They share the same resolution count. Position matters. //They have different DPI. //CopyFromScreen ignores DPI. So I need to adjust the position, multiplying by the DPI scalling factor: 125%, 150%. //_size matters too. #endregion var bt = await Task.Factory.StartNew(() => Native.Capture(_size, lefttop.X, lefttop.Y)); //var bt = await Task.Factory.StartNew(() => Native.CaptureWindow(_thisWindow, _scale)); if (bt == null || !IsLoaded) { return; } string fileName = $"{_pathTemp}{FrameCount}.png"; ListFrames.Add(new FrameInfo(fileName, FrameRate.GetMilliseconds(_snapDelay), new CursorInfo(CaptureCursor.CaptureImageCursor(ref _posCursor), OutterGrid.PointFromScreen(_posCursor), _recordClicked || Mouse.LeftButton == MouseButtonState.Pressed, _scale))); ThreadPool.QueueUserWorkItem(delegate { AddFrames(fileName, new Bitmap(bt)); }); FrameCount++; }
private void FullCursor_Elapsed(object sender, EventArgs e) { var bt = Native.Capture(new System.Drawing.Size((int)_sizeScreen.X, (int)_sizeScreen.Y), 0, 0); string fileName = String.Format("{0}{1}.bmp", _pathTemp, _frameCount); ListFrames.Add(new FrameInfo(fileName, FrameRate.GetMilliseconds(_snapDelay), new CursorInfo(CaptureCursor.CaptureImageCursor(ref _posCursor), OutterGrid.PointFromScreen(_posCursor), _recordClicked, _dpi))); ThreadPool.QueueUserWorkItem(delegate { AddFrames(fileName, new Bitmap(bt)); }); Dispatcher.Invoke(() => Title = String.Format("Screen To Gif • {0}", _frameCount)); _frameCount++; }
private async void FullCursor_Elapsed(object sender, EventArgs e) { var bt = await Task.Factory.StartNew(() => Native.Capture(new Size((int)_sizeScreen.X, (int)_sizeScreen.Y), 0, 0)); if (bt == null || !IsLoaded) { return; } string fileName = $"{_pathTemp}{FrameCount}.png"; ListFrames.Add(new FrameInfo(fileName, FrameRate.GetMilliseconds(_snapDelay), new CursorInfo(CaptureCursor.CaptureImageCursor(ref _posCursor), OutterGrid.PointFromScreen(_posCursor), _recordClicked || Mouse.LeftButton == MouseButtonState.Pressed, _scale))); ThreadPool.QueueUserWorkItem(delegate { AddFrames(fileName, new Bitmap(bt)); }); FrameCount++; }
private void Cursor_Elapsed(object sender, EventArgs e) { //Get the actual position of the form. var lefttop = Dispatcher.Invoke(() => new Point((int)((Left + Constants.LeftOffset) * _scale), (int)((Top + Constants.TopOffset) * _scale))); var bt = Native.Capture(_size, lefttop.X, lefttop.Y); if (bt == null || !IsLoaded) { return; } string fileName = $"{_pathTemp}{FrameCount}.png"; ListFrames.Add(new FrameInfo(fileName, FrameRate.GetMilliseconds(_snapDelay), new CursorInfo(CaptureCursor.CaptureImageCursor(ref _posCursor), OutterGrid.PointFromScreen(_posCursor), _recordClicked || Mouse.LeftButton == MouseButtonState.Pressed, _scale))); ThreadPool.QueueUserWorkItem(delegate { AddFrames(fileName, new Bitmap(bt)); }); FrameCount++; }
/// <summary> /// Releases unmanaged and - optionally - managed resources /// </summary> /// /// <param name="disposing"><c>true</c> to release both managed /// and unmanaged resources; <c>false</c> to release only unmanaged /// resources.</param> /// void Dispose(bool disposing) { if (disposing) { // free managed resources if (clickCapture != null) { clickCapture.Dispose(); clickCapture = null; } if (cursorCapture != null) { cursorCapture.Dispose(); cursorCapture = null; } if (keyCapture != null) { keyCapture.Dispose(); keyCapture = null; } if (audioMixer != null) { audioMixer.Dispose(); audioMixer = null; } if (videoWriter != null) { videoWriter.Dispose(); videoWriter = null; } } }