Esempio n. 1
0
 private void ResetMagnification()
 {
     if (!Magnification.MagSetFullscreenTransform(1, 0, 0))
     {
         throw new Exception(Kernel32.GetLastError().ToString());
     }
 }
Esempio n. 2
0
 private static void InitializeMagnification()
 {
     if (!Magnification.MagInitialize())
     {
         throw new Exception(Kernel32.GetLastError().ToString());
     }
 }
Esempio n. 3
0
    void ControllMagnification()
    {
        if (isZoom)
        {
            if (Input.GetAxis("Mouse ScrollWheel") > 0)
            {
                stateMagnification++;
                if (stateMagnification > Magnification.eight)
                {
                    stateMagnification = Magnification.one;
                }
                switch (stateMagnification)
                {
                case Magnification.one:
                    magnificationCam.GetComponent <Camera>().fieldOfView = 30;
                    break;

                case Magnification.two:
                    magnificationCam.GetComponent <Camera>().fieldOfView = 15;
                    break;

                case Magnification.four:
                    magnificationCam.GetComponent <Camera>().fieldOfView = 8;
                    break;

                case Magnification.eight:
                    magnificationCam.GetComponent <Camera>().fieldOfView = 4;
                    break;
                }
            }
            else if (Input.GetAxis("Mouse ScrollWheel") < 0)
            {
                stateMagnification--;
                if (stateMagnification < Magnification.one)
                {
                    stateMagnification = Magnification.eight;
                }
                switch (stateMagnification)
                {
                case Magnification.one:
                    magnificationCam.GetComponent <Camera>().fieldOfView = 30;
                    break;

                case Magnification.two:
                    magnificationCam.GetComponent <Camera>().fieldOfView = 15;
                    break;

                case Magnification.four:
                    magnificationCam.GetComponent <Camera>().fieldOfView = 8;
                    break;

                case Magnification.eight:
                    magnificationCam.GetComponent <Camera>().fieldOfView = 4;
                    break;
                }
            }
        }
    }
Esempio n. 4
0
 void Start()
 {
     initMainCamPosition = mainCam.transform.localPosition;
     enableBinoculars    = false;
     stateMagnification  = Magnification.one; // 처음 1배율
     //binocularsAnimator = gameObject.GetComponent<Animator>();
     //binocularsAnimator.SetBool("isBin", false);
     timer = 0;
 }
        public ActionResult <SpectacleMagnificationModel> SpectacleMagnification(SpectacleMagnificationModel magnification)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            magnification.Result = Magnification.SpectacleMagnification(magnification.FrontBaseCurve, magnification.ActualLensPower, magnification.Index, magnification.Thickness, magnification.VertexDistance);
            return(magnification);
        }
Esempio n. 6
0
        public override LocalEmbed ToEmbed()
        {
            var embed = base.ToEmbed();

            embed.AddField("Type", Type.Transform(To.TitleCase), true);
            embed.AddField("Variable Zoom", VariableZoom ? "Yes" : "No", true);
            embed.AddField("Magnification", Magnification.Humanize(), true);
            embed.AddField("Zero Distances", ZeroDistances.Humanize(x => $"{x} m."), true);

            return(embed);
        }
Esempio n. 7
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());
            }
        }
Esempio n. 8
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);
                }
            }
        }
Esempio n. 9
0
    public static void Call(string path)
    {
        var window = new Magnification();

        window.Show(path);
    }
