Brushing Up
by Remy Porter
in CodeSOD
on 2025-01-15
Keige inherited some code which seems to be part of a drawing application. It can load brush textures from image files- at least, sometimes it can.
static public Brush GetImageBrush(string serviceCode, string imageName, string language)
{
Brush BorderChannelGroupBrush;
BitmapImage image = null;
int point = imageName.LastIndexOf('.');
string languageImagename = imageName.Substring(0, point) + "-" + language + imageName.Substring(point);
try
{
image = FrameWork.ServicePageImageUrlOnContentServer(serviceCode, languageImagename);
}
catch { }
if (image == null)
{
try
{
image = FrameWork.ServicePageImageUrlOnContentServer(serviceCode, imageName);
}
catch { }
}
if (image != null)
{
BorderChannelGroupBrush = new ImageBrush(image);
}
else
{
BorderChannelGroupBrush = Brushes.White;
}
return BorderChannelGroupBrush;
}