MainForm.cs
上传用户:linger1010
上传日期:2008-12-08
资源大小:561k
文件大小:3k
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Text;
- using System.Windows.Forms;
- namespace DrawBasicShapes
- {
- public partial class MainForm : Form
- {
- // 第一颗星
- private Point[] m_polygonStar1 = new Point[]
- {
- new Point(30,39),new Point(39,39),
- new Point(41,30),new Point(44,39),
- new Point(53,39),new Point(45,44),
- new Point(49,52),new Point(41,46),
- new Point(34,52),new Point(37,44)
- };
- // 第二颗星
- private Point[] m_polygonStar2 = new Point[]
- {
- new Point(60,16),new Point(69,16),
- new Point(72,8),new Point(74,16),
- new Point(83,16),new Point(75,21),
- new Point(79,30),new Point(72,23),
- new Point(65,30),new Point(68,21)
- };
- // 第三颗星
- private Point[] m_polygonStar3 = new Point[]
- {
- new Point(75,54),new Point(84,54),
- new Point(87,45),new Point(90,54),
- new Point(99,54),new Point(91,59),
- new Point(94,67),new Point(87,62),
- new Point(80,67),new Point(83,59)
- };
- // 烟囱
- private Point[] m_polygonChimney = new Point[]
- {
- new Point(38,135),new Point(38,106),
- new Point(53,106),new Point(53,125)
- };
- // 屋顶
- private Point[] m_polygonRoof = new Point[]
- {
- new Point(15,152),new Point(68,113),new Point(121,152),
- };
- // 月亮的边界
- private Rectangle m_rectangleMoonBound = new Rectangle(128, 8, 84, 84);
- // 月缺的边界
- private Rectangle m_rectangleWaneBound = new Rectangle(174, 2, 62, 62);
- // 侧墙壁
- private Rectangle m_rectangleWall = new Rectangle(38, 152, 60, 68);
-
- // 门
- private Rectangle m_rectangleDoor = new Rectangle(45, 174, 23, 46);
- private Color m_colorBackground = Color.FromArgb(51,51,153);
- private Color m_colorStarMoon = Color.FromArgb(255,204,0);
- private Color m_colorLine = Color.White;
- public MainForm()
- {
- InitializeComponent();
- this.BackColor = m_colorBackground;
- }
- private void MainForm_Paint(object sender, PaintEventArgs e)
- {
- using(Brush b = new SolidBrush(m_colorStarMoon))
- {
- e.Graphics.FillPolygon(b, m_polygonStar1);
- e.Graphics.FillPolygon(b, m_polygonStar2);
- e.Graphics.FillPolygon(b, m_polygonStar3);
- e.Graphics.FillEllipse(b, m_rectangleMoonBound);
- }
- using(Brush b = new SolidBrush(m_colorBackground))
- {
- e.Graphics.FillEllipse(b, m_rectangleWaneBound);
- }
- using(Pen p = new Pen(m_colorLine))
- {
- e.Graphics.DrawLines(p, m_polygonChimney);
- e.Graphics.DrawPolygon(p, m_polygonRoof);
- e.Graphics.DrawRectangle(p, m_rectangleWall);
- e.Graphics.DrawRectangle(p, m_rectangleDoor);
- }
- }
- }
- }