frmgraphic.cs

来自「用C#编的非常好的程序」· CS 代码 · 共 126 行

CS
126
字号
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;
using System.Data.OleDb;


namespace winappFirst
{
	/// <summary>
	/// frmGraphic 的摘要说明。
	/// </summary>
	public class frmGraphic : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Label lblGra;
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;

		public frmGraphic()
		{
			//
			// Windows 窗体设计器支持所必需的
			//
			InitializeComponent();

			//
			// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
			//
		}

		/// <summary>
		/// 清理所有正在使用的资源。
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows 窗体设计器生成的代码
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{
			this.lblGra = new System.Windows.Forms.Label();
			this.SuspendLayout();
			// 
			// lblGra
			// 
			this.lblGra.Location = new System.Drawing.Point(24, 24);
			this.lblGra.Name = "lblGra";
			this.lblGra.Size = new System.Drawing.Size(536, 448);
			this.lblGra.TabIndex = 0;
			this.lblGra.Paint += new System.Windows.Forms.PaintEventHandler(this.lblGra_Paint);
			// 
			// frmGraphic
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(584, 493);
			this.Controls.Add(this.lblGra);
			this.Name = "frmGraphic";
			this.Text = "frmGraphic";
			this.ResumeLayout(false);

		}
		#endregion

		private void lblGra_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
		{
		
			Point  pa=new Point(0,0);
			Point  pb=new Point(0,0);

			pa.X=20;
			pa.Y=30;
			pb.X=100;
			pb.Y=50;

			Graphics gra=e.Graphics;
			
			gra.DrawLine(Pens.Red,pa,pb);

			gra.DrawEllipse(Pens.Blue,100,100,200,80);


		
			
			Point[] pp= new Point[5];
       
			pp[0].X=0;
			pp[0].Y=0;
			pp[1].X=300;
			pp[1].Y=200;
			pp[2].X=500;
			pp[2].Y=70;
			pp[3].X=80;
			pp[3].Y=200;
			pp[4].X=500;
			pp[4].Y=600;

			gra.DrawPolygon(Pens.Black,pp);








		}
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?