Download src/ScreenGrab/ScreenGrabber.cs from dlxjj/imradv3: direct link, hf CLI and curl.
- Browser
- Download file 1.8 kB
-
https://huggingface.co/datasets/dlxjj/imradv3/resolve/main/src/ScreenGrab/ScreenGrabber.cs
- Command line
-
hf download hf://datasets/dlxjj/imradv3/src/ScreenGrab/ScreenGrabber.cs
-
curl -L -o ScreenGrabber.cs https://huggingface.co/datasets/dlxjj/imradv3/resolve/main/src/ScreenGrab/ScreenGrabber.cs
1.8 kB
| using System.Drawing; | |
| using System.Windows; | |
| using Dapplo.Windows.User32; | |
| using ScreenGrab.Extensions; | |
| namespace ScreenGrab; | |
| //public enum OcrType | |
| //{ | |
| // WechatOCR, | |
| // ComicOCR | |
| //} | |
| public abstract class ScreenGrabber | |
| { | |
| public static bool IsCapturing { get; private set; } | |
| //public static OcrType _OcrMode { get; set; } = OcrType.WechatOCR; | |
| public static Action<Bitmap, string>? OnCaptured { get; set; } | |
| public static void Capture(bool isAuxiliary = false) | |
| { | |
| if (IsCapturing) return; | |
| IsCapturing = true; | |
| var allDisplayInfos = DisplayInfo.AllDisplayInfos; | |
| var allScreenGrab = Application.Current.Windows.OfType<ScreenGrabView>().ToList(); | |
| var numberOfScreenGrabWindowsToCreate = allDisplayInfos.Length - allScreenGrab.Count; | |
| for (var i = 0; i < numberOfScreenGrabWindowsToCreate; i++) | |
| { | |
| var view = new ScreenGrabView(OnCaptured, isAuxiliary) | |
| { | |
| OnGrabClose = () => IsCapturing = false | |
| }; | |
| allScreenGrab.Add(view); | |
| } | |
| const double sideLength = 40; | |
| foreach (var (displayInfo, screenGrab) in allDisplayInfos.Zip(allScreenGrab, | |
| (displayInfo, screenGrab) => (displayInfo, screenGrab))) | |
| { | |
| screenGrab.WindowStartupLocation = WindowStartupLocation.Manual; | |
| screenGrab.Width = sideLength; | |
| screenGrab.Height = sideLength; | |
| screenGrab.WindowState = WindowState.Normal; | |
| var screenCenterPoint = displayInfo.ScaledCenterPoint(); | |
| screenGrab.Left = screenCenterPoint.X - sideLength / 2; | |
| screenGrab.Top = screenCenterPoint.Y - sideLength / 2; | |
| screenGrab.Show(); | |
| screenGrab.Activate(); | |
| } | |
| } | |
| } |