示例#1
0
        public virtual async Task <TimeSpan?> TryGetTimerAsync()
        {
            Rectangle dimensions = CaptureStrategy.GetDimensions(WindowHandle);

            Bitmap?timer = CaptureStrategy.Capture(WindowHandle, new Rectangle(dimensions.Width / 2 - 50, 0, 100, 50));

            if (timer == null)
            {
                return(null);
            }

            try
            {
                using (Bitmap resized = timer.GetResized(zoom: 2))
                {
                    OcrResult?result = await TryGetOcrResult(resized, Constants.Ocr.TIMER_HRS_MINS_SECONDS_SEPERATOR.ToString());

                    if (result != null)
                    {
                        return(TryParseTimeSpan(result));
                    }
                }
            }
            catch (Exception e)
            {
                Logger.LogError(e, e.Message);
            }
            finally
            {
                timer.Dispose();
            }

            return(null);
        }
示例#2
0
 public HeroesOfTheStorm(
     ILogger <HeroesOfTheStorm> logger,
     IOptions <Settings> settings,
     CancellationTokenProvider tokenProvider,
     CaptureStrategy captureStrategy) : base(tokenProvider, captureStrategy, logger, settings, Constants.HEROES_PROCESS_NAME)
 {
 }
示例#3
0
 public StubOfTheStorm(
     ILogger <HeroesOfTheStorm> logger,
     IOptions <Settings> settings,
     CancellationTokenProvider tokenProvider,
     CaptureStrategy captureStrategy,
     ReplayHelper replayHelper) : base(logger, settings, tokenProvider, captureStrategy)
 {
     this.replayHelper = replayHelper;
     this.timer        = TimeSpan.Zero;
 }
示例#4
0
 public ProcessWrapper(
     CancellationTokenProvider tokenProvider,
     CaptureStrategy captureStrategy,
     ILogger <ProcessWrapper> logger,
     IOptions <Settings> settings,
     string processName)
 {
     Logger             = logger;
     Settings           = settings.Value;
     this.tokenProvider = tokenProvider;
     CaptureStrategy    = captureStrategy;
     ProcessName        = processName;
 }