MainForm.cs
上传用户:linger1010
上传日期:2008-12-08
资源大小:561k
文件大小:3k
源码类别:

Windows Mobile

开发平台:

C#

  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Text;
  7. using System.Windows.Forms;
  8. namespace DrawBasicShapes
  9. {
  10. public partial class MainForm : Form
  11. {
  12. // 第一颗星
  13. private Point[] m_polygonStar1 = new Point[]
  14. {
  15. new Point(30,39),new Point(39,39),
  16. new Point(41,30),new Point(44,39),
  17. new Point(53,39),new Point(45,44),
  18. new Point(49,52),new Point(41,46),
  19. new Point(34,52),new Point(37,44)
  20. };
  21. // 第二颗星
  22. private Point[] m_polygonStar2 = new Point[]
  23. {
  24. new Point(60,16),new Point(69,16),
  25. new Point(72,8),new Point(74,16),
  26. new Point(83,16),new Point(75,21),
  27. new Point(79,30),new Point(72,23),
  28. new Point(65,30),new Point(68,21)
  29. };
  30. // 第三颗星
  31. private Point[] m_polygonStar3 = new Point[]
  32. {
  33. new Point(75,54),new Point(84,54),
  34. new Point(87,45),new Point(90,54),
  35. new Point(99,54),new Point(91,59),
  36. new Point(94,67),new Point(87,62),
  37. new Point(80,67),new Point(83,59)
  38. };
  39. // 烟囱
  40. private Point[] m_polygonChimney = new Point[]
  41. {
  42. new Point(38,135),new Point(38,106),
  43. new Point(53,106),new Point(53,125)
  44. };
  45. // 屋顶
  46. private Point[] m_polygonRoof = new Point[]
  47. {
  48. new Point(15,152),new Point(68,113),new Point(121,152),
  49. };
  50. // 月亮的边界
  51. private Rectangle m_rectangleMoonBound = new Rectangle(128, 8, 84, 84);
  52. // 月缺的边界
  53. private Rectangle m_rectangleWaneBound = new Rectangle(174, 2, 62, 62);
  54. // 侧墙壁
  55. private Rectangle m_rectangleWall = new Rectangle(38, 152, 60, 68);
  56. // 门
  57. private Rectangle m_rectangleDoor = new Rectangle(45, 174, 23, 46);
  58. private Color m_colorBackground = Color.FromArgb(51,51,153);
  59. private Color m_colorStarMoon = Color.FromArgb(255,204,0);
  60. private Color m_colorLine = Color.White;
  61. public MainForm()
  62. {
  63. InitializeComponent();
  64. this.BackColor = m_colorBackground;
  65. }
  66. private void MainForm_Paint(object sender, PaintEventArgs e)
  67. {
  68. using(Brush b = new SolidBrush(m_colorStarMoon))
  69. {
  70. e.Graphics.FillPolygon(b, m_polygonStar1);
  71. e.Graphics.FillPolygon(b, m_polygonStar2);
  72. e.Graphics.FillPolygon(b, m_polygonStar3);
  73. e.Graphics.FillEllipse(b, m_rectangleMoonBound);
  74. }
  75. using(Brush b = new SolidBrush(m_colorBackground))
  76. {
  77. e.Graphics.FillEllipse(b, m_rectangleWaneBound);
  78. }
  79. using(Pen p = new Pen(m_colorLine))
  80. {
  81. e.Graphics.DrawLines(p, m_polygonChimney);
  82. e.Graphics.DrawPolygon(p, m_polygonRoof);
  83. e.Graphics.DrawRectangle(p, m_rectangleWall);
  84. e.Graphics.DrawRectangle(p, m_rectangleDoor);
  85. }
  86. }
  87. }
  88. }