All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
PHP实例:PHP中使用的运算符号_[PHP教程]
5种易犯的PHP数据库错误_[PHP教程]
怎样在Web开发中完美控制IE标题栏_[Asp.Net教程]
ajax和asp.net的配置文件_[Asp.Net教程]
使用Forms,Authentication实现用户注册、登录,(三)用户实体替换_[Asp.Net教程]
利用C#实现分布式数据库查询_[Asp.Net教程]
轻松掌握Ajax.net系列教程十四:使用CalendarExtender_[Asp.Net教程]
实例:尽可能写友好的javascript代码_JavaScript技术_编程技术
C#中程序调试之开始执行
C#关于正则表达式匹配无异常资源耗尽的解决方案_.net资料_编程技术
Reading number is top 10 pictures
The money of more than 100 countries and regions19
两张抽象画
这才是真正的人体艺术4
西游四格漫画(二)
徐若瑄展示美丽胸围3
Sora aoi possession photo1
China's first snake village3
From China fortress sora aoi2
2012 national geographic daily picture7
So beauty, will let you spray blood4
Download software ranking
Sora aoi, the maid, students' uniforms
Tram sex maniac 2 (H) rar bag9
ASP.NET.2.0.XML.高级编程(第3版)
中国结婚习俗实录
linux初级教程
Tram sex maniac 2 (H) rar bag1
Unix video tutorial4
好色的外科大夫
Sora aoi's film--cangkong_Blue.Sky
WebService在.NET中的实战应用教学视频 → 第2集
qq published in(发表于) 2014/7/11 9:16:45 Edit(编辑)
c#中GDI+图形图像:GDI+中的画笔使用方法

c#中GDI+图形图像:GDI+中的画笔使用方法

c#中GDI+图形图像:GDI+中的画笔使用方法|实例

GDI+中的画笔

闭合的形状(例如,矩形或椭圆)由轮廓和内部组成。用钢笔绘制出轮廓,并用画笔填充其内部。GDI+提供了几种填充闭合形状内部的画笔类:SolidBrush、HatchBrush、TextureBrush、LinearGradientBrush和PathGradientBrush。所有这些类都是从Brush类继承的。

1.实心画笔

使用实心画笔时,需要使用SolidBrush类,该类主要用来使用定义的单色画笔填充图形形状,如矩形、椭圆、扇形、多边形和封闭路径等。

示例

实心画笔的使用

本示例中,当程序运行时,单击【实心画笔】按钮,在窗体中绘制一个使用指定颜色填充的椭圆。示例运行结果如图1所示。



图1 实心画笔的使用

Form1窗体中,在【实心画笔】按钮的Click事件中分别声明Graphics类和SolidBrush类的两个实例对象,调用Graphics对象的FillEllipse方法在窗体中绘制一个使用指定颜色填充的椭圆。【实心画笔】按钮的Click事件代码如下:

private void button1_Click(object sender, EventArgs e)

{

Graphics graphics = this.CreateGraphics();

SolidBrush mySolidBrush = new SolidBrush(Color.Green);

graphics.FillEllipse(mySolidBrush, 70, 20, 100, 50);

}

完整程序代码如下:

★ ★★★★Form1.cs窗体代码文件完整程序代码★★★★★

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

namespace _6_09

{

public partial class Form1 : Form

{

public Form1()

{

InitializeComponent();

}

private void button1_Click(object sender, EventArgs e)

{

Graphics graphics = this.CreateGraphics();

SolidBrush mySolidBrush = new SolidBrush(Color.Green);

graphics.FillEllipse(mySolidBrush, 70, 20, 100, 50);

}

}

}

★ ★★★★Form1..Designer.cs窗体代码文件完整程序代码★★★★★

namespace _6_09

{

partial class Form1

{

///



/// 必需的设计器变量。

///


private System.ComponentModel.IContainer components = null;

///

/// 清理所有正在使用的资源。

///


/// 如果应释放托管资源,为 true;否则为 false。

protected override void Dispose(bool disposing)

{

if (disposing && (components != null))

{

components.Dispose();

}

base.Dispose(disposing);

}

#region Windows 窗体设计器生成的代码

///

/// 设计器支持所需的方法 - 不要

/// 使用代码编辑器修改此方法的内容。

///


private void InitializeComponent()

{

this.button1 = new System.Windows.Forms.Button();

this.SuspendLayout();

//

// button1

//

this.button1.Location = new System.Drawing.Point(82, 83);

this.button1.Name = "button1";

this.button1.Size = new System.Drawing.Size(75, 23);

this.button1.TabIndex = 0;

this.button1.Text = "实心画笔";

this.button1.UseVisualStyleBackColor = true;

this.button1.Click += new System.EventHandler(this.button1_Click);

//

// Form1

//

this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);

this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;

this.ClientSize = new System.Drawing.Size(238, 130);

this.Controls.Add(this.button1);

this.MaximizeBox = false;

this.Name = "Form1";

this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;

this.Text = "Form1";

this.ResumeLayout(false);

}

#endregion

private System.Windows.Forms.Button button1;

}

}

★ ★★★★Program.cs主程序文件完整程序代码★★★★★

using System;

using System.Collections.Generic;

using System.Windows.Forms;

namespace _6_09

{

static class Program

{

///

/// 应用程序的主入口点。

///


[STAThread]

static void Main()

{

Application.EnableVisualStyles();

Application.SetCompatibleTextRenderingDefault(false);

Application.Run(new Form1());

}

}

}

2.阴影画笔

使用阴影画笔时,需要使用HatchBrush类,该类位于System.Drawing.Drawing2D命名空间内,它主要使用阴影样式、前景色和背景色定义矩形画笔。


添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.