The Wisej.NET Image Model: Image, ImageSource and ImageList
One command panel whose four buttons carry their icons three different ways - a server-side
System.Drawing.Image, a named theme image on ImageSource, and two buttons sharing one
ImageList through ImageKey - plus lblDiagnostics, which reads each button back through
IImage and names the mechanism actually in play.
This folder is the complete application at this point in the course, with its own solution and port.
Run it
cd "Icons and Images Course/Module 1/IconDesk"
dotnet run -f net10.0 --urls http://localhost:6201
Open http://localhost:6201. In Visual Studio, open IconDesk.slnx and press F5.
The screen
A 40-pixel application bar (IconDesk — Command panel and the three window glyphs), a
Commands heading, the four command buttons with the glyph above the caption, the
lblDiagnostics card, and a status strip. Nothing else.
What to try
| Action | Expected result |
|---|---|
| Press Open, Save, Print, Delete in turn | Each click adds one line to the diagnostics card naming that button's mechanism: Image, ImageSource, then two ImageList + Key lines. With all four printed the status strip turns green. |
| Press Delete again | The picture stored under the key "delete" is replaced. The bin becomes a crossed circle although no image property was assigned on any control - the button holds the key, not the picture. |
| Press Delete once more | A second image property is set on the same button. The diagnostics line flips to ImageSource and the status strip turns red: the key did not merely stop deciding, assigning the source cleared it. |
| Open the browser network panel and reload | btnOpen and the two ImageList pictures arrive as component.wx requests (server-rendered PNG). The theme icon does not - it arrives inline with the theme as a data:image/svg+xml URL. |
Notes for anyone extending the panel
ImageandImageSourceare mutually exclusive, and so areImageSourceandImageList/ImageKey. Assigning an image source clears the others - verified inTakeTheSlotFromTheKey. Nothing warns you, so a lost icon is usually a second assignment somewhere else rather than a missing file.- A control fed from an
ImageListstill returns a picture fromImage. TestImageListandImageKeybeforeImageor every keyed control looks like an image-object control. ImageList.Images["key"]is read-only as an assignment target. It returns the liveImageListEntry; setentry.Imageto repoint the key.- A repointed key does not reach the browser on its own: Wisej.NET serves each control's picture
from a URL stamped with that control's version.
RepaintControlsOnfinds every control on the same list and key and writes the same key back, which moves the version without changing what the control points at. - A button's icon is sized by the theme (18 pixels in Bootstrap-4) unless an
ImageListsupplies anImageSize.imagesCommands.ImageSizeis set to 18 so all four glyphs match. Image.FromFilekeeps the file locked for the lifetime of the image, which is the last thing a server application wants.LoadServerImagereads the bytes and builds the image from aMemoryStreaminstead.Application.MapPath("Images/open.png")resolves whether the application runs frombin/or from a published folder. TheImagesfolder is copied to the output by the.csproj, because the browser also fetches some of these files by relative URL in later modules.