using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace PanelGraphics
{
/// <summary>
/// Form1 的摘要描述。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Panel panel1;
/// <summary>
/// 設(shè)計(jì)工具所需的變數(shù)。
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Windows Form 設(shè)計(jì)工具支援的必要項(xiàng)
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 呼叫之後加入任何建構(gòu)函式程式碼
//
}
/// <summary>
/// 清除任何使用中的資源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form 設(shè)計(jì)工具產(chǎn)生的程式碼
/// <summary>
/// 此為設(shè)計(jì)工具支援所必須的方法 - 請(qǐng)勿使用程式碼編輯器修改
/// 這個(gè)方法的內(nèi)容。
/// </summary>
private void InitializeComponent()
{
this.panel1 = new System.Windows.Forms.Panel();
this.SuspendLayout();
//
// panel1
//
this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(292, 266);
this.panel1.TabIndex = 0;
this.panel1.Paint += new System.Windows.Forms.PaintEventHandler(this.panel1_Paint);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 15);
this.ClientSize = new System.Drawing.Size(292, 266);
this.Controls.Add(this.panel1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// 應(yīng)用程式的主進(jìn)入點(diǎn)。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void panel1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
// Create a Graphics object for the Control.
Graphics g = panel1.CreateGraphics();
// Create pen.
Pen blackPen = new Pen(Color.Black, 3);
// Create location and size of ellipse.
float x = 0.0F;
float y = 0.0F;
float width = 150.0F;
float height = 150.0F;
// Draw ellipse to screen.
g.DrawEllipse(blackPen, x, y, width, height);
// Clean up the Graphics object.
g.Dispose();
}
}
}