當前位置: 首頁>>代碼示例>>C#>>正文


C# Graphics.DrawString方法代碼示例

本文整理匯總了C#中System.Drawing.Graphics.DrawString方法的典型用法代碼示例。如果您正苦於以下問題:C# Graphics.DrawString方法的具體用法?C# Graphics.DrawString怎麽用?C# Graphics.DrawString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Drawing.Graphics的用法示例。


在下文中一共展示了Graphics.DrawString方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: DrawStringFloatFormat

public void DrawStringFloatFormat(PaintEventArgs e)
{
             
    // Create string to draw.
    String drawString = "Sample Text";
             
    // Create font and brush.
    Font drawFont = new Font("Arial", 16);
    SolidBrush drawBrush = new SolidBrush(Color.Black);
             
    // Create point for upper-left corner of drawing.
    float x = 150.0F;
    float y =  50.0F;
             
    // Set format of string.
    StringFormat drawFormat = new StringFormat();
    drawFormat.FormatFlags = StringFormatFlags.DirectionVertical;
             
    // Draw string to screen.
    e.Graphics.DrawString(drawString, drawFont, drawBrush, x, y, drawFormat);
}
開發者ID:.NET開發者,項目名稱:System.Drawing,代碼行數:21,代碼來源:Graphics.DrawString

示例2: DrawStringRectangleFFormat

public void DrawStringRectangleFFormat(PaintEventArgs e)
{
             
    // Create string to draw.
    String drawString = "Sample Text";
             
    // Create font and brush.
    Font drawFont = new Font("Arial", 16);
    SolidBrush drawBrush = new SolidBrush(Color.Black);
             
    // Create rectangle for drawing.
    float x = 150.0F;
    float y = 150.0F;
    float width = 200.0F;
    float height = 50.0F;
    RectangleF drawRect = new RectangleF(x, y, width, height);
             
    // Draw rectangle to screen.
    Pen blackPen = new Pen(Color.Black);
    e.Graphics.DrawRectangle(blackPen, x, y, width, height);
             
    // Set format of string.
    StringFormat drawFormat = new StringFormat();
    drawFormat.Alignment = StringAlignment.Center;
             
    // Draw string to screen.
    e.Graphics.DrawString(drawString, drawFont, drawBrush, drawRect, drawFormat);
}
開發者ID:.NET開發者,項目名稱:System.Drawing,代碼行數:28,代碼來源:Graphics.DrawString

示例3: DrawStringFloat

public void DrawStringFloat(PaintEventArgs e)
{
             
    // Create string to draw.
    String drawString = "Sample Text";
             
    // Create font and brush.
    Font drawFont = new Font("Arial", 16);
    SolidBrush drawBrush = new SolidBrush(Color.Black);
             
    // Create point for upper-left corner of drawing.
    float x = 150.0F;
    float y = 150.0F;
             
    // Draw string to screen.
    e.Graphics.DrawString(drawString, drawFont, drawBrush, x, y);
}
開發者ID:.NET開發者,項目名稱:System.Drawing,代碼行數:17,代碼來源:Graphics.DrawString

示例4: DrawStringRectangleF

public void DrawStringRectangleF(PaintEventArgs e)
{
             
    // Create string to draw.
    String drawString = "Sample Text";
             
    // Create font and brush.
    Font drawFont = new Font("Arial", 16);
    SolidBrush drawBrush = new SolidBrush(Color.Black);
             
    // Create rectangle for drawing.
    float x = 150.0F;
    float y = 150.0F;
    float width = 200.0F;
    float height = 50.0F;
    RectangleF drawRect = new RectangleF(x, y, width, height);
             
    // Draw rectangle to screen.
    Pen blackPen = new Pen(Color.Black);
    e.Graphics.DrawRectangle(blackPen, x, y, width, height);
             
    // Draw string to screen.
    e.Graphics.DrawString(drawString, drawFont, drawBrush, drawRect);
}
開發者ID:.NET開發者,項目名稱:System.Drawing,代碼行數:24,代碼來源:Graphics.DrawString

示例5: DrawStringPointF

public void DrawStringPointF(PaintEventArgs e)
{
             
    // Create string to draw.
    String drawString = "Sample Text";
             
    // Create font and brush.
    Font drawFont = new Font("Arial", 16);
    SolidBrush drawBrush = new SolidBrush(Color.Black);
             
    // Create point for upper-left corner of drawing.
    PointF drawPoint = new PointF(150.0F, 150.0F);
             
    // Draw string to screen.
    e.Graphics.DrawString(drawString, drawFont, drawBrush, drawPoint);
}
開發者ID:.NET開發者,項目名稱:System.Drawing,代碼行數:16,代碼來源:Graphics.DrawString

示例6: Main

//引入命名空間
using System;
using System.Drawing;
using System.Windows.Forms;
   
class TwoPaintHandlers
{
     public static void Main()
     {
          Form form      = new Form();
          form.Text      = "Two Paint Handlers";
          form.BackColor = Color.White;
          form.Paint    += new PaintEventHandler(PaintHandler1);
          form.Paint    += new PaintEventHandler(PaintHandler2);
   
          Application.Run(form);
     }
     static void PaintHandler1(object objSender, PaintEventArgs pea)
     {
          Form     form = (Form)objSender;
          Graphics graphics = pea.Graphics;
   
          graphics.DrawString("First Paint Event Handler", form.Font, 
                          Brushes.Black, 0, 0);
     }
     static void PaintHandler2(object objSender, PaintEventArgs pea)
     {
          Form     form = (Form)objSender;
          Graphics graphics = pea.Graphics;
   
          graphics.DrawString("Second Paint Event Handler", form.Font, 
                          Brushes.Black, 0, 100);
     }
}
開發者ID:C#程序員,項目名稱:System.Drawing,代碼行數:34,代碼來源:Graphics.DrawString

示例7: DrawStringPointFFormat

public void DrawStringPointFFormat(PaintEventArgs e)
{
             
    // Create string to draw.
    String drawString = "Sample Text";
             
    // Create font and brush.
    Font drawFont = new Font("Arial", 16);
    SolidBrush drawBrush = new SolidBrush(Color.Black);
             
    // Create point for upper-left corner of drawing.
    PointF drawPoint = new PointF(150.0F, 50.0F);
             
    // Set format of string.
    StringFormat drawFormat = new StringFormat();
    drawFormat.FormatFlags = StringFormatFlags.DirectionVertical;
             
    // Draw string to screen.
    e.Graphics.DrawString(drawString, drawFont, drawBrush, drawPoint, drawFormat);
}
開發者ID:.NET開發者,項目名稱:System.Drawing,代碼行數:20,代碼來源:Graphics.DrawString


注:本文中的System.Drawing.Graphics.DrawString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。