1using System;
  2using System.Collections.Generic;
  3using System.ComponentModel;
  4using System.Data;
  5using System.Drawing;
  6using System.Text;
  7using System.Windows.Forms;
  8using System.Drawing.Printing;
  9
 10namespace PrintTest
 11{
 12    /// <summary>
 13    /// 打印雪人图像窗体
 14    /// 2009-02-16 涂聚文
 15    /// </summary>
 16    public partial class printDram : Form
 17    {
 18        /// <summary>
 19        /// 打印雪人图像窗体
 20        /// </summary>
 21        public printDram()
 22        {
 23            InitializeComponent();
 24        }
 25        /// <summary>
 26        /// 窗体加载
 27        /// </summary>
 28        /// <param name="sender"></param>
 29        /// <param name="e"></param>
 30        private void printDram_Load(object sender, EventArgs e)
 31        {
 32
 33        }
 34        /// <summary>
 35        /// 打印文档
 36        /// </summary>
 37        /// <param name="sender"></param>
 38        /// <param name="e"></param>
 39        private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
 40        {
 41            const int MID = 150;
 42            const int Top = 50;
 43            this.BackColor = Color.Cyan;
 44            this.Width = 310;
 45            this.Height = 260;
 46            this.Text = "simple graphics snowman";
 47
 48            Pen blue = new Pen(Color.Blue);
 49            Pen yellow = new Pen(Color.Yellow);
 50            Pen white = new Pen(Color.White);
 51            Pen red = new Pen(Color.Red);
 52            Pen black = new Pen(Color.Black);
 53            Brush brWhite = white.Brush;
 54            Brush brBlack = black.Brush;
 55            Brush brRed = red.Brush;
 56            Graphics g = e.Graphics;
 57
 58            g.DrawRectangle(blue, 0, 175, 300, 50);  //sky
 59            g.DrawEllipse(yellow, -40, -40, 80, 80); //sun
 60            g.FillEllipse(brWhite, MID - 20, Top, 40, 40); //head
 61            g.FillEllipse(brRed, MID - 35, Top + 35, 70, 50); //top
 62            g.FillEllipse(brRed, MID - 50, Top + 80, 100, 60); //bot
 63            g.FillEllipse(brBlack, MID - 10, Top + 10, 5, 5); //l.eye
 64            g.FillEllipse(brBlack, MID + 5, Top + 10, 5, 5);//r.eye
 65            g.DrawArc(black, MID - 10, Top + 20, 20, 10, -190, -160);//(:
 66            //arms
 67            g.DrawLine(black, MID - 25, Top + 60, Top - 50, MID + 40);
 68            g.DrawLine(black, MID + 25, Top + 60, MID + 55, Top + 60);
 69
 70            g.DrawLine(black, MID - 20, Top + 5, MID + 20, Top + 5);//hat,brim,top
 71            g.FillRectangle(brBlack, MID - 15, Top - 20, 30, 25);
 72
 73        }
 74        /// <summary>
 75        /// 打印
 76        /// </summary>
 77        /// <param name="sender"></param>
 78        /// <param name="e"></param>
 79        private void btnprint_Click(object sender, EventArgs e)
 80        {
 81            if (MessageBox.Show("是否打印预览?", "打印预览", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
 82            {
 83                this.printPreviewDialog1.Document = this.printDocument1;
 84                printPreviewDialog1.ShowDialog();
 85            }
 86            else
 87            {
 88                this.printDocument1.Print();//直接打印
 89            }
 90        }
 91        /// <summary>
 92        /// 窗体外观
 93        /// </summary>
 94        /// <param name="sender"></param>
 95        /// <param name="e"></param>
 96        private void printDram_Paint(object sender, PaintEventArgs e)
 97        {
 98            const int MID = 150;
 99            const int Top = 50;
100            this.BackColor = Color.Cyan;
101            this.Width = 310;
102            this.Height = 260;
103            this.Text = "simple graphics snowman";
104
105            Pen blue = new Pen(Color.Blue);
106            Pen yellow = new Pen(Color.Yellow);
107            Pen white = new Pen(Color.White);
108            Pen red = new Pen(Color.Red);
109            Pen black = new Pen(Color.Black);
110            Brush brWhite = white.Brush;
111            Brush brBlack = black.Brush;
112            Brush brRed = red.Brush;
113            Graphics g = e.Graphics;
114
115            g.DrawRectangle(blue, 0, 175, 300, 50);  //sky
116            g.DrawEllipse(yellow, -40, -40, 80, 80); //sun
117            g.FillEllipse(brWhite, MID - 20, Top, 40, 40); //head
118            g.FillEllipse(brWhite, MID - 35, Top + 35, 70, 50); //top
119            g.FillEllipse(brWhite, MID - 50, Top + 80, 100, 60); //bot
120            g.FillEllipse(brBlack, MID - 10, Top + 10, 5, 5); //l.eye
121            g.FillEllipse(brBlack, MID + 5, Top + 10, 5, 5);//r.eye
122            g.DrawArc(black, MID - 10, Top + 20, 20, 10, -190, -160);//(:
123            //arms
124            g.DrawLine(black, MID - 25, Top + 60, Top - 50, MID + 40);
125            g.DrawLine(black, MID + 25, Top + 60, MID + 55, Top + 60);
126
127            g.DrawLine(black, MID - 20, Top + 5, MID + 20, Top + 5);//hat,brim,top
128            g.FillRectangle(brBlack, MID - 15, Top - 20, 30, 25);
129        }
130    }
131}

C# 2.0 Graphics 画雪人相关推荐

  1. (C#)如何利用Graphics画出一幅图表

    //获取坐标 private void Form2_MouseMove(object sender, MouseEventArgs e)         {             this.Text ...

  2. C#如何用Graphics画出一幅图表

    /// <summary> /// 绘制折线图 /// </summary> /// <param name="sender"></par ...

  3. 如何用python画雪人_pygame画雪人_函数与图形示例.py

    """pygame画雪人_函数与图形示例.py """ # 导入pygame模块 import pygame def draw_snowma ...

  4. opencv 画雪人

    opencv 画雪人 import cv2 import numpy as n img = 255*n.ones((350,512,3),n.uint8) font = cv2.FONT_HERSHE ...

  5. c语言用字符画一个椭圆,用vc++6.0 程式设计画一个椭圆出来,求完整原始码

    用vc++6.0 程式设计画一个椭圆出来,求完整原始码以下文字资料是由(历史新知网www.lishixinzhi.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧! 用vc++6.0 ...

  6. 用python画雪人-pygame画雪人_函数与图形示例.py

    """pygame画雪人_函数与图形示例.py """ # 导入pygame模块 import pygame def draw_snowma ...

  7. Python画图基础操作之全注释画雪人

    一步步教你怎么用Python画雪人,进一步熟悉Python的基础画图操作,废话不多说,上代码. 希望您给个关注给个赞,也算对我们的支持了. class Shape: # 基类(雪人各部件(形状)共有的 ...

  8. 如何从0开始画出一张优秀的架构图

    你好,我是悟空. 最近在画项目的技术架构图,找到了一些不错的模板,分享给大家~ 画图工具:ProcessOn. 画图技巧:如何从0开始画出一张优秀的架构图 文末再送 5 本书给大家! 业务架构图 定义 ...

  9. 用java编写圆锥_用java中的graphics画圆锥的代码

    展开全部 圆锥就32313133353236313431303231363533e4b893e5b19e31333337616564是一个三角形+一个椭圆.只要算好三角形和椭圆 的坐标就可以了impo ...

最新文章

  1. 帝国cms后台模板编辑器辅助增强插件代码高亮格式化显示
  2. 学python可以做什么产品-学完Python可以做什么?主要用途有哪些?
  3. 百分点集团被APAC CIO Outlook杂志评选为亚太区大数据企业25强
  4. java语言简单代码_java语言编程如何实现一个最简单程序?
  5. NIFI使用过程中的invalid component问题解决
  6. Sales Volume Analysis PoC app test - environment setup finished
  7. springboot springmvc mybatis_12道重点的Spring Boot面试题,帮你整理好了!
  8. java rsa 公钥加密_java – 使用公钥进行RSA解密
  9. python中multiply函数_python中numpy库内multiply()、dot()和 * 三种乘法运算的区别小计...
  10. Tarjan算法求解桥和边双连通分量(附POJ 3352 Road Construction解题报告)
  11. IDEA配置SpringBoot的springloaded热部署(写方法、属性不用重启)
  12. matlab颜色识别提取,matlab实现图像颜色特征提取
  13. android 图层绘画分析,Android-绘图机制总结
  14. 快乐机:人活着真的只为追求快乐吗?
  15. css中的盒模型box-sizing
  16. 虚拟机建Mac系统步骤
  17. 斯坦福大学公开课机器学习:Neural Networks,representation: non-linear hypotheses(为什么需要做非线性分类器)...
  18. 自动下载必应主页图片做壁纸
  19. 整理:卷积的直观理解、物理意义与本质(四)
  20. 《推荐系统实践》__第1章__好的推荐系统

热门文章

  1. 常用的七种数据分析方法有哪些?
  2. 世界五百强中国上榜公司首次超过美国;现代汽车发布电动汽车品牌IONIQ | 美通企业日报...
  3. python开发qq聊天机器人_Python qqbot 实现qq机器人的示例代码
  4. RocksDB原理介绍
  5. P1498 南蛮图腾---洛谷(分冶)
  6. 岁月温柔-17 妈妈在市第一人民医院ICU第七天
  7. 大数据级新闻去重实现 - 1.在线实时方案
  8. 重组的脱氧核糖核酸酶 I,生物工艺级相关研究
  9. 单词接龙acwing
  10. ppt 里插入html,如何在PPT中插入html网页.ppt