• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • JavaScript
  • ASP.NET
  • PHP
  • 正则表达式
  • AJAX
  • JSP
  • ASP
  • Flex
  • XML
  • 编程技巧
  • Android
  • swift
  • C#教程
  • vb
  • vb.net
  • C语言
  • Java
  • Delphi
  • 易语言
  • vc/mfc
  • 嵌入式开发
  • 游戏开发
  • ios
  • 编程问答
  • 汇编语言
  • 微信小程序
  • 数据结构
  • OpenGL
  • 架构设计
  • qt
  • 微信公众号
您的位置:首页 > 程序设计 >C#教程 > C#绘制中国国旗的方法

C#绘制中国国旗的方法

作者:北风其凉 字体:[增加 减小] 来源:互联网 时间:2017-05-28

北风其凉 通过本文主要向大家介绍了马桶c的个人空间,c语言,欲情 c max,维生素c,奔驰c200等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com

本文实例讲述了C#绘制中国国旗的方法。分享给大家供大家参考。具体如下:

程序运行截图:

中国国旗被定义在《GB:12982-2004》中,以下是从维基百科条目中华人民共和国国旗中截的一张图,标出了五颗星大致的位置。

建立一个空的C# Windows窗体应用程序,窗体取名FormMain,在窗体中放一个PictureBox,取名为picFlagOfChina,并将Dock属性设置为Fill。程序代码中用到了窗体事件Load和Resize,程序代码如下:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace ChineseFlag
{
 public partial class FormMain : Form
 {
  public FormMain()
  {
   InitializeComponent();
  }
  private void FormMain_Load(object sender, EventArgs e)
  {
   PaintFlag();
  }
  //修改窗体大小时发生
  private void FormMain_Resize(object sender, EventArgs e)
  {
   PaintFlag();
  }
  /// <summary>
  /// 在图片框 picFlagOfChina 中绘制国旗
  /// </summary>
  private void PaintFlag()
  {
   picFlagOfChina.BackColor = Color.Red;
   picFlagOfChina.Image = new Bitmap(
    picFlagOfChina.Width, picFlagOfChina.Height);
   Graphics g = Graphics.FromImage(picFlagOfChina.Image);
   Point[] p = new Point[] { };
   p = PentacleA(this.Width, this.Height);
   g.FillPolygon(Brushes.Yellow, p);
   p = PentacleB(this.Width, this.Height);
   g.FillPolygon(Brushes.Yellow, p);
   p = PentacleC(this.Width, this.Height);
   g.FillPolygon(Brushes.Yellow, p);
   p = PentacleD(this.Width, this.Height);
   g.FillPolygon(Brushes.Yellow, p);
   p = PentacleE(this.Width, this.Height);
   g.FillPolygon(Brushes.Yellow, p);
  }
  //大星
  private Point[] PentacleA(int width, int height)
  {
   return new Point[] 
   { 
    new Point((int)(width / 30.0 * 5), (int)(height / 20.0 * 2)),
    new Point((int)(width / 30.0 * 5.7), (int)(height / 20.0 * 4.1)),
    new Point((int)(width / 30.0 * 8), (int)(height / 20.0 * 4.1)),
    new Point((int)(width / 30.0 * 6), (int)(height / 20.0 * 5.3)),
    new Point((int)(width / 30.0 * 6.8), (int)(height / 20.0 * 7.3)),
    new Point((int)(width / 30.0 * 5), (int)(height / 20.0 * 6.1)),
    new Point((int)(width / 30.0 * 3.2), (int)(height / 20.0 * 7.3)),
    new Point((int)(width / 30.0 * 4), (int)(height / 20.0 * 5.3)),
    new Point((int)(width / 30.0 * 2), (int)(height / 20.0 * 4.1)),
    new Point((int)(width / 30.0 * 4.3), (int)(height / 20.0 * 4.1)),
   };
  }
  //工人星
  private Point[] PentacleB(int width, int height)
  {
   return new Point[] 
   { 
    new Point((int)(width / 30.0 * 9.2), (int)(height / 20.0 * 2.5)),
    new Point((int)(width / 30.0 * 9.6), (int)(height / 20.0 * 2)),
    new Point((int)(width / 30.0 * 9.3), (int)(height / 20.0 * 1.4)),
    new Point((int)(width / 30.0 * 9.95), (int)(height / 20.0 * 1.7)),
    new Point((int)(width / 30.0 * 10.45), (int)(height / 20.0 * 1.1)),
    new Point((int)(width / 30.0 * 10.36), (int)(height / 20.0 * 1.85)),
    new Point((int)(width / 30.0 * 11), (int)(height / 20.0 * 2.1)),
    new Point((int)(width / 30.0 * 10.34), (int)(height / 20.0 * 2.25)),
    new Point((int)(width / 30.0 * 10.3), (int)(height / 20.0 * 2.95)),
    new Point((int)(width / 30.0 * 9.9), (int)(height / 20.0 * 2.3))
   };
  }
  //农民星
  private Point[] PentacleC(int width, int height)
  {
   return new Point[] 
   { 
    new Point((int)(width / 30.0 * 11), (int)(height / 20.0 * 4.1)),
    new Point((int)(width / 30.0 * 11.65), (int)(height / 20.0 * 3.8)),
    new Point((int)(width / 30.0 * 11.55), (int)(height / 20.0 * 3.05)),
    new Point((int)(width / 30.0 * 12.05), (int)(height / 20.0 * 3.6)),
    new Point((int)(width / 30.0 * 12.7), (int)(height / 20.0 * 3.3)),
    new Point((int)(width / 30.0 * 12.35), (int)(height / 20.0 * 3.98)),
    new Point((int)(width / 30.0 * 12.9), (int)(height / 20.0 * 4.5)),
    new Point((int)(width / 30.0 * 12.1), (int)(height / 20.0 * 4.3)),
    new Point((int)(width / 30.0 * 11.8), (int)(height / 20.0 * 5)),
    new Point((int)(width / 30.0 * 11.7), (int)(height / 20.0 * 4.2))
   };
  }
  //小资星
  private Point[] PentacleD(int width, int height)
  {
   return new Point[] 
   { 
    new Point((int)(width / 30.0 * 11.1), (int)(height / 20.0 * 6.7)),
    new Point((int)(width / 30.0 * 11.8), (int)(height / 20.0 * 6.7)),
    new Point((int)(width / 30.0 * 12), (int)(height / 20.0 * 6)),
    new Point((int)(width / 30.0 * 12.2), (int)(height / 20.0 * 6.7)),
    new Point((int)(width / 30.0 * 12.9), (int)(height / 20.0 * 6.7)),
    new Point((int)(width / 30.0 * 12.35), (int)(height / 20.0 * 7.1)),
    new Point((int)(width / 30.0 * 12.55), (int)(height / 20.0 * 7.8)),
    new Point((int)(width / 30.0 * 12), (int)(height / 20.0 * 7.4)),
    new Point((int)(width / 30.0 * 11.45), (int)(height / 20.0 * 7.8)),
    new Point((int)(width / 30.0 * 11.65), (int)(height / 20.0 * 7.1))
   };
  }
  //民资星(工人星向下平移7个单位)
  private Point[] PentacleE(int width, int height)
  {
   return new Point[] 
   { 
    new Point((int)(width / 30.0 * 9.2), (int)(height / 20.0 * 9.5)),
    new Point((int)(width / 30.0 * 9.6), (int)(height / 20.0 * 9)),
    new Point((int)(width / 30.0 * 9.3), (int)(height / 20.0 * 8.4)),
    new Point((int)(width / 30.0 * 9.95), (int)(height / 20.0 * 8.7)),
    new Point((int)(width / 30.0 * 10.45), (int)(height / 20.0 * 8.1)),
    new Point((int)(width / 30.0 * 10.36), (int)(height / 20.0 * 8.85)),
    new Point((int)(width / 30.0 * 11), (int)(height / 20.0 * 9.1)),
    new Point((int)(width / 30.0 * 10.34), (int)(height / 20.0 * 9.25)),
    new Point((int)(width / 30.0 * 10.3), (int)(height / 20.0 * 9.95)),
    new Point((int)(width / 30.0 * 9.9), (int)(height / 20.0 * 9.3))
   };
  }
 }
}

