//Update the max frame rate setting
        public static void UpdateMaxFrameRateSetting()
        {
            try
            {
                //Get the current target monitor
                int monitorNumber = Convert.ToInt32(ConfigurationManager.AppSettings["DisplayMonitor"]);

                //Get the monitor refresh rate
                DisplayMonitorSettings displayMonitorSettings = GetScreenSettings(monitorNumber);

                //Adjust the maximum frame rate
                int targetRefreshRate = displayMonitorSettings.RefreshRate;
                int maxFpsOffset      = Convert.ToInt32(ConfigurationManager.AppSettings["MaxFpsOffset"]);
                targetRefreshRate += maxFpsOffset;
                bool adjustedFps = NvApiWrapper.UpdateMaxFrameRate(targetRefreshRate);

                //Update the status text
                if (adjustedFps)
                {
                    AppTray.NotifyIcon.Text = "Nvidia Fps Limit Helper (" + targetRefreshRate + "fps)";
                    App.vMainWindow.textblock_ApplicationStatus.Text = "Status: adjusted the maximum frame rate to " + targetRefreshRate + "fps at " + DateTime.Now.ToShortTimeString();
                }
                else
                {
                    AppTray.NotifyIcon.Text = "Nvidia Fps Limit Helper (?fps)";
                    App.vMainWindow.textblock_ApplicationStatus.Text = "Status: failed to adjust the maximum frame rate to " + targetRefreshRate + "fps at " + DateTime.Now.ToShortTimeString();
                }
            }
            catch { }
        }
Esempio n. 2
0
        //Update the window position
        async Task UpdateWindowPosition(bool notifyApps, bool silent)
        {
            try
            {
                //Check if the application is maximized
                bool isMaximized = vAppMaximized;
                if (isMaximized)
                {
                    await AppSwitchScreenMode(false, true);
                }

                //Get the current active screen
                int monitorNumber = Convert.ToInt32(Setting_Load(vConfigurationCtrlUI, "DisplayMonitor"));
                DisplayMonitorSettings displayMonitorSettings = GetScreenSettings(monitorNumber);

                //Get the current window size
                int windowWidth  = (int)(this.ActualWidth * displayMonitorSettings.DpiScaleHorizontal);
                int windowHeight = (int)(this.ActualHeight * displayMonitorSettings.DpiScaleVertical);

                //Check and resize the target window size
                if (windowWidth > displayMonitorSettings.WidthNative || windowHeight > displayMonitorSettings.HeightNative)
                {
                    windowWidth  = displayMonitorSettings.WidthNative;
                    windowHeight = displayMonitorSettings.HeightNative;
                    WindowResize(vInteropWindowHandle, windowWidth, windowHeight);
                }

                //Center the window on target screen
                int horizontalLeft = (int)(displayMonitorSettings.BoundsLeft + (displayMonitorSettings.WidthNative - windowWidth) / 2);
                int verticalTop    = (int)(displayMonitorSettings.BoundsTop + (displayMonitorSettings.HeightNative - windowHeight) / 2);
                WindowMove(vInteropWindowHandle, horizontalLeft, verticalTop);

                //Restore the previous screen mode
                if (isMaximized)
                {
                    await AppSwitchScreenMode(true, false);
                }

                //Notify apps the monitor changed
                if (notifyApps)
                {
                    await NotifyDirectXInputSettingChanged("DisplayMonitor");
                    await NotifyFpsOverlayerSettingChanged("DisplayMonitor");
                }

                //Show monitor change notification
                if (!silent)
                {
                    await Notification_Send_Status("MonitorNext", "Moved to monitor " + monitorNumber);
                }

                Debug.WriteLine("Moved the application to monitor: " + monitorNumber);
            }
            catch { }
        }
Esempio n. 3
0
        //Update the window position
        public void UpdateWindowPosition()
        {
            try
            {
                //Get the current active screen
                int monitorNumber = Convert.ToInt32(Setting_Load(vConfigurationCtrlUI, "DisplayMonitor"));
                DisplayMonitorSettings displayMonitorSettings = GetScreenSettings(monitorNumber);

                //Move and resize the window
                WindowMove(vInteropWindowHandle, displayMonitorSettings.BoundsLeft, displayMonitorSettings.BoundsTop);
                WindowResize(vInteropWindowHandle, displayMonitorSettings.WidthNative, displayMonitorSettings.HeightNative);
            }
            catch { }
        }
