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

Reading number is top 10 articles
PHP中的sprintf()函数的学习研究笔记_php资料_编程技术
ASP.Net中保护自定义的服务器控件_.net资料_编程技术
Web,Service的几个很重要的概念_[Asp.Net教程]
MYSQL中如何设列的默认值为Now()_mssql学习_编程技术
AspNetPager分页控件--使用方法_.net资料_编程技术
SQL2000 关于 Java JDBC 驱动的安装和设定_[SQL Server教程]
在MySQL中定义外键_php资料_编程技术
JS开发字典探测用户名或密码工具_JavaScript技术_编程技术
C#教程:C#发展历程以及特点
ASP.NET中文件上传下载方法集合_[Asp.Net教程]
Reading number is top 10 pictures
俞敏洪在清华终于说了实话
30 beautiful school beauty4
Distribution of wealth in China survey status report
Hunan road lawenforcement vehicle pursue overload car caused the car turn and man is died
A resort photographed beautiful young woman change clothes process vomiting blood1
Startling Russian girl blind date scene3
全球清廉国家排行
The little woman's bright wire2
美丽的少女1
玩手机对身体不好
Download software ranking
XML+Web+Service开发教程
网络管理员第三版
Ashlynn Video2
Love the forty days
Such love down(擒爱记)
WebService在.NET中的实战应用教学视频 → 第1集
Tram sex maniac 2 (H) rar bag14
打鸟视频
linux初级教程
双旗镇刀客A
qq published in(发表于) 2014/7/11 9:16:43 Edit(编辑)
c#中GDI+图形图像:GDI+中的椭圆和弧使用方法

c#中GDI+图形图像:GDI+中的椭圆和弧使用方法

c#中GDI+图形图像:GDI+中的椭圆和弧使用方法|实例

GDI+中的椭圆和弧

1.绘制椭圆

绘制椭圆时,可以调用Graphics类中的DrawEllipse方法,该方法为可重载方法,它主要用来绘制边界由Rectangle结构指定的椭圆,其常用格式有以下两种。

(1)绘制边界由Rectangle结构指定的椭圆。

语法:

public void DrawEllipse (

Pen pen,

Rectangle rect)

参数说明如下。

pen:Pen对象,它确定曲线的颜色、宽度和样式。

rect:Rectangle结构,它定义椭圆的边界。

(2)绘制一个由边框(该边框由一对坐标、高度和宽度指定)指定的椭圆。

语法:

public void DrawEllipse (

Pen pen,

int x,

int y,

int width,

int height)

DrawEllipse方法中各参数及说明如表1所示。



表1 DrawEllipse方法参数及说明

示例

绘制椭圆

本示例实现的是,当程序运行时,单击【绘制椭圆】按钮,在窗体中的指定位置绘制一个指定边框大小的椭圆。示例运行结果如图1所示。



图1 绘制椭圆

程序代码如下。

Form1窗体中,在【绘制椭圆】按钮的Click事件中分别声明Graphics类和Pen类的两个实例对象,然后定义一个Rectangle结构,以用来控制椭圆的边框大小,最后调用Graphics对象的DrawEllipse方法在窗体中绘制一个指定边框大小的椭圆。网站源代码【绘制椭圆】按钮的Click事件代码如下:

private void button1_Click(object sender, EventArgs e)

{

Graphics graphics = this.CreateGraphics();

Pen myPen = new Pen(Color.Blue, 3);

Rectangle myRectangle = new Rectangle(70, 20, 100, 60);

graphics.DrawEllipse(myPen, myRectangle);

}

完整程序代码如下:

★ ★★★★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_03

{

public partial class Form1 : Form

{

public Form1()

{

InitializeComponent();

}

private void button1_Click(object sender, EventArgs e)

{

Graphics graphics = this.CreateGraphics();

Pen myPen = new Pen(Color.Blue, 3);

Rectangle myRectangle = new Rectangle(70, 20, 100, 60);

graphics.DrawEllipse(myPen, myRectangle);

}

}

}

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

namespace _6_03

{

partial class Form1

{

///

本教程来自:HTTP://www.isstudy.com

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

///


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(78, 90);

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

//本教程来自:HTTP://www.isstudy.com

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

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

this.ClientSize = new System.Drawing.Size(231, 135);

this.Controls.Add(this.button1);

this.MaximizeBox = false;

this.Name = "Form1";

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

this.Text = "Form1";

this.ResumeLayout(false);


添加到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.