If this is CodeLab created than I want src.
Mike, your wish is my command (well, a list of commands anyway....,)
This is purely an exercise in getting-it-done, and should not be read as an example of best coding practice :!:
Feel free to ask if there is anything you want explained.
/*==============================================================================
WhichSymbol.cs
© 2008 Ego Eram Reputo
Description: Draws a selectable symbol from the Webdings/Webdings fonts.
==============================================================================*/
#region UICode
int Amount1=42; // [32,255] Character
int Amount2=150; // [8,255] FontSize
int Amount3 = 1; // [1,4] Webdings Wingdings Wingdings2 Wingdings3
bool Amount4 = true; // [0,1] Show Entire Font
#endregion
void Render(Surface dst, Surface src, Rectangle rect)
{
// Init variables and settings
string symbol;
Rectangle selection = this.EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt();
Graphics g = new RenderArgs(dst).Graphics;
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
g.Clip = new Region(rect);
ColorBgra PC = (ColorBgra)EnvironmentParameters.PrimaryColor;
SolidBrush B1 = new SolidBrush(Color.FromArgb(PC.A, PC.R, PC.G, PC.<img src='http://forums.getpaint.net/public/style_emoticons/<#EMO_DIR#>/boltbait.cool.png' class='bbc_emoticon' alt='B)' />);
Font F1 = new Font("Webdings", Amount2);
Font F2 = new Font("Wingdings", Amount2);
Font F3 = new Font("Wingdings 2", Amount2);
Font F4 = new Font("Wingdings 3", Amount2);
Font F7 = new Font("Arial", 10);
Font F11 = new Font("Webdings", 16);
Font F12 = new Font("Wingdings", 16);
Font F13 = new Font("Wingdings 2", 16);
Font F14 = new Font("Wingdings 3", 16);
// Clear the canvas by copying existing image (source) to destination
for(int y = rect.Top; y < rect.Bottom; y++)
for (int x = rect.Left; x < rect.Right; x++)
dst[x,y] = src[x,y];
// draw a single symbol if we are not drawing the whole lot
if (Amount4==false)
{
switch (Amount3)
{
case 1:
symbol = Convert.ToString((char)Amount1);
g.DrawString(symbol, F1, B1, selection.Left, selection.Top);
break;
case 2:
symbol = Convert.ToString((char)Amount1);
g.DrawString(symbol, F2, B1, selection.Left, selection.Top);
break;
case 3:
symbol = Convert.ToString((char)Amount1);
g.DrawString(symbol, F3, B1, selection.Left, selection.Top);
break;
case 4:
symbol = Convert.ToString((char)Amount1);
g.DrawString(symbol, F4, B1, selection.Left, selection.Top);
break;
}
}
// Or if we are drawing them all...,
if (Amount4==true)
{
// Start with a clear the canvas
for(int y = rect.Top; y < rect.Bottom; y++)
for (int x = rect.Left; x < rect.Right; x++)
dst[x,y] = src[x,y];
// loop to write top character codes
for (int File=1; File<=15; File++)
{
symbol = "+" + Convert.ToString(File);
g.DrawString(symbol, F7, B1, selection.Left+(File*32), selection.Top+1*16);
}
// loop to draw all characters
for (int Rank=0; Rank<=14; Rank++)
{
for (int File=0; File<15; File++)
{
// Draw characters
switch (Amount3)
{
case 1:
symbol = Convert.ToString((char)(32+(Rank*15)+File));
g.DrawString(symbol, F11, B1, selection.Left+((File+1)*32), selection.Top+((Rank+1)*2*16));
break;
case 2:
symbol = Convert.ToString((char)(32+(Rank*15)+File));
g.DrawString(symbol, F12, B1, selection.Left+((File+1)*32), selection.Top+((Rank+1)*2*16));
break;
case 3:
symbol = Convert.ToString((char)(32+(Rank*15)+File));
g.DrawString(symbol, F13, B1, selection.Left+((File+1)*32), selection.Top+((Rank+1)*2*16));
break;
case 4:
symbol = Convert.ToString((char)(32+(Rank*15)+File));
g.DrawString(symbol, F14, B1, selection.Left+((File+1)*32), selection.Top+((Rank+1)*2*16));
break;
}
}
// draw the number codes
symbol = Convert.ToString(31+(Rank*15));
g.DrawString(symbol, F7, B1, selection.Left, selection.Top+5+((Rank+1)*2*16));
}
}
}