예제 #1
0
 public Bot(IClicker clicker, IScreenCapture screenCapture, IList <TeraPixel> rod)
 {
     this.m_Clicker         = clicker;
     this.m_ScreenCapture   = screenCapture;
     this.m_rod             = rod;
     this.m_searchWithDelta = new SearchWithDeltaEColorCompare(this.m_rod);
 }
예제 #2
0
        private static void InitScreenCapture()
        {
            if (_screenCapture != null && !_screenCapture.IsDisposed())
            {
                // Screen capture already initialized
                return;
            }
            try
            {
                LOG.Info($"Initializing screen capture for {SettingsManager.CaptureMethod}");
                switch (SettingsManager.CaptureMethod)
                {
                case CaptureMethod.DX9:
                    _screenCapture = new DX9ScreenCapture(SettingsManager.MonitorIndex, SettingsManager.HyperionWidth, SettingsManager.HyperionHeight,
                                                          SettingsManager.CaptureInterval);
                    break;

                case CaptureMethod.DX11:
                    _screenCapture = new DX11ScreenCapture(SettingsManager.Dx11AdapterIndex, SettingsManager.Dx11MonitorIndex, SettingsManager.Dx11ImageScalingFactor,
                                                           SettingsManager.Dx11MaxFps, SettingsManager.Dx11FrameCaptureTimeout);
                    break;

                default:
                    throw new NotImplementedException($"The capture method {SettingsManager.CaptureMethod} is not supported yet");
                }
                LOG.Info("Screen capture initialized");
            }
            catch (Exception ex)
            {
                throw new Exception("Failed to initialize screen capture: " + ex.Message, ex);
            }
        }
 public ImageGrabberService(IScreenCapture imageProvider, IOptions <DisplaySpyServerOption> options, ILogger <ImageGrabberService> logger)
 {
     this.m_imageProvider = imageProvider;
     this.m_options       = options?.Value ?? new DisplaySpyServerOption();
     this.m_th            = new Thread(this.Run);
     this.m_th.Name       = this.GetType().Name;
     this.m_logger        = logger;
 }
        public static Task <Bitmap> ToBitmap(this IScreenCapture capture)
        {
            var serviceProvider = capture.ServiceProvider
                                  ?? throw new ArgumentNullException(nameof(capture.ServiceProvider), $"{nameof(capture.ServiceProvider)} is null.");
            var factory = serviceProvider.GetService <IScreenCaptureBitmapFactory>()
                          ?? throw new NotSupportedException($"{capture.GetType()} does not support {typeof(IScreenCaptureBitmapFactory)}.");

            return(factory.ToBitmap(capture));
        }
예제 #5
0
        public AmbilightScreenCapture(IScreenCapture screenCapture)
        {
            this._screenCapture = screenCapture;

            if (screenCapture is DX11ScreenCapture dx11ScreenCapture)
            {
                dx11ScreenCapture.Timeout = 100;
            }
        }
예제 #6
0
        public void Initialize()
        {
            _driver = SingletonWebDriver.GetInstance(_webDriverType, _driverServerDirectory).GetDriver();
            _screenCapture = new ScreenCapture(_pathEvidence);
            _safeExecution = new SafeExecution(_screenCapture);

            Element = new Element(_driver, _safeExecution);
            Navigation = new Navigation(_driver, _safeExecution);
        }
        private static IScreenCaptureOclImageFactory GetFactory(IScreenCapture capture)
        {
            var serviceProvider = capture.ServiceProvider
                                  ?? throw new ArgumentNullException(nameof(capture.ServiceProvider), $"{nameof(capture.ServiceProvider)} is null.");
            var factory = serviceProvider.GetService <IScreenCaptureOclImageFactory>()
                          ?? throw new NotSupportedException($"{capture.GetType()} does not support {typeof(IScreenCaptureOclImageFactory)}.");

            return(factory);
        }
    public FishingMachine(IClicker clicker, IScreenCapture screenCapture, ISearchStrategy searchStrategy, CancellationToken mToken = default)
    {
        this.m_Clicker        = clicker;
        this.m_ScreenCapture  = screenCapture;
        this.m_SearchStrategy = searchStrategy;
        this.m_token          = mToken;

        this._stateMachine = new StateMachine <State, Trigger>(State.LookingForHook);
        ConfigureStateMachine();
    }
 public ShamanObservableExceptionHandler(
     IExceptionHandlersManager exceptionHandlersManager,
     IScreenCapture screenCapture,
     IMessenger messenger,
     IMailer mailer)
 {
     _exceptionHandlersManager = exceptionHandlersManager;
     _screenCapture            = screenCapture;
     _messenger = messenger;
     _mailer    = mailer;
 }