Esempio n. 4
0
        //Update the window position
        public void UpdateWindowPosition()
        {
            try
            {
                //Get the current active screen
                int monitorNumber = Convert.ToInt32(Setting_Load(vConfigurationCtrlUI, "DisplayMonitor"));
                DisplayMonitorSettings displayMonitorSettings = GetScreenSettings(monitorNumber);

                //Get the current window size
                int windowWidth  = (int)(this.ActualWidth * displayMonitorSettings.DpiScaleHorizontal);
                int windowHeight = (int)(this.ActualHeight * displayMonitorSettings.DpiScaleVertical);

                //Move the window to screen center
                int horizontalLeft = (int)(displayMonitorSettings.BoundsLeft + (displayMonitorSettings.WidthNative - windowWidth) / 2);
                int verticalTop    = (int)(displayMonitorSettings.BoundsTop + (displayMonitorSettings.HeightNative - windowHeight) / 2);
                WindowMove(vInteropWindowHandle, horizontalLeft, verticalTop);
            }
            catch { }
        }
Esempio n. 5
0
        //Move the keyboard window based on thumb movement
        public void MoveKeyboardWindow(int mouseHorizontal, int mouseVertical)
        {
            try
            {
                //Check the mouse movement position
                if (mouseHorizontal == 0 && mouseVertical == 0)
                {
                    return;
                }

                //Get the current window position
                WindowRectangle positionRect = new WindowRectangle();
                GetWindowRect(vInteropWindowHandle, ref positionRect);
                int moveLeft   = positionRect.Left + mouseHorizontal;
                int moveTop    = positionRect.Top + mouseVertical;
                int moveRight  = positionRect.Right + mouseHorizontal;
                int moveBottom = positionRect.Bottom + mouseVertical;

                //Get the current active screen
                int monitorNumber = Convert.ToInt32(Setting_Load(vConfigurationCtrlUI, "DisplayMonitor"));
                DisplayMonitorSettings displayMonitorSettings = GetScreenSettings(monitorNumber);

                //Get the current window size
                int windowWidth  = (int)(this.ActualWidth * displayMonitorSettings.DpiScaleHorizontal);
                int windowHeight = (int)(this.ActualHeight * displayMonitorSettings.DpiScaleVertical);

                //Check if window leaves screen
                double screenEdgeLeft    = moveLeft + windowWidth;
                double screenLimitLeft   = displayMonitorSettings.BoundsLeft + 20;
                double screenEdgeTop     = moveTop + windowHeight;
                double screenLimitTop    = displayMonitorSettings.BoundsTop + 20;
                double screenEdgeRight   = moveRight - windowWidth;
                double screenLimitRight  = displayMonitorSettings.BoundsRight - 20;
                double screenEdgeBottom  = moveBottom - windowHeight;
                double screenLimitBottom = displayMonitorSettings.BoundsBottom - 20;
                if (screenEdgeLeft > screenLimitLeft && screenEdgeTop > screenLimitTop && screenEdgeRight < screenLimitRight && screenEdgeBottom < screenLimitBottom)
                {
                    WindowMove(vInteropWindowHandle, moveLeft, moveTop);
                }
            }
            catch { }
        }
Esempio n. 6
0
        //Activate keyboard window
        void CheckMousePosition()
        {
            try
            {
                //Get the current active screen
                int monitorNumber = Convert.ToInt32(Setting_Load(vConfigurationCtrlUI, "DisplayMonitor"));
                DisplayMonitorSettings displayMonitorSettings = GetScreenSettings(monitorNumber);

                //Get the current mouse position
                GetCursorPos(out PointWin previousCursorPosition);

                //Check if mouse cursor is in window
                if ((displayMonitorSettings.HeightNative - previousCursorPosition.Y) <= this.Height)
                {
                    previousCursorPosition.Y = Convert.ToInt32(displayMonitorSettings.HeightNative - this.Height - 20);
                    SetCursorPos(previousCursorPosition.X, previousCursorPosition.Y);
                }
            }
            catch { }
        }