</div>

希望本文所述对大家的C#程序设计有所帮助。

</div>
分享到:QQ空间新浪微博腾讯微博微信百度贴吧QQ好友复制网址打印

您可能想查找下面的文章:

  • C#利用ReportViewer生成报表
  • C#基于正则去掉注释的方法示例
  • C#中new的用法及与override的区别分析
  • C#实现两个richtextbox控件滚动条同步滚动的简单方法
  • C# for循环的经典案例集锦
  • C#操作word的方法示例
  • C#使用WebClient登录网站并抓取登录后的网页信息实现方法
  • C# WinForm制作异形窗体与控件的方法
  • C#实现Excel表数据导入Sql Server数据库中的方法
  • C#使用NPOI上传excel

相关文章

  • 2017-05-28设置C#窗体程序只能启动一次
  • 2017-05-28C#在MySQL大量数据下的高效读取、写入详解
  • 2017-05-28C#函数式编程中的部分应用详解
  • 2017-05-28C#获取本机IP地址和Mac地址的方法
  • 2017-05-28C#中私有构造函数的特点和用途实例解析
  • 2017-05-28C#实现获取磁盘空间大小的方法
  • 2017-05-28C#信号量用法简单示例
  • 2017-05-28C#实现跨线程操作控件方法
  • 2017-05-28C#实现中英文混合字符串截取的方法
  • 2017-05-28c# 类型转换

文章分类

  • JavaScript
  • ASP.NET
  • PHP
  • 正则表达式
  • AJAX
  • JSP
  • ASP
  • Flex
  • XML
  • 编程技巧
  • Android
  • swift
  • C#教程
  • vb
  • vb.net
  • C语言
  • Java
  • Delphi
  • 易语言
  • vc/mfc
  • 嵌入式开发
  • 游戏开发
  • ios
  • 编程问答
  • 汇编语言
  • 微信小程序
  • 数据结构
  • OpenGL
  • 架构设计
  • qt
  • 微信公众号

最近更新的内容

    • C#制作简易的屏保
    • c# socket网络编程接收发送数据示例代码
    • C#使用加边法计算行列式的值
    • 英雄联盟辅助lol挂机不被踢的方法(lol挂机脚本)
    • C#异步调用的好处和方法分享
    • WPF实现类似360安全卫士界面的程序源码分享
    • c#连接mysql数据库的方法
    • C#使用Object类实现栈的方法详解
    • C#的四种基本数据类型
    • 轻松学习C#的预定义数据类型

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有