Exemplo n.º 1
0
        private void HandleResolutionValueChanged()
        {
            int horizontalResolution = (int)_newWidthBox.Value;
            int verticalResolution   = (int)_newHeightBox.Value;

            _setResolutionButton.IsEnabled = (horizontalResolution >= 640 && verticalResolution >= 480);
            _aspectRatioTextBox.Text       = GeneralUtils.CalculateAspectRatio(horizontalResolution, verticalResolution).ToString(appendDescription: false);
        }
Exemplo n.º 2
0
        private void AddResolutionToRecentlyUsedList(int horizontalResolution, int verticalResolution)
        {
            // Base the aspect ratio on the string representation we have constructed. This is a bit lame, but it can be the user changes the width or height
            // manually after selecting a node in the tree so the ar has changed. Calculating it again from width/height is tempting but gives wrong results for
            // 21:9 which isn't really 21:9 but 21.5:9 so the AR doesn't match anymore.
            var ar = string.IsNullOrEmpty(_aspectRatioTextBox.Text) ? GeneralUtils.CalculateAspectRatio(horizontalResolution, verticalResolution)
                                                                                                                                        : AspectRatio.FromString(_aspectRatioTextBox.Text);
            var toAdd = new Resolution(ar, horizontalResolution, verticalResolution, string.Format("{0} x {1} ({2})", horizontalResolution, verticalResolution, ar));

            this.RecentlyUserResolutions.Remove(toAdd);                 // if we've used this one before, remove it from the list as it will be placed at the front.
            this.RecentlyUserResolutions.Insert(0, toAdd);
            // remove any resolutions over the maximum. This is at most 1, as we're adding 1 at a time.
            while (this.RecentlyUserResolutions.Count > ConstantsEnums.NumberOfResolutionsToKeep)
            {
                this.RecentlyUserResolutions.RemoveAt(ConstantsEnums.NumberOfResolutionsToKeep);
            }
        }
Exemplo n.º 3
0
 private void GetActiveGameWindowInfo()
 {
     _gameWindowHwnd = AppStateSingleton.Instance().GetMainWindowHandleOfAttachedProcess();
     if (_gameWindowHwnd == IntPtr.Zero)
     {
         _currentWidthTextBox.Text  = string.Empty;
         _currentHeightTextBox.Text = string.Empty;
         _currentARTextBox.Text     = string.Empty;
         return;
     }
     Win32Wrapper.GetWindowInfo(_gameWindowHwnd, ref _gameWindowInfo);
     _currentWidthTextBox.Text  = _gameWindowInfo.rcWindow.Width.ToString();
     _currentHeightTextBox.Text = _gameWindowInfo.rcWindow.Height.ToString();
     _currentARTextBox.Text     = GeneralUtils.CalculateAspectRatio(_gameWindowInfo.rcWindow.Width, _gameWindowInfo.rcWindow.Height).ToString(appendDescription: false);
     if (_newHeightBox.Value <= 0 || _newWidthBox.Value <= 0)
     {
         //reset with current window
         _newHeightBox.Value      = _gameWindowInfo.rcWindow.Height;
         _newWidthBox.Value       = _gameWindowInfo.rcWindow.Width;
         _aspectRatioTextBox.Text = _currentARTextBox.Text;
     }
 }
Exemplo n.º 4
0
        private void BuildResolutionTree(System.Drawing.Rectangle screenBounds)
        {
            var arOfScreen = GeneralUtils.CalculateAspectRatio(screenBounds.Width, screenBounds.Height);

            arOfScreen.Description = "Monitor aspect ratio";
            _monitorResolution     = new Resolution(arOfScreen, screenBounds.Width, screenBounds.Height,
                                                    string.Format("{0} x {1} ({2})", screenBounds.Width, screenBounds.Height, arOfScreen.ToString(false)));
            // default ARs
            var defaultARs = new List <AspectRatio>()
            {
                new AspectRatio(16, 9), new AspectRatio(16, 10), new AspectRatio(21, 9), new AspectRatio(1, 1),
                new AspectRatio(9, 16), new AspectRatio(2, 3), new AspectRatio(3, 2), new AspectRatio(2, 1), new AspectRatio(3, 4), new AspectRatio(4, 5)
            };

            // remove the one we already have determined from the monitor (if present)
            defaultARs.Remove(arOfScreen);
            var resolutions = new List <Resolution>();

            // first the resolutions based on the screen resolution
            AddResolutionsForAspectRatio(resolutions, screenBounds.Width, screenBounds.Height, arOfScreen);
            // then the resolutions calculated from the aspect ratios in the list.
            foreach (var ar in defaultARs)
            {
                if (ar.Horizontal <= ar.Vertical)
                {
                    // use height instead of width so the full shot can be setup on the lowest res
                    AddResolutionsForAspectRatio(resolutions, (int)(screenBounds.Height * ar.ARFactorWidth), screenBounds.Height, ar);
                }
                else
                {
                    AddResolutionsForAspectRatio(resolutions, screenBounds.Width, (int)(screenBounds.Width * ar.ARFactorHeight), ar);
                }
            }

            _resolutionTreeView.ItemsSource = resolutions.GroupBy(r => r.AR.ToString());
        }