Hi,
my first attempt to create BSish toolbar icons: instead of loading pcts, I tried using SF Pro font’s glyphs, for a Preferences window. At present, two toolbaritems only: General and Advanced.
Although the outcome seems good enough (below), is it a good idea to go this way? Or should I load real pictures?
- open event of the toolbar
Sub Open() Handles Open
//to do: check if user has got SF Pro installed
me.ToolItem1.Icon = initToolbarIcons(Encodings.UTF8.Chr(&h1008CB),true)//gear
me.ToolItem2.Icon = initToolbarIcons(encodings.utf8.chr(&h10094E),false)//double gear
me.ToolItem1.Caption = “General”
me.ToolItem1.Name = “General”
me.ToolItem1.pressed = true
me.ToolItem2.Caption = “Advanced”
me.ToolItem2.Name = “Advanced”
End Sub
-
and this is the method returning the pictures
Public Function initToolbarIcons(s as string, applyClr as Boolean) As picture
dim p as picture
dim sf as Double = ScaleFactor
p = new Picture(32sf,32sf)
p.Graphics.TextFont = “SFPro”
p.Graphics.AntiAlias = false
p.Graphics.TextSize = 22*sf
if IsDarkMode then
p.Graphics.ForeColor = color.Gray
end if
if applyClr then//matching more or less the label.color when item.pressed
if IsDarkMode then
p.Graphics.ForeColor = clrDarkMode
else
p.Graphics.ForeColor = clrLightMode
end if
end if
p.Graphics.DrawString s, ((p.Width-p.Graphics.stringwidth(s))/2) * sf, 23 * sf
Return p
End Function -
resulting in this pct
-
code for action event wtc. not added; but it is more or less the one in the open event.
Thanks,