Esempio n. 10
0
        public void Run()
        {
            Process process = null;

            try
            {
                process = Process.Start(executablePath);
                process.WaitForInputIdle();

                int width = 0, height = 0;
                User32.WINDOWINFO windowInfo = default;
                windowInfo = GetWindowInfo(process.MainWindowHandle);
                width      = windowInfo.rcWindow.right - windowInfo.rcWindow.left;
                height     = windowInfo.rcWindow.bottom - windowInfo.rcWindow.top;

#if DEBUG
                // If Notepad was started, test different window sizes.
                if (executablePath == "notepad")
                {
                    width  = 300;
                    height = 600;
                }
#endif

                ResetWindowPosition(process.MainWindowHandle, width, height);
                InitializeMagnification();

                backgroundWindow = new BackgroundWindow(process.MainWindowHandle, desktopWidth, desktopHeight).Show();

                User32.ShowCursor(false);

                var  refreshInterval = 200;
                var  previousRect = new RECT();
                bool pause = false, forceUpdate = false;
                while (!process.HasExited)
                {
                    if ((User32.GetAsyncKeyState((int)User32.VirtualKey.VK_LWIN)) != 0 &&
                        (User32.GetAsyncKeyState((int)User32.VirtualKey.VK_ESCAPE)) != 0)
                    {
                        pause = !pause;
                        if (pause)
                        {
                            backgroundWindow.Hide();
                            ResetMagnification();
                        }
                        else
                        {
                            backgroundWindow.Show();
                            forceUpdate = true;
                        }
                    }

                    if (pause)
                    {
                        Thread.Sleep(refreshInterval);
                        continue;
                    }

                    if (User32.GetForegroundWindow() != process.MainWindowHandle)
                    {
                        User32.SetForegroundWindow(process.MainWindowHandle);
                    }

                    windowInfo = GetWindowInfo(process.MainWindowHandle);
                    if (windowInfo.rcWindow.left != 0 || windowInfo.rcWindow.top != 0)
                    {
                        ResetWindowPosition(process.MainWindowHandle, windowInfo);
                        windowInfo = GetWindowInfo(process.MainWindowHandle);
                    }

                    if (forceUpdate || !windowInfo.rcClient.Equals(previousRect))
                    {
                        SetMagnification(windowInfo);
                        previousRect = windowInfo.rcClient;
                    }

                    if (forceUpdate)
                    {
                        forceUpdate = false;
                    }

                    Thread.Sleep(refreshInterval);
                }
            }
            catch (Exception ex)
            {
                ex.Message.Log();

                if (process != null && !process.HasExited)
                {
                    process.Kill();
                }
            }
            finally
            {
                try { User32.ShowCursor(true); } catch { }
                try { Magnification.MagUninitialize(); } catch { }
                try { backgroundWindow?.Hide(); } catch { }
            }
        }
Esempio n. 11
0
        /// <summary>
        /// Query on Wolfram Alpha using the specified
        /// </summary>
        /// <param name="query">The query you would like to search for on Wolfram Alpha</param>
        /// <returns>The results of the query</returns>
        public QueryResult Query(string query)
        {
            //http://api.wolframalpha.com/v2/query?input=xx&appid=xxxxx
            RestRequest request = CreateRequest("query", query);

            //Output
            if (Formats.HasElements())
            {
                request.AddParameter("format", string.Join(",", Formats));
            }

            if (OutputUnit != Unit.NotSet)
            {
                request.AddParameter("units", OutputUnit.ToString().ToLower());
            }

            if (Assumptions.HasElements())
            {
                foreach (string assumption in Assumptions)
                {
                    request.AddParameter("assumption", assumption);
                }
            }

            //Filtering
            if (IncludePodIDs.HasElements())
            {
                foreach (string include in IncludePodIDs)
                {
                    request.AddParameter("includepodid", include);
                }
            }

            if (ExcludePodIDs.HasElements())
            {
                foreach (string exclude in ExcludePodIDs)
                {
                    request.AddParameter("excludepodid", exclude);
                }
            }

            if (PodTitles.HasElements())
            {
                foreach (string podTitle in PodTitles)
                {
                    request.AddParameter("podtitle", podTitle);
                }
            }

            if (PodIndex.HasElements())
            {
                request.AddParameter("podindex", string.Join(",", PodIndex));
            }

            if (Scanners.HasElements())
            {
                request.AddParameter("scanner", string.Join(",", Scanners));
            }

            //Timeout
            if (ParseTimeout >= Epsilon)
            {
                request.AddParameter("parsetimeout", ParseTimeout.ToString(_culture));
            }

            if (ScanTimeout >= Epsilon)
            {
                request.AddParameter("scantimeout", ScanTimeout.ToString(_culture));
            }

            if (PodTimeout >= Epsilon)
            {
                request.AddParameter("podtimeout", PodTimeout.ToString(_culture));
            }

            if (FormatTimeout >= Epsilon)
            {
                request.AddParameter("formattimeout", FormatTimeout.ToString(_culture));
            }

            //Async
            if (UseAsync)
            {
                request.AddParameter("async", UseAsync.ToString().ToLower());
            }

            //Location
            if (IpAddress != null)
            {
                request.AddParameter("ip", IpAddress.ToString());
            }

            if (!string.IsNullOrEmpty(Location))
            {
                request.AddParameter("location", Location);
            }

            if (GPSLocation != null)
            {
                request.AddParameter("latlong", GPSLocation.ToString());
            }

            //Size
            if (Width >= 1f)
            {
                request.AddParameter("width", Width);
            }

            if (MaxWidth >= 1f)
            {
                request.AddParameter("maxwidth", MaxWidth);
            }

            if (PlotWidth >= 1f)
            {
                request.AddParameter("plotwidth", PlotWidth);
            }

            if (Magnification >= 0.1f)
            {
                request.AddParameter("mag", Magnification.ToString(_culture));
            }

            //Misc
            if (!string.IsNullOrEmpty(Signature))
            {
                request.AddParameter("sig", Signature);
            }

            if (ReInterpret.HasValue)
            {
                request.AddParameter("reinterpret", ReInterpret.ToString().ToLower());
            }

            if (IgnoreCase.HasValue)
            {
                request.AddParameter("ignorecase", IgnoreCase.ToString().ToLower());
            }

            if (EnableTranslate.HasValue)
            {
                request.AddParameter("translation", EnableTranslate.ToString().ToLower());
            }

            QueryResult results = GetResponse <QueryResult>(request);

            return(results);
        }
