private void MainForm_Load(object sender, EventArgs e) { System.Drawing.Drawing2D.GraphicsPath gp = BuildTransparencyPath(RecPictureBox.Image); RecPictureBox.Region = new Region(gp); _captureClass = new CaptureClass(); string[] videoDevices = _captureClass.GetVideoDevices(); string[] audioDevices = _captureClass.GetAudioDevices(); string[] videoCompressors = _captureClass.GetVideoCompressors(); foreach (string videoDevice in videoDevices) { VideoDeviceCB.Items.Add(videoDevice); } foreach (string audioDevice in audioDevices) { AudioDeviceCB.Items.Add(audioDevice); } foreach (string videoCompressor in videoCompressors) { VideoCompressorCB.Items.Add(videoCompressor); } RecPictureBox.Visible = false; PreviewCheckBox.Enabled = false; //CaptureCheckBox.Enabled = false; SnapshotButton.Enabled = false; VideoDeviceCB.SelectedIndex = 0; AudioDeviceCB.SelectedIndex = 0; VideoCompressorCB.SelectedIndex = 0; }
private void CaptureScreen() { try { var currScr = Screen.FromPoint(new Point(Cursor.Position.X, Cursor.Position.Y)); var scr = AllScreen.First(m => m.DeviceName == currScr.DeviceName); var rightScreenInfo = new ScreenInfo(); var win = new Window1 { Topmost = true, Left = scr.WorkingArea.Left, CurrentScreen = scr, IsCaptureScreen = true, IsDrawMark = false }; win.SourceInitialized += (snd, arg) => win.WindowState = System.Windows.WindowState.Maximized; win.ShowDialog(); if (win.IsQuitByEscape) { return; } var scaleScreen = win.CurrentScreen; ////Screen1 //CaptureClass.CaptureScreentoClipboard(0, 0, 1920, 1080, 0, scr); ////Screen2 //CaptureClass.CaptureScreentoClipboard(0, 0, 1440, 900, 1920, scr); if (scaleScreen.Bounds.X == 0) { rightScreenInfo.X = scaleScreen.Bounds.X; rightScreenInfo.Y = scaleScreen.Bounds.Y; rightScreenInfo.Width = scaleScreen.Bounds.Width; rightScreenInfo.Height = scaleScreen.Bounds.Height; rightScreenInfo.StartX = 0; rightScreenInfo.StartY = 0; } else { var scrCurrent = AllScreen.First(m => m.DeviceName == scaleScreen.DeviceName); rightScreenInfo.X = 0; rightScreenInfo.Y = scrCurrent.Bounds.Y; rightScreenInfo.Width = scrCurrent.Bounds.Width; rightScreenInfo.Height = scrCurrent.Bounds.Height; rightScreenInfo.StartX = scrCurrent.Bounds.X; rightScreenInfo.StartY = 0; } var saveAsImageType = Convert.ToInt32(Registry.GetValue("HKEY_CURRENT_USER\\SOFTWARE\\NiceScreenCapturer", "SaveType", 1)); CaptureClass.CaptureScreentoClipboard(rightScreenInfo.X, rightScreenInfo.Y, rightScreenInfo.Width, rightScreenInfo.Height, rightScreenInfo.StartX, rightScreenInfo.StartY, saveAsImageType); } catch (Exception ex) { throw new ApplicationException(ex.Message); } }
private void CaptureRegion() { try { var enableDrawMark = Convert.ToInt32(Registry.GetValue("HKEY_CURRENT_USER\\SOFTWARE\\NiceScreenCapturer", "DrawMark", 0)); var currScr = Screen.FromPoint(new Point(Cursor.Position.X, Cursor.Position.Y)); var scr = AllScreen.First(m => m.DeviceName == currScr.DeviceName); var win = new Window1 { Topmost = true, Left = scr.WorkingArea.Left, CurrentScreen = scr, IsCaptureScreen = false, IsDrawMark = enableDrawMark == 1 }; win.SourceInitialized += (snd, arg) => win.WindowState = System.Windows.WindowState.Maximized; win.ShowDialog(); if (win.IsQuitByEscape) { return; } //Starting Capture var scaleScreen = win.CurrentScreen; var scaleFactor = win.ZoneFirst.ScaleFactor; var rightScreenInfo = new ScreenInfo(); var rightScreenMark = new List <ZoneInfo>(); if (scaleScreen.Bounds.X == 0) { //Get region of primary screen rightScreenInfo.X = 0; rightScreenInfo.Y = 0; rightScreenInfo.Width = (int)(win.ZoneFirst.ZoneWidth * scaleFactor); rightScreenInfo.Height = (int)(win.ZoneFirst.ZoneHeight * scaleFactor); rightScreenInfo.StartX = (int)((win.ZoneFirst.ZoneX - 6.4) * scaleFactor); rightScreenInfo.StartY = (int)((win.ZoneFirst.ZoneY - 6.4) * scaleFactor); } else { //Get region of another screen var scrCurrent = AllScreen.First(m => m.DeviceName == scaleScreen.DeviceName); rightScreenInfo.X = 0; rightScreenInfo.Y = 0; rightScreenInfo.Width = (int)(win.ZoneFirst.ZoneWidth * scaleFactor); rightScreenInfo.Height = (int)(win.ZoneFirst.ZoneHeight * scaleFactor); rightScreenInfo.StartX = (int)((win.ZoneFirst.ZoneX - 6.4) * scaleFactor + scrCurrent.Bounds.X); rightScreenInfo.StartY = (int)((win.ZoneFirst.ZoneY - 6.4) * scaleFactor); } if (win.ZoneMark != null && win.ZoneMark.Count > 0) { //Get region of mark rectangle foreach (var zoneInfo in win.ZoneMark) { var rightScreenMarkItem = new ZoneInfo { ZoneX = (double)(zoneInfo.ZoneX - win.ZoneFirst.ZoneX) * scaleFactor, ZoneY = (double)(zoneInfo.ZoneY - win.ZoneFirst.ZoneY) * scaleFactor, ZoneWidth = zoneInfo.ZoneWidth * scaleFactor, ZoneHeight = zoneInfo.ZoneHeight * scaleFactor, BorderColor = zoneInfo.BorderColor, Thinkness = zoneInfo.Thinkness }; rightScreenMark.Add(rightScreenMarkItem); } } win.ZoneFirst = null; win.ZoneMark = null; var saveAsImageType = Convert.ToInt32(Registry.GetValue("HKEY_CURRENT_USER\\SOFTWARE\\NiceScreenCapturer", "SaveType", 1)); CaptureClass.CaptureScreenWithMarktoClipboard(rightScreenInfo.X, rightScreenInfo.Y, rightScreenInfo.Width, rightScreenInfo.Height, rightScreenInfo.StartX, rightScreenInfo.StartY, rightScreenMark, saveAsImageType); //clear memory rightScreenInfo = null; rightScreenMark = null; } catch (Exception ex) { throw new ApplicationException(ex.Message); } }