public void CaptureScreen() { ScreenGrab screenGrab = ScreenCapture.GrabAreaOfFocus(); if (screenGrab != null) { screenGrabs.Add(screenGrab); } }
public void AnnotateScreenshot(DrawingContext context, ScreenGrab screenGrab) { Point clientPt = screenGrab.ToClientPoint(position); Color mouseAnnotationColor1 = Color.FromArgb(0xA0, 0xFF, 0x00, 0x00); SolidColorBrush annotationBrush = CachedBrushes.Get(mouseAnnotationColor1); context.DrawEllipse(annotationBrush, null, clientPt, 2.5, 2.5); context.DrawEllipse(Brushes.Black, null, clientPt, 0.7, 0.7); Color mouseAnnotationColor2 = Color.FromArgb(0x50, 0xFF, 0x00, 0x00); SolidColorBrush annotationBrush2 = CachedBrushes.Get(mouseAnnotationColor2); context.DrawEllipse(null, new Pen(annotationBrush2, 2), clientPt, 9, 9); Color mouseAnnotationColor3 = Color.FromArgb(0x30, 0xFF, 0x00, 0x00); SolidColorBrush annotationBrush3 = CachedBrushes.Get(mouseAnnotationColor3); context.DrawEllipse(null, new Pen(annotationBrush3, 1), clientPt, 16, 16); }
void AnnotateScreenshot(IScreenShotAnnotator screenShotAnnotator, ScreenGrab screenGrab) { DrawingVisual visual = new DrawingVisual(); double screenGrabWidth = screenGrab.Image.Width; double screenGrabHeight = screenGrab.Image.Height; using (DrawingContext drawingContext = visual.RenderOpen()) { drawingContext.DrawImage(screenGrab.Image, new Rect(0, 0, screenGrabWidth, screenGrabHeight)); screenShotAnnotator.AnnotateScreenshot(drawingContext, screenGrab); } RenderTargetBitmap newImage = new RenderTargetBitmap((int)screenGrabWidth, (int)screenGrabHeight, 96, 96, PixelFormats.Pbgra32); newImage.Render(visual); screenGrab.Image = newImage; GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect(); }
public void AnnotateScreenshot(DrawingContext context, ScreenGrab screenGrab) { Point start = screenGrab.ToClientPoint(StartPosition); Point end = screenGrab.ToClientPoint(EndPosition); bool mouseIsDownAtEnd = false; if (midPoints.Count > 1) { Point thisPoint = start; DateTime thisTime = Start; foreach (TimeMousePoint midPoint in midPoints) { DateTime nextTime = midPoint.Time; TimeSpan timeBetweenPoints = nextTime - thisTime; double time = timeBetweenPoints.TotalMilliseconds; Point nextPoint = screenGrab.ToClientPoint(midPoint.Point); double distance = GetDistanceBetweenPoints(thisPoint, nextPoint); if (thisPoint != nextPoint) { DrawLine(context, thisPoint, nextPoint, distance, time, midPoint.MouseIsDown); } if (mouseIsDownAtEnd != midPoint.MouseIsDown) { mouseIsDownAtEnd = midPoint.MouseIsDown; double radius; double thickness; if (mouseIsDownAtEnd) { radius = 6; thickness = 2; } else { radius = 6; thickness = 1; } Color annotationColor = GetMouseAnnotationColor(mouseIsDownAtEnd); SolidColorBrush mouseDownBrush = CachedBrushes.Get(annotationColor); Pen arrowPen = new Pen(mouseDownBrush, thickness); context.DrawEllipse(null, arrowPen, nextPoint, radius, radius); } thisPoint = nextPoint; thisTime = nextTime; } } else if (start != end) { TimeSpan timeBetweenPoints = Duration; double time = timeBetweenPoints.TotalMilliseconds; double distance = GetDistanceBetweenPoints(startPosition, endPosition); DrawLine(context, start, end, distance, time, mouseStartsDown); mouseIsDownAtEnd = mouseStartsDown; } Color lastEllipseColor = GetMouseAnnotationColor(mouseIsDownAtEnd); SolidColorBrush arrowBrush = CachedBrushes.Get(lastEllipseColor); context.DrawEllipse(arrowBrush, null, end, 4, 4); }
public void Add(ScreenGrab grab) { allGrabs.Add(grab); }
public static void TooltipLoaded(Grid parentGrid) { if (parentGrid == null) { return; } animationAdjustX = 0; animationAdjustY = 0; Image screenGrab = VisualTree.FindChild <Image>(parentGrid, "imgScreenGrab"); if (screenGrab != null) { Border border = screenGrab.Parent as Border; if (border != null) { double deltaWidth = border.ActualWidth - screenGrab.ActualWidth; if (deltaWidth > 4.0) { animationAdjustX = deltaWidth / 2 - 4.0; } double deltaHeight = border.ActualHeight - screenGrab.ActualHeight; if (deltaHeight > 4.0) { animationAdjustY = deltaHeight / 2 - 4.0; } } } mouseImage = VisualTree.FindChild <Image>(parentGrid, "imgMouse"); if (mouseImage == null) { return; } mouseBeacon = VisualTree.FindChild <Ellipse>(parentGrid, "mouseBeacon"); if (mouseBeacon == null) { return; } mouseLightRingBeacon = VisualTree.FindChild <Ellipse>(parentGrid, "mouseLightRingBeacon"); if (mouseLightRingBeacon == null) { return; } mouseGrab = null; mouseImage.Visibility = Visibility.Hidden; mouseBeacon.Visibility = Visibility.Hidden; mouseLightRingBeacon.Visibility = Visibility.Hidden; ToolTip parentToolTip = VisualTree.GetParent <ToolTip>(parentGrid); if (parentToolTip == null) { return; } lock (animatingEventLocker) { mouseMoveEvent = parentToolTip.DataContext as MouseMoveEvent; mouseDownEvent = parentToolTip.DataContext as MouseDownEvent; if ((mouseMoveEvent == null || mouseMoveEvent.MidPoints.Count <= 0) && mouseDownEvent == null) { return; } MouseEvent mouseEvent = parentToolTip.DataContext as MouseEvent; List <ScreenGrab> allGrabs = mouseEvent.ScreenGrabs.AllGrabs; if (allGrabs.Count <= 0) { return; } mouseGrab = allGrabs[0]; mouseImage.Visibility = Visibility.Visible; if (mouseDownEvent != null) { mouseLightRingBeacon.Width = 0; mouseLightRingBeacon.Height = 0; mouseLightRingBeacon.Opacity = 0; mouseBeacon.Width = 0; mouseBeacon.Height = 0; mouseBeacon.Opacity = 0; QueueMouseAppearAnimation(mouseDownEvent.Position, QueueNextMouseDownAnimation); mouseBeacon.Visibility = Visibility.Visible; mouseLightRingBeacon.Visibility = Visibility.Visible; return; } midPointIndex = -1; QueueNextMouseMoveAnimation(null, null); } }