Skip to content

Commit

Permalink
- Do not resize buttons spec images, as that is handled by the Renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
Smurf-IV committed Feb 6, 2022
1 parent 6c30018 commit d574bc6
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 67 deletions.
1 change: 1 addition & 0 deletions Documents/Help/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* Resolved [#611](https://github.com/Krypton-Suite/Standard-Toolkit/issues/611), `KryptonContextMenu`: Cannot add `ComboBoxItem`
* Implemented [#610](https://github.com/Krypton-Suite/Standard-Toolkit/issues/610), `KryptonContextMenuRadioButton` - no way to assign a method/event through the item editor
* Resolved [#607](https://github.com/Krypton-Suite/Standard-Toolkit/issues/607), `KryptonMessageBox` Certain length of the first line of text can push the text on the following out of the visible area (thanks to [giduac](https://github.com/giduac))
* Some fixes for [#603](https://github.com/Krypton-Suite/Standard-Toolkit/issues/603), Title Bar Images Stretched/Cropped
* Resolved [#596](https://github.com/Krypton-Suite/Standard-Toolkit/issues/596), ActionLists do not reflect the recommended or possible settings in the designer properties
* Resolved [#590](https://github.com/Krypton-Suite/Standard-Toolkit/issues/590), Button text colour in certain themes is unreadable
* Resolved [#587](https://github.com/Krypton-Suite/Standard-Toolkit/issues/587), `KryptonLabel` adds the `Paint` method by default
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public class KryptonPage : VisualPanel
/// Initialize a new instance of the KryptonPage class.
/// </summary>
public KryptonPage()
: this("Page", null)
: this(@"Page", null)
{
}

Expand Down Expand Up @@ -166,9 +166,9 @@ public KryptonPage(string text, Bitmap imageSmall, string uniqueName)
// Default properties
Text = text;
MinimumSize = new Size(50, 50);
_textTitle = "Page Title";
_textDescription = "Page Description";
_toolTipTitle = "Page ToolTip";
_textTitle = @"Page Title";
_textDescription = @"Page Description";
_toolTipTitle = @"Page ToolTip";
_toolTipBody = string.Empty;
_toolTipImage = null;
_toolTipStyle = LabelStyle.ToolTip;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,6 @@ protected virtual void OnFinishDelegate(object sender, EventArgs e) =>

#region IContentValues

private float _lastFactorDpiX;
private float _lastFactorDpiY;
private readonly Dictionary<Image, Image> _cachedImages = new();
/// <summary>
/// Gets the content image.
/// </summary>
Expand All @@ -319,33 +316,10 @@ public Image GetImage(PaletteState state)
{
// Get value from button spec passing inheritance redirector
var baseImage = ButtonSpec.GetImage(_redirector, state);
if (baseImage == null)
{
return null;
}

// Currently the `ViewButton.FactorDpi#`'s do _NOT_ change whilst the app is running
if (/*(ViewButton.FactorDpiX != _lastFactorDpiX)
|| (ViewButton.FactorDpiY != _lastFactorDpiY)
||*/ !_cachedImages.ContainsKey(baseImage)
)
{
// Image needs to be regenerated
_lastFactorDpiX = ViewButton.FactorDpiX;
_lastFactorDpiY = ViewButton.FactorDpiY;
var currentWidth = baseImage.Width * _lastFactorDpiX;
var currentHeight = baseImage.Height * _lastFactorDpiY;
if ((int)currentHeight == baseImage.Height)
{
// Need to workaround the image drawing off the bottom of the form title bar when scaling @ 100%
currentHeight -= 2; // Has to be even to ensure that horizontal lines are still drawn.
}

_cachedImages[baseImage] = CommonHelper.ScaleImageForSizedDisplay(baseImage, currentWidth, currentHeight);
}

//return baseImage;
return _cachedImages[baseImage];
// No need to perform scaling as it will be done @
// $\Standard-Toolkit\Source\Krypton Components\Krypton.Toolkit\Rendering\RenderStandard.cs
// line 5779: memento.Image = CommonHelper.ScaleImageForSizedDisplay(memento.Image, currentWidth, currentHeight);
return baseImage;
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5773,11 +5773,10 @@ private static void AllocateImageSpace(StandardContentMemento memento,
if ((displayRect.Width < memento.Image.Width) ||
(displayRect.Height < memento.Image.Height))
{
var ratio = 1.0f * Math.Min(memento.Image.Width, memento.Image.Height) /
Math.Max(memento.Image.Width, memento.Image.Height);
// Resize image to fit display area
var currentWidth = Math.Min(displayRect.Width, memento.Image.Width);
var currentHeight = Math.Min(displayRect.Height, memento.Image.Height);

memento.Image = CommonHelper.ScaleImageForSizedDisplay(memento.Image, currentWidth, currentHeight);
memento.Image = CommonHelper.ScaleImageForSizedDisplay(memento.Image, displayRect.Width*ratio, displayRect.Height*ratio);

}
// Cache the size of the image
Expand Down

0 comments on commit d574bc6

Please sign in to comment.