Esempio n. 7
0
        //Activate keyboard window
        void CheckMousePosition()
        {
            try
            {
                //Get the current active screen
                int monitorNumber = Convert.ToInt32(Setting_Load(vConfigurationCtrlUI, "DisplayMonitor"));
                DisplayMonitorSettings displayMonitorSettings = GetScreenSettings(monitorNumber);

                //Get the current mouse position
                GetCursorPos(out PointWin previousCursorPosition);

                //Check if mouse cursor is in window
                int windowHeight        = (int)this.Height;
                int displayCenterTop    = (int)(displayMonitorSettings.BoundsTop + (displayMonitorSettings.HeightNative - windowHeight) / 2);
                int displayCenterBottom = displayCenterTop + windowHeight;
                if (AVFunctions.BetweenNumbers(previousCursorPosition.Y, displayCenterTop, displayCenterBottom, true))
                {
                    previousCursorPosition.Y = displayCenterTop - 20;
                    SetCursorPos(previousCursorPosition.X, previousCursorPosition.Y);
                }
            }
            catch { }
        }
Esempio n. 8
0
        //Update the monitor information
        void UpdateMonitorInformation()
        {
            try
            {
                //Check if the information is visible
                bool showResolution    = Convert.ToBoolean(Setting_Load(vConfigurationFpsOverlayer, "MonShowResolution"));
                bool showDpiResolution = Convert.ToBoolean(Setting_Load(vConfigurationFpsOverlayer, "MonShowDpiResolution"));
                bool showColorBitDepth = Convert.ToBoolean(Setting_Load(vConfigurationFpsOverlayer, "MonShowColorBitDepth"));
                bool showRefreshRate   = Convert.ToBoolean(Setting_Load(vConfigurationFpsOverlayer, "MonShowRefreshRate"));
                if (!showResolution && !showColorBitDepth && !showRefreshRate)
                {
                    AVActions.ActionDispatcherInvoke(delegate
                    {
                        stackpanel_CurrentMon.Visibility = Visibility.Collapsed;
                    });
                    return;
                }

                //Get the current active screen
                int monitorNumber = Convert.ToInt32(Setting_Load(vConfigurationCtrlUI, "DisplayMonitor"));

                //Get the screen resolution
                DisplayMonitorSettings displayMonitorSettings = GetScreenSettings(monitorNumber);
                string screenResolutionString = string.Empty;
                if (showResolution)
                {
                    if (showDpiResolution)
                    {
                        screenResolutionString = " " + displayMonitorSettings.WidthDpi + "x" + displayMonitorSettings.HeightDpi;
                    }
                    else
                    {
                        screenResolutionString = " " + displayMonitorSettings.WidthNative + "x" + displayMonitorSettings.HeightNative;
                    }
                }

                //Get the screen color bit depth
                string screenColorBitDepthString = string.Empty;
                if (showColorBitDepth)
                {
                    screenColorBitDepthString = " " + displayMonitorSettings.BitDepth + "Bits";
                }

                //Get the screen refresh rate
                string screenRefreshRateString = string.Empty;
                if (showRefreshRate)
                {
                    int screenRefreshRateInt = displayMonitorSettings.RefreshRate;
                    if (screenRefreshRateInt > 0)
                    {
                        if (showResolution || showColorBitDepth)
                        {
                            screenRefreshRateString = " @ " + screenRefreshRateInt + "Hz";
                        }
                        else
                        {
                            screenRefreshRateString = " " + screenRefreshRateInt + "Hz";
                        }
                    }
                }

                //Update the screen resolution
                string stringDisplay = AVFunctions.StringRemoveStart(vTitleMON + screenResolutionString + screenColorBitDepthString + screenRefreshRateString, " ");
                AVActions.ActionDispatcherInvoke(delegate
                {
                    textblock_CurrentMon.Text        = stringDisplay;
                    stackpanel_CurrentMon.Visibility = Visibility.Visible;
                });
            }
            catch { }
        }