本文整理汇总了C#中System.Drawing.Graphics.DrawText方法的典型用法代码示例。如果您正苦于以下问题:C# Graphics.DrawText方法的具体用法?C# Graphics.DrawText怎么用?C# Graphics.DrawText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Graphics
的用法示例。
在下文中一共展示了Graphics.DrawText方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoNoteIds
public static void DoNoteIds(this WidgetMidiList widget, FloatRect grid, Graphics g)
{
var gs = g.Save();
using (g.Clip = new Region(grid))
{
foreach (var i in widget.GetHLines(Convert.ToInt32(Math.Pow(4, 2))))
{
var r2=new FloatRect(i.XO-16,grid.Top,32,24);
g.FillEllipse(Brushes.Black,r2);
g.DrawText((i.Index / 4).ToString(),Color.White,widget.Font,r2);
}
foreach (var i in widget.GetHLines(Convert.ToInt32(Math.Pow(4, 3))))
{
var r2=new FloatRect(i.XO-16,grid.Top+32,32,24);
g.FillEllipse(Brushes.Black,r2);
g.DrawText((i.Index / 64).ToString(),Color.White,widget.Font,r2);
}
g.ResetClip();
}
g.Restore(gs);
}
示例2: DoVKeys
public static void DoVKeys(this WidgetMidiList widget, FloatRect grid, Graphics g)
{
var gs = g.Save();
// Vertical
using (var linePen = new Pen(Color.Blue, 1)) foreach (var row in widget.GetVLines(widget.LineOffset))
{
var r = new FloatRect(widget.Container.X + 12, row.Top, widget.WidthGutter, widget.LineHeight);
if (row.CanDo)
{
// Note-Number + Piano-KeyName
var str = string.Format("{0:00#} {1,-3}", row.RowIndex, MKeys[row.RowIndex]);
// create rect, then move x/y and shrinks w/h by one pixel.
var rc = new FloatRect(grid.Left, row.Top, grid.Width, widget.LineHeight).Shrink(1);
using (var sb = new SolidBrush(Color.FromArgb(24, row.IsIvory ? Color.White : Color.Black)))
if (row.IsIvory) g.FillRectangle(sb, rc);
var r2 = r.Clone();
r2.Location = r2.Location.NegX(10);
g.DrawText(str,Color.White,widget.Font,r2,StringAlignment.Near);
}
}
g.Restore(gs);
}
示例3: Draw
/// <summary>
///
/// </summary>
/// <param name="g"></param>
/// <param name="selected"></param>
internal virtual void Draw(Graphics g, bool selected)
{
if (selected)
{
if (selectedImage != null)
{
g.DrawImage(selectedImage, rectangle, rectangle, GraphicsUnit.Pixel);
}
else
{
if (selectedBackColor == selectedBackColor2)
{
using (var brush = new SolidBrush(selectedBackColor))
{
g.FillRectangle(brush, rectangle);
}
}
else
{
g.GradientFill(rectangle, selectedBackColor, selectedBackColor2, FillDirection.TopToBottom);
}
using (var pen = new Pen(selectedBorderColor))
{
g.DrawRectangle(pen, rectangle.Left, rectangle.Top, rectangle.Width - 1, rectangle.Height - 1);
}
}
}
else
{
if (image != null)
{
g.DrawImage(selectedImage, rectangle, rectangle, GraphicsUnit.Pixel);
}
else
{
if (backColor == backColor2)
{
using (var brush = new SolidBrush(backColor))
{
g.FillRectangle(brush, rectangle);
}
}
else
{
g.GradientFill(rectangle, backColor, backColor2, FillDirection.TopToBottom);
}
using (var pen = new Pen(borderColor))
{
g.DrawRectangle(pen, rectangle.Left, rectangle.Top, rectangle.Width - 1, rectangle.Height - 1);
}
}
}
g.DrawText(text, font ?? Parent.Font, selected ? selectedForeColor : foreColor, rectangle, ContentAlignmentEx.MiddleCenter);
}