Define a static constructor to initialize static members of the class.
C#
Copy Code
|
---|
static IconNode() { defaultIcon = new Bitmap(48, 48);
Graphics graphics = Graphics.FromImage(defaultIcon); Font font = new Font("Arial", 48, FontStyle.Bold, GraphicsUnit.Pixel);
graphics.FillRectangle(Brushes.Transparent, 0, 0, 48, 48); graphics.DrawString("?", font, Brushes.Black, 0, 0);
font.Dispose(); graphics.Dispose(); } |
Visual Basic
Copy Code
|
---|
Shared Sub New()
defaultIcon = New Bitmap(48, 48)
Dim graphics As Graphics = graphics.FromImage(defaultIcon) Dim font As Font = New Font("Arial", 48, FontStyle.Bold, GraphicsUnit.Pixel)
graphics.FillRectangle(Brushes.Transparent, 0, 0, 48, 48) graphics.DrawString("?", font, Brushes.Black, 0, 0)
font.Dispose() graphics.Dispose()
End Sub |