Neco/LandView/GraphicsEngine.cs
/// <summary>Draws a two line, two font label centered on the given point, on the given Graphics</summary>
/// <param name="GRM">Graphics object to draw on</param>
/// <param name="LabelCenter">Point to center the label on</param>
/// <param name="NameLabel">String to write on the first line</param>
/// <param name="InfoLabel">String to write on the second line</param>
/// <param name="NameFont">Font for the first line</param>
/// <param name="InfoFont">Font for the second line</param>
/// <param name="Padding">Padding around the label</param>
/// <param name="Spacing">Spacing between the first and second line of text</param>
/// <param name="Background">Color of the background of the label</param>
/// <param name="Foreground">Color of the foreground of the label (The text)</param>
Draws a two line, two font label centered on the given point, on the given Graphics
Draws a two line two font label centered on the given point on the given Graphics
public static void DrawLabel(Graphics GRM, Point LabelCenter, string NameLabel, string InfoLabel, Color Foreground, Color Background, Font NameFont, Font InfoFont, int Padding, int Spacing) {
            SizeF NameSize = GRM.MeasureString(NameLabel, NameFont);
            SizeF InfoSize = GRM.MeasureString(InfoLabel, InfoFont);
            Size CardSize = new(Convert.ToInt32(Math.Max(NameSize.Width, InfoSize.Width)) + (2 * Padding),
                                        Convert.ToInt32(NameSize.Height + InfoSize.Height) + Spacing + (2 * Padding));
            Point LabelDrawPoint = OffsetPoint(LabelCenter, CardSize.Width / -2, CardSize.Height / -2);
            GRM.FillRectangle(new SolidBrush(Background), LabelDrawPoint.X, LabelDrawPoint.Y, CardSize.Width, CardSize.Height);
            GRM.DrawString(NameLabel, NameFont, new SolidBrush(Foreground), OffsetPoint(LabelDrawPoint, Padding, Padding));
            GRM.DrawString(InfoLabel, InfoFont, new SolidBrush(Foreground), OffsetPoint(LabelDrawPoint, Padding, Padding + Convert.ToInt32(NameSize.Height) + Spacing));
        }
public static void DrawLabel ( Graphics GRM , Point LabelCenter , string NameLabel , string InfoLabel , Color Foreground , Color Background , Font NameFont , Font InfoFont , int Padding , int Spacing ) { SizeF NameSize = GRM . MeasureString ( NameLabel , NameFont ) ; SizeF InfoSize = GRM . MeasureString ( InfoLabel , InfoFont ) ; Size CardSize = new ( Convert . ToInt32 ( Math . Max ( NameSize . Width , InfoSize . Width ) ) + ( 2 * Padding ) , Convert . ToInt32 ( NameSize . Height + InfoSize . Height ) + Spacing + ( 2 * Padding ) ) ; Point LabelDrawPoint = OffsetPoint ( LabelCenter , CardSize . Width / - 2 , CardSize . Height / - 2 ) ; GRM . FillRectangle ( new SolidBrush ( Background ) , LabelDrawPoint . X , LabelDrawPoint . Y , CardSize . Width , CardSize . Height ) ; GRM . DrawString ( NameLabel , NameFont , new SolidBrush ( Foreground ) , OffsetPoint ( LabelDrawPoint , Padding , Padding ) ) ; GRM . DrawString ( InfoLabel , InfoFont , new SolidBrush ( Foreground ) , OffsetPoint ( LabelDrawPoint , Padding , Padding + Convert . ToInt32 ( NameSize . Height ) + Spacing ) ) ; }
Draws a two line, two font label centered on the given point, on the given Graphics
Draws a two line two font label centered on the given point on the given Graphics
//Get the point at which to draw this thing //Draw a rectangle in black //Draw the Label //Draw the PlotLabel //Now we're done
GRM
Graphics
Graphics object to draw on
Graphics object to draw on
LabelCenter
Point
Point to center the label on
Point to center the label on
NameLabel
string
String to write on the first line
String to write on the first line
InfoLabel
string
String to write on the second line
String to write on the second line
Foreground
Color
Color of the foreground of the label (The text)
Color of the foreground of the label ( The text )
Background
Color
Color of the background of the label
Color of the background of the label
NameFont
Font
Font for the first line
Font for the first line
InfoFont
Font
Font for the second line
Font for the second line
Padding
int
Padding around the label
Padding around the label
Spacing
int
Spacing between the first and second line of text
Spacing between the first and second line of text