Home

LINQPad.Controls.Image.Style is overwritten when a LINQPad.Util.ScaleMode is active

Came across this small issue when I was building up a tiny interface:

If a LINQPad.Util.ScaleMode is used with LINQPad.Controls.Image, any value set to Styles gets dropped when the image actually renders it's dump.

An incredibly minor problem that I did manage to find a workaround for (by manually adjusting the Style property on HtmlElement,) but I figured it might be worth tweaking if you wanted to knock out an easy bug. :)

Cheers and thanks a bunch as always!

Screenshot:
screenshot of behavior

Repro code:

void Main()
{
    string imagePath = @"C:\Windows\System32\ComputerToastIcon.png";

    LINQPad.Controls.Image image0 = new(imagePath, Util.ScaleMode.ResizeTo(50));
    image0.Styles["border"] = "3px red solid";
    image0.Dump("image0 (with scale mode - `Style` property)");

    LINQPad.Controls.Image image1 = new(imagePath);
    image1.Styles["border"] = "3px red solid";
    image1.Dump("image1 (without scale mode)");

    LINQPad.Controls.Image image2 = new(imagePath, Util.ScaleMode.ResizeTo(50));
    string oldStyle = image2.HtmlElement["style"];
    image2.HtmlElement["style"] = $"border: 3px red solid; {oldStyle}";
    image2.Dump("image2 (with scale mode & workaround)");

    string version = typeof(LINQPad.Util).Assembly.GetType("LINQPad.AppVersion").GetField("VersionString").GetValue(null) as string;
    Util.Metatext($"LINQPad v{version}").Dump();
}

Comments

Sign In or Register to comment.