当前位置: 首页>>代码示例>>C#>>正文


C# Graphics.FillRectangle方法代码示例

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


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

示例1: FillRectangleRectangle

private void FillRectangleRectangle(PaintEventArgs e)
{

    // Create solid brush.
    SolidBrush blueBrush = new SolidBrush(Color.Blue);

    // Create rectangle.
    Rectangle rect = new Rectangle(0, 0, 200, 200);

    // Fill rectangle to screen.
    e.Graphics.FillRectangle(blueBrush, rect);
}
开发者ID:.NET开发者,项目名称:System.Drawing,代码行数:12,代码来源:Graphics.FillRectangle

示例2: FillRectangleRectangleF

private void FillRectangleRectangleF(PaintEventArgs e)
{

    // Create solid brush.
    SolidBrush blueBrush = new SolidBrush(Color.Blue);

    // Create rectangle.
    RectangleF rect = new RectangleF(0.0F, 0.0F, 200.0F, 200.0F);

    // Fill rectangle to screen.
    e.Graphics.FillRectangle(blueBrush, rect);
}
开发者ID:.NET开发者,项目名称:System.Drawing,代码行数:12,代码来源:Graphics.FillRectangle

示例3: FillRectangleInt

private void FillRectangleInt(PaintEventArgs e)
{

    // Create solid brush.
    SolidBrush blueBrush = new SolidBrush(Color.Blue);

    // Create location and size of rectangle.
    int x = 0;
    int y = 0;
    int width = 200;
    int height = 200;

    // Fill rectangle to screen.
    e.Graphics.FillRectangle(blueBrush, x, y, width, height);
}
开发者ID:.NET开发者,项目名称:System.Drawing,代码行数:15,代码来源:Graphics.FillRectangle

示例4: FillRectangleFloat

private void FillRectangleFloat(PaintEventArgs e)
{

    // Create solid brush.
    SolidBrush blueBrush = new SolidBrush(Color.Blue);

    // Create location and size of rectangle.
    float x = 0.0F;
    float y = 0.0F;
    float width = 200.0F;
    float height = 200.0F;

    // Fill rectangle to screen.
    e.Graphics.FillRectangle(blueBrush, x, y, width, height);
}
开发者ID:.NET开发者,项目名称:System.Drawing,代码行数:15,代码来源:Graphics.FillRectangle

示例5: OnPaint

//引入命名空间
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

public class Form1 : Form {

    protected override void OnPaint(PaintEventArgs e) {
    Graphics g = e.Graphics;
    g.FillRectangle(Brushes.White, this.ClientRectangle);
    Font f = new Font("Times New Roman", 12);
    Font bf = new Font(f, FontStyle.Bold);
    StringFormat sf = new StringFormat();
    float[] ts = { 10.0f, 70.0f, 100.0f, 90.0f };
    sf.SetTabStops(0.0f, ts);

    string s1 = "\tA\tAA\tAAA\tAAAA";
    string s2 = "\tAAAA\tAAA\tAA\tA";
    string s3 = "\tAAAAAAAA\tAAAAAAA\tAAAAAA\tAAAAA\n\tAAAA\tAAA\tAA\tAA";

    g.DrawString(s1, bf, Brushes.Black, 20, 20, sf);
    g.DrawString(s2, f, Brushes.Blue, 20, 20 + bf.Height, sf);
    g.DrawString(s3, f, Brushes.Blue, 20,
                      20 + bf.Height + f.Height, sf);

    f.Dispose();
    bf.Dispose();
    }
    public static void Main() {
        Application.Run(new Form1());
    }
}
开发者ID:C#程序员,项目名称:System.Drawing,代码行数:36,代码来源:Graphics.FillRectangle


注:本文中的System.Drawing.Graphics.FillRectangle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。