private void Grid1_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { isDrawing = false; // Calculate rectangle cords/size BitmapSource bSource = ScreenCapturer.CaptureRegion((int)X, (int)Y, (int)W, (int)H); if (Settings.Default.AlwaysCopyToClipboard) { Clipboard.SetImage(bSource); } if (Settings.Default.AlwaysOpenToEditor) { new EditCaptureWindow(bSource).Show(); } else { if (ScreenCapturer.Save(bSource)) { MainWindow.notification.ShowBalloonTip(this.Title, "File saved!", BalloonIcon.Info); } else { MessageBox.Show("Oups! We couldn't save this file. Please check permissions."); } } this.Close(); }
public TrendViewModel() { _settings = new MySettings() { Language = Languages.English, PortBaudRate = 9600, PortParity = System.IO.Ports.Parity.None, PortStopBits = System.IO.Ports.StopBits.One, PortDataBits = 8, PortName = "COM3", }; ReadSettings(); _dataFromFile = new SamplesCSV(); _dataFromFile.DataReceived += _data_DataReceived; _dataFromSerial = new SamplesSerial(_settings.PortBaudRate, _settings.PortParity, _settings.PortStopBits, _settings.PortDataBits, _settings.PortName); _dataFromSerial.DataReceived += _data_DataReceived; InitializeChart(); _oneSecondTimer = new DispatcherTimer(); _oneSecondTimer.Interval = TimeSpan.FromSeconds(1); _oneSecondTimer.Tick += _oneSecondTimer_Tick; _capture = new ScreenCapturer(); _export = new ExcelExporter(); }
public void HandleCapture(BitmapSource bSource) { if (Settings.Default.AlwaysCopyToClipboard) { Clipboard.SetImage(bSource); } if (Settings.Default.AlwaysOpenToEditor) { new EditCaptureWindow(bSource).Show(); this.Close(); } else { this.Show(); if (ScreenCapturer.Save(bSource)) { notification.ShowBalloonTip(this.Title, "File saved!", BalloonIcon.Info); } else { MessageBox.Show("Oups! We couldn't save this file. Please check permissions."); } } }
private void CaptureFullScreenButton_Click(object sender, RoutedEventArgs e) { this.Hide(); BitmapSource bSource = ScreenCapturer.CaptureFullScreen(); HandleCapture(bSource); }
private void Capture(Config config) { ImageCodecInfo jpgEncoder = null; ImageCodecInfo[] codecs = ImageCodecInfo.GetImageDecoders(); foreach (ImageCodecInfo codec in codecs) { if (codec.FormatID == ImageFormat.Jpeg.Guid) { jpgEncoder = codec; } } if (jpgEncoder == null) { Console.WriteLine("Can't create Jpeg encoder :("); Environment.Exit(-1); } Encoder quality = Encoder.Quality; var encoderParams = new EncoderParameters(1); encoderParams.Param[0] = new EncoderParameter(quality, config.Quality); Image img = ScreenCapturer.CaptureDesktop(); img.Save($"{config.Path}{PREFIX}{DateTime.Now:MM-dd-yyyy_HH-mm-ss}{EXTENSION}", jpgEncoder, encoderParams); }
public static void StartScreenCapturer() { ScreenCapturer.OnScreenUpdated += ScreenCapturer_OnScreenUpdated; ScreenCapturer.OnCaptureStop += ScreenCapturer_OnCaptureStop; ScreenCapturer.StartCapture(); ScreenCapturer.SkipFirstFrame = true; System.Threading.Thread.Sleep(500); }
public void ScreenShot() { var activeScreenCapture = ScreenCapturer.GetActiveScreenCapture( ScreenBoundsCalculator.GetRectangleByScreenResolution( ScreenResolution.FullHD)); Assert.NotNull(activeScreenCapture); }
public void GetSingleFrame_GetsFrameFromScreen_Screenshot() { Rectangle resolution = Screen.PrimaryScreen.Bounds; var frame = ScreenCapturer.GetSingleFrame(); Assert.AreEqual(true, frame != null); Assert.AreEqual(resolution.Height, frame.Height); Assert.AreEqual(resolution.Width, frame.Width); }
public void AfterScenario() { if (Context.HasError) { ScreenCapturer.Capture(); } Context.MobileApp.Close(); }
public FunctionCall savewindow(string arg_txt) { return(delegate() { Bitmap bmp = ScreenCapturer.CaptureForegroundWindow(); bmp.Save(arg_txt); bmp.Dispose(); return FunctionResult.Continue; }); }
public LedPositionWindow() { InitializeComponent(); im = new ImageManipulator(); frame = ScreenCapturer.GetSingleFrame(); this.Width = (int)(frame.Width * windowSizePercent / 100); this.Height = (int)(frame.Height * windowSizePercent / 100); pb_main.Image = im.ResizeImage(frame, pb_main.Width, pb_main.Height); }
public static void StopScreenCapturer() { Stopwatch stp = Stopwatch.StartNew(); while (ScreenCapturer.IsActive) { ScreenCapturer.StopCapture(); System.Threading.Thread.Sleep(50); if (stp.ElapsedMilliseconds > 500) break; } }
private void buttonCapture_Click(object sender, EventArgs e) { ScreenCapturer imageCapturer = new ScreenCapturer(); if (imageCapturer.ShowDialog() == System.Windows.Forms.DialogResult.OK) { this.chatBoxSend.InsertImage(imageCapturer.Image); this.chatBoxSend.Focus(); this.chatBoxSend.ScrollToCaret(); } }
private void SaveButton_Click(object sender, RoutedEventArgs e) { SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.FileName = $"screenshot_{DateTime.Now.ToString("yyyy_dd_MM_HH_mm_ss")}"; saveFileDialog.Filter = "Bitmap Image (.bmp)|*.bmp|JPEG Image(.jpeg)|*.jpeg|PNG Image Image (.png)|*.png"; if (saveFileDialog.ShowDialog() == true) { ScreenCapturer.Save(saveFileDialog.FileName, CapturedImage.Source as BitmapSource); } }
public override void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == REQUEST_MEDIA_PROJECTION) { if (resultCode != AppCompatActivity.RESULT_OK) { Toast.makeText(this, [email protected]_capture_permission_not_granted, Toast.LENGTH_LONG).show(); return; } screenCapturer = new ScreenCapturer(this, resultCode, data, screenCapturerListener); startScreenCapture(); } }
protected override void OnSelectedItemChanged() { base.OnSelectedItemChanged(); if (SelectedItem == null) { return; } _gameController.Init(SelectedItem.Handle); var bitmap = ScreenCapturer.MakeSnapshot(SelectedItem.Handle, true); bitmap.Save("c:\\test.bmp"); Screen = SelectedItem == null ? null : ToBitmapSource(bitmap); //using(var context=) }
public async static Task MainAsync(int role, string addr, int port) { encoderParameters = new EncoderParameters(1); encoderParameters.Param[0] = new EncoderParameter(Encoder.Quality, encodeQuality); imageCodecInfo = GetEncoder(ImageFormat.Jpeg); VideoStreamer.role = role; udpSock = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); divideRects = new Rectangle[divideWidth * divideHeight]; int blockWidth = width / divideWidth; int blockHeight = height / divideHeight; for (int x = 0; x < divideWidth; x++) { for (int y = 0; y < divideHeight; y++) { int pos = y * divideWidth + x; divideRects[pos] = new Rectangle(x * blockWidth, y * blockHeight, blockWidth, blockHeight); } } currImage = new Bitmap(width, height, System.Drawing.Imaging.PixelFormat.Format32bppRgb); currImageDraw = Graphics.FromImage(currImage); MainWindow.current.Dispatcher.Invoke(() => { writeableBitmap = new WriteableBitmap(width, height, 96, 96, PixelFormats.Bgra32, null); MainWindow.current.VideoObject.Source = writeableBitmap; }); if (role == 0) { udpSock.Bind(new IPEndPoint(IPAddress.Any, port)); Thread rcv = new Thread(new ThreadStart(receiverThreadProcessor)); rcv.IsBackground = false; rcv.Priority = ThreadPriority.Highest; rcv.Start(); } else { udpSock.Bind(new IPEndPoint(IPAddress.Any, 0)); remote = new IPEndPoint(IPAddress.Parse(addr), port); ScreenCapturer.OnScreenUpdated += CapturedEvent; ScreenCapturer.StartCapture(); } await Task.Delay(-1); }
public static void CaptureScreen() { if (Inst == null) { var mainCam = SceneDataUtilities.MainCam; if (mainCam == null) { return; } Inst = mainCam.gameObject.GetComponent <ScreenCapturer>(); if (Inst == null) { Inst = mainCam.gameObject.AddComponent <ScreenCapturer>(); } } Inst.DoCapture(null); }
/// <summary>Funcion que capturara la ventana Activa /// </summary> public void CapturarVentanaActiva() { // realizar el screenshot de todas las pantallas y unirlas en una sola imagen. try { ImagenG.BorrarDatos(); int w = 0; //Screen.PrimaryScreen.Bounds.Width; int h = Screen.PrimaryScreen.Bounds.Height; w += Screen.PrimaryScreen.Bounds.Width; ScreenCapturer sc = new ScreenCapturer(); ImagenG.img = sc.Capture(enmScreenCaptureMode.Window); this.ImagenG.imgOriginal = sc.Capture(enmScreenCaptureMode.Screen); pck.Image = ImagenG.img; // guardamos la copia origial //this.imgOriginal = (Bitmap)img.Clone(); this.ImagenG.imgOriginal = (Bitmap)ImagenG.img.Clone(); // establecemos la imagen //pck.Image = img; pck.Image = ImagenG.img; pck.Refresh(); // mostramos la ventana oculta this.Visible = true; this.WindowState = FormWindowState.Normal; this.ShowInTaskbar = true; this.Refresh(); // calculo de variables de zoom calcularZoom(); visibilidadBtMod(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
public TestManager() { _report = new ReportingTools("QA Simulator"); ExcelWriter excelWriter = new ExcelWriter(_report.getFileLocation()); DateTime start = _report.getNow(); originStart = start; List <Action> tests = new List <Action>(); tests.Add(Test_CreateNewClient); tests.Add(Test_AddNewVisitPlan); tests.Add(Test_SetProvider); tests.Add(Test_CompleteScheduledVisit); foreach (Action test in tests) { _report.createReportItem(""); start = _report.getNow(); _report.createReportItem(test.Method.Name); try { createSUT(); test(); _report.createReportItem($"{test.Method.Name}", start); } catch (Exception e) { ScreenCapturer.CaptureAndSave($@"S:\Dev_IMS\Development\Jordan\uiAutomation\systemMapping\%NOW%_{test.Method.Name}", CaptureMode.Screen); _report.createReportItem($"Test failure {test.Method.Name}", start, $"Target: {e.TargetSite} Source: {e.Source} Message: {e.Message}"); excelWriter.WriteToFile(_report.getReport()); ShutDownSystemUnderTest close = new ShutDownSystemUnderTest(_application); return; } } _report.createReportItem(""); _report.createReportItem("Test Set Complete", originStart); excelWriter.WriteToFile(_report.getReport()); }
public override void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == REQUEST_MEDIA_PROJECTION) { if (resultCode != AppCompatActivity.RESULT_OK) { Toast.makeText(this, [email protected]_capture_permission_not_granted, Toast.LENGTH_LONG).show(); return; } screenCapturer = new ScreenCapturer(this, resultCode, data, screenCapturerListener); startScreenCapture(); } }
/// <summary> /// Capture window /// The whole idea is to pick the window that we want to capture with mouse click /// First, we will use an transparent window to catch user click point /// Then we will use 'WindowFromPoint' native method to get the window handle /// </summary> private void ClickWindowToCapture() { // The target window IntPtr hWnd; // Create a dummy window to capture click point Window DummyWindow = new Window() { WindowStyle = WindowStyle.None, Topmost = true, ShowInTaskbar = false, AllowsTransparency = true, Background = Brushes.Black, Opacity = 0.1, WindowState = WindowState.Maximized, ResizeMode = ResizeMode.NoResize }; Point ClickedPoint = new Point(); // On press {ESC}: Cancel window capturing DummyWindow.KeyUp += (s, e) => { if (e.Key == Key.Escape) { DummyWindow.Close(); this.Show(); } }; // On mouse click: Get position DummyWindow.MouseDown += (s, e) => { ClickedPoint = e.GetPosition(DummyWindow); }; // After click DummyWindow.MouseUp += (s, e) => { if (ClickedPoint.X > 5 && ClickedPoint.X < (SystemParameters.PrimaryScreenWidth - 5) && ClickedPoint.Y > 5 && ClickedPoint.Y < (SystemParameters.PrimaryScreenHeight - 5)) { // We don't need it anymore DummyWindow.Close(); // Get window handle from that position hWnd = NativeMethods.WindowFromPoint(new System.Drawing.Point((int)ClickedPoint.X, (int)ClickedPoint.Y)); NativeMethods.SetForegroundWindow(hWnd); // Capture window BitmapSource bSource = ScreenCapturer.CaptureWindow(hWnd); HandleCapture(bSource); } }; notification.ShowBalloonTip(this.Title, "Click the window you want to capture", BalloonIcon.Info); this.Hide(); DummyWindow.Show(); }
public void TakeScreenshot() { ScreenCapturer.Capture(); }
private void btnScreenCapturer_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { ScreenCapturer imageCapturer = new ScreenCapturer(); imageCapturer.ShowDialog(); }
private static void SaveScreenshotToClipboard() // save screenshot to clipboard { Clipboard.SetImage(ScreenCapturer.GetActiveWindowBitmapSource()); }
private static void ScreenCapturer_OnCaptureStop(object sender, OnCaptureStopEventArgs e) { ScreenCapturer.StartCapture(); }
private void LedPositionConfig_ResizeEnd(object sender, EventArgs e) { frame = ScreenCapturer.GetSingleFrame(); pb_main.Image = im.ResizeImage(frame, pb_main.Width, pb_main.Height); }
public MainWindow() { InitializeComponent(); _screenCapturer = new ScreenCapturer(); _im = new ImageManipulator(); }