C# Graphics.MeasureString方法代码示例(c#graphics.measurestring方法的8个代码示例)

本文整理汇总了C#中System.Drawing.Graphics.MeasureString方法的典型用法代码示例。如果您正苦于以下问题:C# Graphics.MeasureString方法的具体用法?C# Graphics.MeasureString怎么用?C# Graphics.MeasureString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Drawing.Graphics的用法示例。


C# Graphics.MeasureString方法代码示例(c#graphics.measurestring方法的8个代码示例)

在下文中一共展示了Graphics.MeasureString方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: MeasureStringMin

private void MeasureStringMin(PaintEventArgs e)
{

    // Set up string.
    string measureString = "Measure String";
    Font stringFont = new Font("Arial", 16);

    // Measure string.
    SizeF stringSize = new SizeF();
    stringSize = e.Graphics.MeasureString(measureString, stringFont);

    // Draw rectangle representing size of string.
    e.Graphics.DrawRectangle(new Pen(Color.Red, 1), 0.0F, 0.0F, stringSize.Width, stringSize.Height);

    // Draw string to screen.
    e.Graphics.DrawString(measureString, stringFont, Brushes.Black, new PointF(0, 0));
}
开发者ID:.NET开发者,项目名称:System.Drawing,代码行数:17,代码来源:Graphics.MeasureString

示例2: MeasureStringSizeF

private void MeasureStringSizeF(PaintEventArgs e)
{

    // Set up string.
    string measureString = "Measure String";
    Font stringFont = new Font("Arial", 16);

    // Set maximum layout size.
    SizeF layoutSize = new SizeF(200.0F, 50.0F);

    // Measure string.
    SizeF stringSize = new SizeF();
    stringSize = e.Graphics.MeasureString(measureString, stringFont, layoutSize);

    // Draw rectangle representing size of string.
    e.Graphics.DrawRectangle(new Pen(Color.Red, 1), 0.0F, 0.0F, stringSize.Width, stringSize.Height);

    // Draw string to screen.
    e.Graphics.DrawString(measureString, stringFont, Brushes.Black, new PointF(0, 0));
}
开发者ID:.NET开发者,项目名称:System.Drawing,代码行数:20,代码来源:Graphics.MeasureString

示例3: MeasureStringWidth

private void MeasureStringWidth(PaintEventArgs e)
{

    // Set up string.
    string measureString = "Measure String";
    Font stringFont = new Font("Arial", 16);

    // Set maximum width of string.
    int stringWidth = 200;

    // Measure string.
    SizeF stringSize = new SizeF();
    stringSize = e.Graphics.MeasureString(measureString, stringFont, stringWidth);

    // Draw rectangle representing size of string.
    e.Graphics.DrawRectangle(new Pen(Color.Red, 1), 0.0F, 0.0F, stringSize.Width, stringSize.Height);

    // Draw string to screen.
    e.Graphics.DrawString(measureString, stringFont, Brushes.Black, new PointF(0, 0));
}
开发者ID:.NET开发者,项目名称:System.Drawing,代码行数:20,代码来源:Graphics.MeasureString

示例4: MeasureStringPointFFormat

private void MeasureStringPointFFormat(PaintEventArgs e)
{

    // Set up string.
    string measureString = "Measure String";
    Font stringFont = new Font("Arial", 16);

    // Set point for upper-left corner of string.
    float x = 50.0F;
    float y = 50.0F;
    PointF ulCorner = new PointF(x, y);

    // Set string format.
    StringFormat newStringFormat = new StringFormat();
    newStringFormat.FormatFlags = StringFormatFlags.DirectionVertical;

    // Measure string.
    SizeF stringSize = new SizeF();
    stringSize = e.Graphics.MeasureString(measureString, stringFont, ulCorner, newStringFormat);

    // Draw rectangle representing size of string.
    e.Graphics.DrawRectangle(new Pen(Color.Red, 1), x, y, stringSize.Width, stringSize.Height);

    // Draw string to screen.
    e.Graphics.DrawString(measureString, stringFont, Brushes.Black, ulCorner, newStringFormat);
}
开发者ID:.NET开发者,项目名称:System.Drawing,代码行数:26,代码来源:Graphics.MeasureString

示例5: MeasureStringSizeFFormat

private void MeasureStringSizeFFormat(PaintEventArgs e)
{

    // Set up string.
    string measureString = "Measure String";
    Font stringFont = new Font("Arial", 16);

    // Set maximum layout size.
    SizeF layoutSize = new SizeF(100.0F, 200.0F);

    // Set string format.
    StringFormat newStringFormat = new StringFormat();
    newStringFormat.FormatFlags = StringFormatFlags.DirectionVertical;

    // Measure string.
    SizeF stringSize = new SizeF();
    stringSize = e.Graphics.MeasureString(measureString, stringFont, layoutSize, newStringFormat);

    // Draw rectangle representing size of string.
    e.Graphics.DrawRectangle(new Pen(Color.Red, 1), 0.0F, 0.0F, stringSize.Width, stringSize.Height);

    // Draw string to screen.
    e.Graphics.DrawString(measureString, stringFont, Brushes.Black, new PointF(0, 0), newStringFormat);
}
开发者ID:.NET开发者,项目名称:System.Drawing,代码行数:24,代码来源:Graphics.MeasureString