Esempio n. 12
0
 /// <summary>
 /// Sets the magnification of the AxIpeDspCtrl image control.
 /// </summary>
 /// <param name="imgDisplay">A reference to the AxeIpeDspCtrl display control used.</param>
 /// <param name="magnification">Sets the magnification of the AxIpeDspCtrl control.</param>
 public void SetZoom(AxIpeDspCtrl imgDisplay, Magnification magnification)
 {
     imgDisplay.SetZoom(( double )magnification);
 }
Esempio n. 13
0
 /// <summary>
 /// Connects the AxIpeDspCtrl image control to an image window in Sherlock and then sets the magnification.
 /// </summary>
 /// <param name="displayName">The name of the image window in Sherlock.</param>
 /// <param name="imgDisplay">A reference to the AxeIpeDspCtrl display control used.</param>
 /// <param name="magnification">Sets the inital magnification of the AxIpeDspCtrl control.</param>
 public void ConnectDisplay(string displayName, AxIpeDspCtrl imgDisplay, Magnification magnification)
 {
     imgDisplay.ConnectEngine(_sherlock.GetEngineObj( ));
     imgDisplay.ConnectImgWindow(displayName);
     imgDisplay.SetZoom(( double )magnification);
 }
Esempio n. 14
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["matrix_sleep_time"], out var sleepTime);

            var effect = new Magnification.MAGCOLOREFFECT();

            var random = new Random();

            while (true)
            {
                var matr = Matrices[random.Next(0, Matrices.Count - 1)];

                var t = random.Next(0, 8);

                switch (t)
                {
                case 0:
                    matr = MoreBlue(matr);
                    break;

                case 1:
                    matr = MoreGreen(matr);
                    break;

                case 2:
                    matr = MoreRed(matr);
                    break;

                default:
                    matr = Multiply(matr, Matrices[random.Next(0, Matrices.Count - 1)]);
                    break;
                }

                if (!_configuration.GetBool("smooth_changing"))
                {
                    effect[0, 0] = matr[0, 0];
                    effect[0, 1] = matr[0, 1];
                    effect[0, 2] = matr[0, 2];
                    effect[0, 3] = matr[0, 3];
                    effect[0, 4] = matr[0, 4];
                    effect[1, 0] = matr[1, 0];
                    effect[1, 1] = matr[1, 1];
                    effect[1, 2] = matr[1, 2];
                    effect[1, 3] = matr[1, 3];
                    effect[1, 4] = matr[1, 4];
                    effect[2, 0] = matr[2, 0];
                    effect[2, 1] = matr[2, 1];
                    effect[2, 2] = matr[2, 2];
                    effect[2, 3] = matr[2, 3];
                    effect[2, 4] = matr[2, 4];
                    effect[3, 0] = matr[3, 0];
                    effect[3, 1] = matr[3, 1];
                    effect[3, 2] = matr[3, 2];
                    effect[3, 3] = matr[3, 3];
                    effect[3, 4] = matr[3, 4];
                    effect[4, 0] = matr[4, 0];
                    effect[4, 1] = matr[4, 1];
                    effect[4, 2] = matr[4, 2];
                    effect[4, 3] = matr[4, 3];
                    effect[4, 4] = matr[4, 4];

                    Magnification.MagSetFullscreenColorEffect(effect);
                }
                else
                {
                    var transitions = Interpolate(effect, matr);

                    foreach (var transition in transitions)
                    {
                        Apply(transition);
                        await Task.Delay(15);
                    }
                }

                if (timeoutSet)
                {
                    await Task.Delay(sleepTime);
                }
            }
        }
        public QrCodeBuilder SetSize(Magnification magnification)
        {
            Context.MagnificationFactor = magnification;

            return(this);
        }