예제 #1
0
 private void ResetMagnification()
 {
     if (!Magnification.MagSetFullscreenTransform(1, 0, 0))
     {
         throw new Exception(Kernel32.GetLastError().ToString());
     }
 }
예제 #2
0
        private void SetMagnification(User32.WINDOWINFO windowInfo)
        {
            var width  = windowInfo.rcClient.GetWidth();
            var height = windowInfo.rcClient.GetHeight();

            var isHigherThanWider = desktopHeight / height <= desktopWidth / width;
            var magnification     = isHigherThanWider ?
                                    (float)desktopHeight / height :
                                    (float)desktopWidth / width;

            var xOffset = Math.Max(0, isHigherThanWider ?
                                   (int)Math.Ceiling((desktopWidth / magnification - width) / 2f) :
                                   (int)Math.Floor((desktopWidth / magnification - width) / 2f)
                                   );
            var yOffset = Math.Max(0, isHigherThanWider ?
                                   (int)Math.Floor((desktopHeight / magnification - height) / 2f) :
                                   (int)Math.Ceiling((desktopHeight / magnification - height) / 2f)
                                   );

            if (!Magnification.MagSetFullscreenTransform(magnification, windowInfo.rcClient.left - xOffset, windowInfo.rcClient.top - yOffset))
            {
                throw new Exception(Kernel32.GetLastError().ToString());
            }
        }
예제 #3
0
        /// <inheritdoc />
        public async Task Execute()
        {
            var res = Magnification.MagInitialize();

            if (!res)
            {
                Console.WriteLine("Failed to initialize magnification API");
                return;
            }

            var timeoutSet = int.TryParse(_configuration["zoomer_sleep_time"], out var sleepTime);

            var rnd = new Random();

            while (true)
            {
                Magnification.MagSetFullscreenTransform(rnd.NextFloat(1, 6), rnd.Next(10, 500), rnd.Next(10, 500));

                if (timeoutSet)
                {
                    await Task.Delay(sleepTime);
                }
            }
        }