示例6: MeasureStringWidthFormat

private void MeasureStringWidthFormat(PaintEventArgs e)
{

    // Set up string.
    string measureString = "Measure String";
    Font stringFont = new Font("Arial", 16);

    // Set maximum width of string.
    int stringWidth = 100;

    // Set string format.
    StringFormat newStringFormat = new StringFormat();
    newStringFormat.FormatFlags = StringFormatFlags.DirectionVertical;

    // Measure string.
    SizeF stringSize = new SizeF();
    stringSize = e.Graphics.MeasureString(measureString, stringFont, stringWidth, newStringFormat);

    // Draw rectangle representing size of string.
    e.Graphics.DrawRectangle(new Pen(Color.Red, 1), 0.0F, 0.0F, stringSize.Width, stringSize.Height);

    // Draw string to screen.
    e.Graphics.DrawString(measureString, stringFont, Brushes.Black, new PointF(0, 0), newStringFormat);
}
开发者ID:.NET开发者,项目名称:System.Drawing,代码行数:24,代码来源:Graphics.MeasureString

示例7: MeasureStringSizeFFormatInts

private void MeasureStringSizeFFormatInts(PaintEventArgs e)
{

    // Set up string.
    string measureString = "Measure String";
    Font stringFont = new Font("Arial", 16);

    // Set maximum layout size.
    SizeF layoutSize = new SizeF(100.0F, 200.0F);

    // Set string format.
    StringFormat newStringFormat = new StringFormat();
    newStringFormat.FormatFlags = StringFormatFlags.DirectionVertical;

    // Measure string.
    int charactersFitted;
    int linesFilled;
    SizeF stringSize = new SizeF();
    stringSize = e.Graphics.MeasureString(measureString, stringFont, layoutSize, newStringFormat, out charactersFitted, out linesFilled);

    // Draw rectangle representing size of string.
    e.Graphics.DrawRectangle(new Pen(Color.Red, 1), 0.0F, 0.0F, stringSize.Width, stringSize.Height);

    // Draw string to screen.
    e.Graphics.DrawString(measureString, stringFont, Brushes.Black, new PointF(0, 0), newStringFormat);

    // Draw output parameters to screen.
    string outString = "chars " + charactersFitted + ", lines " + linesFilled;
    e.Graphics.DrawString(outString, stringFont, Brushes.Black, new PointF(100, 0));
}
开发者ID:.NET开发者,项目名称:System.Drawing,代码行数:30,代码来源:Graphics.MeasureString

示例8: Main

//引入命名空间
using System;
using System.Drawing;
using System.Windows.Forms;
   
class SysInfoColumns: Form
{
     public static void Main()
     {
          Application.Run(new SysInfoColumns());
     }
     public SysInfoColumns()
     {
     }
     protected override void OnPaint(PaintEventArgs pea)
     {
          Graphics grfx  = pea.Graphics;
          Brush    brush = new SolidBrush(ForeColor);
          SizeF    sizef;
          float    cxCol, y = 0;
          int      cySpace;
   
          sizef   = grfx.MeasureString("ArrangeStartingPosition ", Font);
          cxCol   = sizef.Width;
          cySpace = Font.Height;
   
          grfx.DrawString("ArrangeDirection", Font, brush, 0, y);
          grfx.DrawString(SystemInformation.ArrangeDirection.ToString(), 
                          Font, brush, cxCol, y);
          y += cySpace;
   
          grfx.DrawString("ArrangeStartingPosition", Font, brush, 0, y);
          grfx.DrawString(
               SystemInformation.ArrangeStartingPosition.ToString(), 
               Font, brush, cxCol, y);
          y += cySpace;
   
          grfx.DrawString("BootMode", Font, brush, 0, y);
          grfx.DrawString(SystemInformation.BootMode.ToString(), 
                          Font, brush, cxCol, y);
          y += cySpace;
   
          grfx.DrawString("Border3DSize", Font, brush, 0, y);
          grfx.DrawString(SystemInformation.Border3DSize.ToString(), 
                          Font, brush, cxCol, y);
          y += cySpace;
   
          grfx.DrawString("BorderSize", Font, brush, 0, y);
          grfx.DrawString(SystemInformation.BorderSize.ToString(), 
                          Font, brush, cxCol, y);
          y += cySpace;
   
          grfx.DrawString("CaptionButtonSize", Font, brush, 0, y);
          grfx.DrawString(SystemInformation.CaptionButtonSize.ToString(), 
                          Font, brush, cxCol, y);

     }
}
开发者ID:C#程序员,项目名称:System.Drawing,代码行数:58,代码来源:Graphics.MeasureString

本文标签属性:

示例:示例英文

代码:代码零九

Graphics:graphics620相当于什么显卡

MeasureString:MeasureString

上一篇:切削工具刀具种类有哪些(刀具的发展历史)
下一篇:世界上最严重的中毒事件发生在哪里?(山东一饭店多人出现中毒现象,到底是怎么一回事?)(世界上最严重的中毒事件)

为您推荐