예제 #10
0
 public async void OnSettingsChanged(object sender, PropertyChangedEventArgs e)
 {
     if (e.PropertyName == "ScreenCapMethod")
     {
         ScreenCapAdjustLayout(false);
         IScreenCapture old = ScreenCapture;
         InitScreenCapture();
         await old.StopScreenCappingAsync();
     }
     else if (e.PropertyName == "ScreenlockBright" && Properties.Settings.Default.PrefInitialDisplayLock)
     {
         ServerConnection.CurrentServer?.SendSetDisplayLock(Properties.Settings.Default.PrefInitialDisplayLock, Properties.Settings.Default.ScreenlockBright);
     }
 }
예제 #11
0
        private CaptureService(IScreenCapture screenCapture, int timerInterval)
        {
            this.screenCapture = screenCapture;

            this.screenCaptureTimer          = new Timer();
            this.screenCaptureTimer.Interval = timerInterval;
            this.screenCaptureTimer.Elapsed += (sender, e) =>
            {
                BitmapContainer bitmapContainer = null;
                lock (this.bitmapLock)
                {
                    bitmapContainer = this.CaptureBitmap();
                }

                this.NotifyScreenChanged(bitmapContainer);
            };
        }
예제 #12
0
        private void InstantiateScreenCapture()
        {
            switch (_configuration.CaptureMethod)
            {
            case CaptureMethod.DX9:
                _screenCapture = new DX9ScreenCapture(_configuration.Dx9MonitorIndex, _configuration.Dx9CaptureWidth, _configuration.Dx9CaptureHeight,
                                                      _configuration.Dx9CaptureInterval);
                break;

            case CaptureMethod.DX11:
                _screenCapture = new DX11ScreenCapture(_configuration.Dx11AdapterIndex, _configuration.Dx11MonitorIndex, _configuration.Dx11ImageScalingFactor,
                                                       _configuration.Dx11MaxFps, _configuration.Dx11FrameCaptureTimeout);
                break;

            default:
                throw new NotImplementedException($"The capture method {_configuration.CaptureMethod} is not supported yet");
            }
        }
예제 #13
0
 private void InitScreenCapture()
 {
     if (Properties.Settings.Default.ScreenCapMethod == "2")
     {
         ScreenCapture = Adb;
         adbScreenCapElement.Visibility     = Visibility.Visible;
         androidScreenCapElement.Visibility = Visibility.Collapsed;
         Log.d(TAG, "Setting ADB for screen capture");
     }
     else
     {
         ScreenCapture = ServerConnection.ScreenCapture;
         adbScreenCapElement.Visibility     = Visibility.Collapsed;
         androidScreenCapElement.Visibility = Visibility.Visible;
         Log.d(TAG, "Setting android native for screen capture");
     }
     PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("ScreenCapture"));
 }
예제 #14
0
        private static IScreenCapture GetScreenCapture()
        {
            if (_lastScreenCaptureMode == ScreenCaptureMode && _screenCapture != null)
            {
                return(_screenCapture);
            }

            DisposeScreenCapture();

            _lastScreenCaptureMode = ScreenCaptureMode;
            switch (ScreenCaptureMode)
            {
            case ScreenCaptureMode.DirectX9:
                return(_screenCapture = new DX9ScreenCapture());

            default:
                throw new InvalidEnumArgumentException();
            }
        }
