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);
            }
        }
示例#2
0
 public Resolution(AspectRatio ar, int horizontalResolution, int verticalResolution)
 {
     AR = ar;
     HorizontalResolution = horizontalResolution;
     VerticalResolution   = verticalResolution;
 }
 private void AddResolutionsForAspectRatio(List <Resolution> resolutions, int initialWidth, int initialHeight, AspectRatio ar)
 {
     for (decimal i = 1; i < 6; i++)
     {
         resolutions.Add(GetResolutionForAR(initialWidth, initialHeight, ar, i));
         resolutions.Add(GetResolutionForAR(initialWidth, initialHeight, ar, i + 0.25m));
         resolutions.Add(GetResolutionForAR(initialWidth, initialHeight, ar, i + 0.5m));
         resolutions.Add(GetResolutionForAR(initialWidth, initialHeight, ar, i + 0.75m));
     }
 }
示例#4
0
 private void AddResolutionNodes(TreeNode parentNode, int initialWidth, int initialHeight, AspectRatio ar)
 {
     for (decimal i = 1; i < 6; i++)
     {
         AddResolutionNode(parentNode, initialWidth, initialHeight, ar, i);
         AddResolutionNode(parentNode, initialWidth, initialHeight, ar, i + 0.25m);
         AddResolutionNode(parentNode, initialWidth, initialHeight, ar, i + 0.5m);
         AddResolutionNode(parentNode, initialWidth, initialHeight, ar, i + 0.75m);
     }
 }