本文整理汇总了C#中Microsoft.SPOT.Bitmap.DrawText方法的典型用法代码示例。如果您正苦于以下问题:C# Bitmap.DrawText方法的具体用法?C# Bitmap.DrawText怎么用?C# Bitmap.DrawText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.SPOT.Bitmap
的用法示例。
在下文中一共展示了Bitmap.DrawText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Render
//private Bitmap img = new Bitmap(Resources.GetBytes(Resources.BinaryResources.AnalogTicksOutside),
// Bitmap.BitmapImageType.Gif);
//private Bitmap img = new Bitmap(Resources.GetBytes(Resources.BinaryResources.AnalogTicksInside),
// Bitmap.BitmapImageType.Gif);
public override void Render(Bitmap screen)
{
if (_screen == null) _screen = screen;
screen.DrawImage(0, 0, img, 0, 0, img.Width, img.Height);
var text = "AGENT";
Point textLocation = new Point(
AGENT.Center.X - (drawing.MeasureString(text, smallFont) / 2), AGENT.Center.Y - 25);
screen.DrawText(text, smallFont, Color.White, textLocation.X, textLocation.Y);
var date = Settings.Now.ToString(CultureInfo.CurrentUICulture.DateTimeFormat.MonthDayPattern);
; //time.MonthNameShort + " " + time.Day;
Point dateLocation = new Point(
AGENT.Center.X - (drawing.MeasureString(date, smallFont) / 2), AGENT.Center.Y + 20);
screen.DrawText(date, smallFont, Color.White, dateLocation.X, dateLocation.Y);
//draw our hands
drawing.PaintSkinnyHands(screen, Settings.Now, AGENT.Center);
drawing.DrawTray(screen, _notificationProvider, smallFont);
}
示例2: Render
public void Render(Bitmap screen, bool military, ArrayList forecast)
{
DateTime now = DateTime.Now;
string display = "";
string hour, minute = now.Minute.ToString();
if (military)
{
hour = now.Hour.ToString();
}
else
{
int h = now.Hour;
if (h >= 12) h = h - 12;
if (h == 0) h = 12;
hour = h.ToString();
}
if (minute.Length == 1) minute = "0" + minute;
display = hour + ":" + minute;
screen.DrawLine(Color.White, 2, 0, Program.AgentSize/2, Program.AgentSize, Program.AgentSize/2);
int left = Program.AgentSize - Program.MeasureString(display, bigfont);
screen.DrawText(display, bigfont, Color.White, left, (Program.AgentSize/2) +2);
string dow = System.Globalization.DateTimeFormatInfo.CurrentInfo.DayNames[(int) now.DayOfWeek];
screen.DrawText(dow.ToString(), font, Color.White, 5, 10);
string date = System.Globalization.DateTimeFormatInfo.CurrentInfo.MonthNames[(int) now.Month];
date = date + " " + now.Day.ToString();
screen.DrawText(date, font, Color.White, 5, 30);
}
示例3: Render
public void Render(Bitmap screen, bool military, ArrayList forecast)
{
screen.DrawLine(Color.White, 2, 0, Program.AgentSize / 2, Program.AgentSize, Program.AgentSize / 2);
DateTime now = DateTime.Now;
int counter = (int) now.DayOfWeek;
counter++;
int left = buffer;
Forecast nowForecast = null;
bool needsDate = false;
DateTime lastUpdated = DateTime.Now;
for (int x = 0; x <= days; x++)
{
string dayName = System.Globalization.DateTimeFormatInfo.CurrentInfo.DayNames[counter];
if (dayName.Length >= 3) dayName = dayName.Substring(0, 3);
int width = Program.MeasureString(dayName, font);
screen.DrawText(dayName, font, Color.White, left, top);
if (forecast != null && forecast.Count > 0)
{
Forecast current = null;
var startDate = now.Date.AddDays(x);
foreach (Forecast f in forecast)
{
if (f.Date.Year == now.Date.Year && f.Date.Month == now.Date.Month && f.Date.Day == now.Date.Day)
nowForecast = f;
if (startDate.Year == f.Date.Year && startDate.Month == f.Date.Month && startDate.Day == f.Date.Day)
{
Debug.Print("Found match");
current = f;
break;
}
}
if (current != null)
{
needsDate = true;
screen.DrawText(current.Current.ToString(), font, Color.White, left+4, top+font.Height + 2);
lastUpdated = current.LastUpdated;
}
}
counter++;
if (counter > 6) counter = 0;
left += width + buffer;
}
if (nowForecast != null)
{
string display = nowForecast.Current.ToString();
int forecastLeft = Program.AgentSize - Program.MeasureString(display, bigfont);
screen.DrawText(display, bigfont, Color.White, forecastLeft, (Program.AgentSize / 2) + 2);
needsDate = true;
lastUpdated = nowForecast.LastUpdated;
}
if (needsDate)
{
screen.DrawText(lastUpdated.ToString(), smallFont, Color.White, 3, (Program.AgentSize / 2)-smallFont.Height-1);
}
}
示例4: DrawItem
protected override void DrawItem(Bitmap screen, int x, int y, int width, int height, ref int index, object it, Style cStyle)
{
bool selected = _selIndex == index;
RadioStationItem item = (RadioStationItem)it;
if (selected)
screen.DrawRectangle(Colors.Blue, 0, x, y, width, height, 0, 0,
cStyle.ListBoxSelectedItemBack1, x, y,
cStyle.ListBoxSelectedItemBack2, x, y + height, Enabled ? (ushort)256 : (ushort)128);
Color textColor = item.IsConnecting ? Colors.Yellow : (item.IsPlaying ? Colors.LightGreen : (Enabled ? (selected ? cStyle.TextBoxPressedTextColor : cStyle.TextBoxEnabledTextColor) : cStyle.TextBoxDisabledTextColor));
screen.DrawText(item.Name, nameFont, textColor, x + 5, y + 2);
screen.DrawText(item.Address, textFont, textColor, x + 5, y + 2 + nameFont.Height + 2);
}
示例5: Run
public override void Run()
{
try
{
using (var bmp = new Bitmap(Dimensions.Width, Dimensions.Height))
{
const string text = "Hello World";
int textWidth, textHeight;
Font font = Resources.GetFont(Resources.FontResources.ninabd18ppem);
font.ComputeExtent(text, out textWidth, out textHeight);
int textX = (Dimensions.Width - textWidth)/2;
var rand = new Random();
for (int x = 0; x < 3; x++)
{
int baseColor = rand.Next(0xffff);
for (int i = 0; i < Dimensions.Height; i++)
{
bmp.Clear();
bmp.DrawText(text, font, (Color) (((255 - i) << 16) | baseColor), textX, i);
bmp.Flush();
}
}
}
Pass = true;
}
catch (Exception e)
{
UnexpectedException(e);
}
}
示例6: DrawAlignedText
/// <summary>
/// Draw text in a vertical and horizontal position
/// When "align" is "Center" then "margin" is ignored.
/// Also when "vAlign" is "Middle" then "vMargin" is ignored.
/// </summary>
/// <param name="screen"></param>
/// <param name="color"></param>
/// <param name="font"></param>
/// <param name="inString"></param>
/// <param name="align"></param>
/// <param name="margin"></param>
/// <param name="vAlign"></param>
/// <param name="vMargin"></param>
public void DrawAlignedText(Bitmap screen, Color color, Font font, string inString, HAlign align, int margin, VAlign vAlign, int vMargin)
{
Point p = new Point();
var stringWidth = MeasureString(inString, font);
var stringHeight = 0;
var textAreaLength = 0;
switch (align)
{
case HAlign.Left:
p.X = margin + 1;
break;
case HAlign.Center:
textAreaLength = screen.Width - (margin * 2);
p.X = margin + ((textAreaLength - stringWidth) / 2);
break;
case HAlign.Right:
textAreaLength = screen.Width - margin;
p.X = textAreaLength - stringWidth;
break;
}
stringHeight = font.Height;
switch (vAlign)
{
case VAlign.Top:
p.Y = vMargin + 1;
break;
case VAlign.Middle:
p.Y= (screen.Height / 2) - (stringHeight / 2);
break;
case VAlign.Bottom:
p.Y = screen.Height - stringHeight - vMargin;
break;
}
screen.DrawText(inString, font, color, p.X, p.Y);
}
示例7: Render
public void Render(Bitmap screen)
{
screen.DrawText(
Settings.Now.ToString(DateTimeFormatInfo.CurrentInfo.ShortTimePattern),
font,
Color.White,
0,
0
);
}
示例8: Render
public void Render(Bitmap screen, bool military, ArrayList forecast)
{
var time = new Time();
time.CurrentTime = DateTime.Now;
screen.DrawImage(0, 0, img, 0, 0, img.Width, img.Height);
var text = "agent";
Point textLocation = new Point(
Program.Center.X - (Program.MeasureString(text, font) / 2), Program.Center.Y - 25);
screen.DrawText(text, font, Color.White, textLocation.X, textLocation.Y);
var date = time.MonthNameShort + " " + time.Day;
Point dateLocation = new Point(
Program.Center.X - (Program.MeasureString(date, font) / 2), Program.Center.Y + 20);
screen.DrawText(date, font, Color.White, dateLocation.X, dateLocation.Y);
PaintSkinnyHands(screen, time);
}
示例9: Main
public static void Main()
{
IPAddress Server = IPAddress.Parse("1.2.3.4");
string SharedSecret = "SharedSecret";
string UserName = "UserName";
string UserPassword = "UserPassword";
Bitmap screen = new Bitmap(320, 240); // emulator display size
Font font = Resources.GetFont(Resources.FontResources.NinaB);
RadiusResult result;
using (Client client = new Client(Server, SharedSecret))
{
client.AddAttribute(AttributeType.UserName, UserName);
client.AddAttribute(AttributeType.UserPassword, UserPassword);
result = client.Authenticate();
};
switch (result)
{
case RadiusResult.LocalError:
screen.DrawText("Result: LocalError", font, ColorUtility.ColorFromRGB(0xff, 0, 0), 50, 50);
break;
case RadiusResult.NoResponse:
screen.DrawText("Result: NoResponse", font, ColorUtility.ColorFromRGB(0xff, 0, 0), 50, 50);
break;
case RadiusResult.AccessAccept:
screen.DrawText("Result: AccessAccept", font, ColorUtility.ColorFromRGB(0, 0xff, 0), 50, 50);
break;
case RadiusResult.AccessReject:
screen.DrawText("Result: AccessReject", font, ColorUtility.ColorFromRGB(0xff, 0, 0), 50, 50);
break;
case RadiusResult.NotImplemented:
screen.DrawText("Result: NotImplemented", font, ColorUtility.ColorFromRGB(0, 0, 0xff), 50, 50);
break;
}
screen.Flush();
Thread.Sleep(Timeout.Infinite);
}
示例10: Render
public override void Render(Bitmap screen)
{
if (base._screen == null) _screen = screen;
DateTime now = DateTime.Now;
string display = "";
string hour, minute = now.Minute.ToString();
if (Settings.TimeInISONotatation)
{
hour = now.Hour.ToString();
}
else
{
int h = now.Hour;
if (h >= 12) h = h - 12;
if (h == 0) h = 12;
hour = h.ToString();
}
if (minute.Length == 1) minute = "0" + minute;
display = hour + ":" + minute;
screen.DrawLine(Color.White, 2, 0, AGENT.Contrib.Device.Size/2, AGENT.Contrib.Device.Size, AGENT.Contrib.Device.Size/2);
int left = AGENT.Contrib.Device.Size - base.drawing.MeasureString(display, bigfont);
screen.DrawText(display, bigfont, Color.White, left, (AGENT.Contrib.Device.Size/2) + 2);
string dow = System.Globalization.DateTimeFormatInfo.CurrentInfo.DayNames[(int) now.DayOfWeek];
screen.DrawText(dow.ToString(), font, Color.White, 5, 15);
string date = System.Globalization.DateTimeFormatInfo.CurrentInfo.MonthNames[(int) now.Month];
date = date + " " + now.Day.ToString();
screen.DrawText(date, font, Color.White, 5, 35);
drawing.DrawTray(screen, _notificationProvider, smallFont);
}
示例11: Main
public static void Main()
{
// initialize display buffer
_display = new Bitmap(Bitmap.MaxWidth, Bitmap.MaxHeight);
// sample "hello world" code
_display.Clear();
Font fontNinaB = Resources.GetFont(Resources.FontResources.NinaB);
_display.DrawText("Waiting.", fontNinaB, Color.White, 10, 64);
_display.Flush();
var connection = new Connection("COM3", new CSVChannel());
connection.Open();
connection.OnReceived+=connection_OnReceived;
// go to sleep; all further code should be timer-driven or event-driven
Thread.Sleep(Timeout.Infinite);
}
示例12: ToBitmap
/// <summary>
/// Converts this ByteMatrix to a black and white bitmap.
/// </summary>
/// <returns>A black and white bitmap converted from this ByteMatrix.</returns>
public Bitmap ToBitmap(BarcodeFormat format, String content)
{
int width = Width;
int height = Height;
bool outputContent = !(content == null || content.Length == 0) && (format == BarcodeFormat.CODE_39 ||
format == BarcodeFormat.CODE_128 ||
format == BarcodeFormat.EAN_13 ||
format == BarcodeFormat.EAN_8 ||
format == BarcodeFormat.CODABAR ||
format == BarcodeFormat.ITF ||
format == BarcodeFormat.UPC_A);
int emptyArea = outputContent ? 16 : 0;
// create the bitmap and lock the bits because we need the stride
// which is the width of the image and possible padding bytes
var bmp = new Bitmap(width, height);
for (int y = 0; y < height - emptyArea; y++)
{
for (var x = 0; x < width; x++)
{
var color = this[x, y] ? Color.Black : Color.White;
bmp.SetPixel(x, y, color);
}
}
if (outputContent)
{
//switch (format)
//{
// case BarcodeFormat.EAN_8:
// if (content.Length < 8)
// content = OneDimensionalCodeWriter.CalculateChecksumDigitModulo10(content);
// content = content.Insert(4, " ");
// break;
// case BarcodeFormat.EAN_13:
// if (content.Length < 13)
// content = OneDimensionalCodeWriter.CalculateChecksumDigitModulo10(content);
// content = content.Insert(7, " ");
// content = content.Insert(1, " ");
// break;
//}
bmp.DrawText(content, null, Color.Black, width / 2, height - 14);
}
return bmp;
}
示例13: DrawString
static public void DrawString(Font font, String text, int x, int y, UInt32 text_color, UInt32 back_color)
{
int width = 0;
for (int i = 0; i < text.Length; i++)
{
width+=font.CharWidth((char)(text[i]));
}
Bitmap bmp = new Bitmap(width, font.Height);
bmp.DrawRectangle((Microsoft.SPOT.Presentation.Media.Color)back_color, 100, 0, 0, width, font.Height, 0, 0, (Microsoft.SPOT.Presentation.Media.Color)back_color, 0, 0, (Microsoft.SPOT.Presentation.Media.Color)back_color, 0, 0, 0);
bmp.DrawText(text, font, (Microsoft.SPOT.Presentation.Media.Color)text_color, 0, 0);
Image imge = new Image(bmp); // Note: Maybe out of memory here
DrawImage(imge, x, y);
bmp.Dispose();
bmp = null;
imge.Dispose();
imge = null;
}
示例14: Render
public void Render(Bitmap screen, Font font, int height, int width, int borderBuffer, Color ForegroundColor, Color BackgroundColor)
{
if (Text != null && Text != "")
{
Color forColor = ForegroundColor;
Color bColor = BackgroundColor;
if (Selected)
{
forColor = BackgroundColor;
bColor = ForegroundColor;
}
screen.DrawRectangle(forColor, 1, Point.X, Point.Y, width + borderBuffer * 2,
height + borderBuffer * 2, 0, 0, bColor, 0, 0,
bColor, 0, 0, 255);
screen.DrawText(Text, font, forColor, Point.X + borderBuffer, Point.Y + borderBuffer);
}
}
示例15: Main
/// <summary>
/// A demonstration as to how to handle multiple button presses at the same time
/// </summary>
public static void Main()
{
ButtonHelper.ButtonSetup = new Buttons[]{ Buttons.TopRight, Buttons.MiddleRight, Buttons.BottomRight,};
ButtonHelper.Current.OnButtonPress += Current_OnButtonPress;
buttonStates = new Hashtable();
buttonStates.Add(Buttons.TopRight, ButtonDirection.Up);
buttonStates.Add(Buttons.MiddleRight, ButtonDirection.Up);
buttonStates.Add(Buttons.BottomRight, ButtonDirection.Up);
// initialize display buffer
_display = new Bitmap(Bitmap.MaxWidth, Bitmap.MaxHeight);
// sample "hello world" code
_display.Clear();
_display.DrawText("Hello world.", fontNinaB, Color.White, 10, 64);
_display.Flush();
// go to sleep; all further code should be timer-driven or event-driven
Thread.Sleep(Timeout.Infinite);
}