예제 #15
0
        public async Task <System.Drawing.Bitmap> ToBitmap(IScreenCapture capture)
        {
            if (capture is not DxgiScreenCapture dxgiCapture)
            {
                throw new ArgumentOutOfRangeException(nameof(capture), $"Only {typeof(DxgiScreenCapture)} is supported.");
            }

            var width  = dxgiCapture.Width;
            var height = dxgiCapture.Height;

            var exporter = dxgiCapture.ServiceProvider.GetRequiredService <IDxgiScreenCaptureExporter>();

            using var texture = await exporter.MapTexture(dxgiCapture);

            // Create Drawing.Bitmap
            var bitmap     = new System.Drawing.Bitmap(width, height, PixelFormat.Format32bppArgb);
            var boundsRect = new System.Drawing.Rectangle(0, 0, width, height);

            // Copy pixels from screen capture Texture to GDI bitmap
            var mapTarget = bitmap.LockBits(boundsRect, ImageLockMode.WriteOnly, bitmap.PixelFormat);
            var sourcePtr = texture.DataPointer;
            var targetPtr = mapTarget.Scan0;

            for (var y = 0; y < height; y++)
            {
                // Copy a single line
                Utilities.CopyMemory(targetPtr, sourcePtr, width * 4);

                // Advance pointers
                sourcePtr = IntPtr.Add(sourcePtr, texture.RowPitch);
                targetPtr = IntPtr.Add(targetPtr, mapTarget.Stride);
            }

            // Release source and dest locks
            bitmap.UnlockBits(mapTarget);

            return(bitmap);
        }
예제 #16
0
        public MainWindow()
        {
            Loaded          += WinMain_Loaded;
            ServerConnection = new BbServerConnection(this);

            ScreenCapture = ServerConnection.ScreenCapture;

            InitializeComponent();
            InitScreenCapture();

            Log.StatusChanged += OnStatusChanged;
            Log.LogAdded      += OnLogAdded;
            Log.i(TAG, "Ready", true);

            AppIconManager.PropertyChanged                        += OnAppSelectionChanged;
            ServerConnection.PropertyChanged                      += OnPropertyChanged;
            ServerConnection.SoftwareUpdateRequired               += OnSoftwareUpdateNeeded;
            Properties.Settings.Default.PropertyChanged           += OnSettingsChanged;
            SharedClipboard.ClipboardChanged                      += OnClipboardChanged;
            ServerConnection.ScreenCapture.ScreenCaptureCancelled += OnScreenCaptureCancelled;

            SetActionButton(0);
        }
예제 #17
0
 public AmbilightMirrorBrush(IScreenCapture screenCapture, AmbilightSettings settings)
     : base(screenCapture, settings)
 { }
예제 #18
0
 public AmbilightExtendBrush(IScreenCapture screenCapture, AmbilightSettings settings)
     : base(screenCapture, settings)
 {
 }
        public static Task <IOclImage> CreateImage(this IScreenCapture capture, nint contextId, nint queueId, nint imageId = default, nint[] waitEventIds = default)
        {
            var factory = GetFactory(capture);

            return(factory.CreateImage(capture, contextId, queueId, imageId, waitEventIds));
        }
예제 #20
0
 public AbstractAmbilightBrush(IScreenCapture screenCapture, AmbilightSettings settings)
 {
     this.ScreenCapture = screenCapture;
     this.Settings = settings;
 }
예제 #21
0
 private ScreenSharer(IScreenCapture capture, IStreamer streamer)
 {
     _capture  = capture;
     _streamer = streamer;
 }
예제 #22
0
 public AmbilightMirrorBrush(IScreenCapture screenCapture, AmbilightSettings settings)
     : base(screenCapture, settings)
 {
 }
예제 #23
0
 public static void Initialize(IScreenCapture screenCapture, int timerInterval)
 {
     Instance = new CaptureService(screenCapture, timerInterval);
 }
예제 #24
0
 public AbstractAmbilightBrush(IScreenCapture screenCapture, AmbilightSettings settings)
 {
     this.ScreenCapture = screenCapture;
     this.Settings      = settings;
 }
예제 #25
0
 private static void DisposeScreenCapture()
 {
     _screenCapture?.Dispose();
     _screenCapture     = null;
     _lastScreenCapture = null;
 }
예제 #26
0
 public Ambilight(IScreenCapture screenCapture, AmbilightSettings settings)
 {
     this._screenCapture = screenCapture;
     this._settings      = settings;
 }
예제 #27
0
 public Ambilight(IScreenCapture screenCapture, AmbilightSettings settings)
 {
     this._screenCapture = screenCapture;
     this._settings = settings;
 }
예제 #28
0
 public AmbilightExtendBrush(IScreenCapture screenCapture, AmbilightSettings settings)
     : base(screenCapture, settings)
 { }