资源简介
这是用C# GDI实现的简易画板Demo,对应博文http://blog.csdn.net/luols/article/details/7171668,有需要的朋友可以下载样例试用
![](http://www.nz998.com/pic/46156.jpg)
代码片段和文件信息
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
namespace GDIDemo
{
public partial class Form1 : Form
{
Bitmap originImg;
Image finishImg;
Graphics g;
DrawType dType;
Point StartPoint EndPoint FontPoint;
Pen p = new Pen(Color.Black 1);
bool IsDraw;
Font font;
Rectangle FontRect;
///
/// 画笔颜色
///
Color DrawColor
{
get { return p.Color; }
set { p.Color = value; }
}
///
/// 画笔宽度
///
float PenWidth
{
set { p.Width = value; }
}
public Form1()
{
InitializeComponent();
cmbThickness.SelectedIndex = 0;
//将文本输入框的父容器设为picDraw,否则显示时会出现错位
txtWrite.Parent = picDraw;
this.Setstyle(Controlstyles.OptimizedDoubleBuffer | Controlstyles.AllPaintingInWmPaint | Controlstyles.UserPaint true);
this.Updatestyles();
//将线帽样式设为圆线帽,否则笔宽变宽时会出现明显的缺口
p.StartCap = LineCap.Round;
p.EndCap = LineCap.Round;
originImg = new Bitmap(picDraw.Width picDraw.Height);
g = Graphics.FromImage(originImg);
//画布背景初始化为白底
g.Clear(Color.White);
picDraw.Image = originImg;
finishImg = (Image)originImg.Clone();
}
private void btnArrow_Click(object sender EventArgs e)
{
dType = DrawType.None;
txtWrite.Visible = false;
txtWrite.Text = ““;
}
private void btnPen_Click(object sender EventArgs e)
{
dType = DrawType.Pen;
txtWrite.Visible = false;
txtWrite.Text = ““;
}
private void btnLine_Click(object sender EventArgs e)
{
dType = DrawType.Line;
txtWrite.Visible = false;
txtWrite.Text = ““;
}
private void btnRect_Click(object sender EventArgs e)
{
dType = DrawType.Rect;
txtWrite.Visible = false;
txtWrite.Text = ““;
}
private void btnEllipse_Click(object sender EventArgs e)
{
dType = DrawType.Ellipse;
txtWrite.Visible = false;
txtWrite.Text = ““;
}
private void btnEraser_Click(object sender EventArgs e)
{
dType = DrawType.Eraser;
txtWrite.Visible = false;
txtWrite.Text = ““;
}
private void btnWrite_Click(object sender EventArgs e)
{
dType = DrawType.Write;
FontDialog fd = ne
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 17408 2015-06-30 11:15 GDIDemo\bin\Debug\GDIDemo.exe
文件 34304 2015-06-30 11:15 GDIDemo\bin\Debug\GDIDemo.pdb
文件 11608 2015-06-30 11:15 GDIDemo\bin\Debug\GDIDemo.vshost.exe
文件 490 2013-03-18 17:00 GDIDemo\bin\Debug\GDIDemo.vshost.exe.manifest
文件 11529 2015-06-30 11:15 GDIDemo\Form1.cs
文件 11691 2015-06-30 11:15 GDIDemo\Form1.Designer.cs
文件 5817 2015-06-30 11:15 GDIDemo\Form1.resx
文件 3421 2015-06-30 11:03 GDIDemo\GDIDemo.csproj
文件 5452 2015-06-30 11:15 GDIDemo\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache
文件 834 2015-06-30 11:15 GDIDemo\obj\x86\Debug\GDIDemo.csproj.FileListAbsolute.txt
文件 975 2015-06-30 11:15 GDIDemo\obj\x86\Debug\GDIDemo.csproj.GenerateResource.Cache
文件 17408 2015-06-30 11:15 GDIDemo\obj\x86\Debug\GDIDemo.exe
文件 180 2015-06-30 11:15 GDIDemo\obj\x86\Debug\GDIDemo.Form1.resources
文件 34304 2015-06-30 11:15 GDIDemo\obj\x86\Debug\GDIDemo.pdb
文件 180 2015-06-30 11:11 GDIDemo\obj\x86\Debug\GDIDemo.Properties.Resources.resources
文件 468 2015-06-30 10:53 GDIDemo\Program.cs
文件 1364 2015-06-30 10:53 GDIDemo\Properties\AssemblyInfo.cs
文件 2866 2015-06-30 10:53 GDIDemo\Properties\Resources.Designer.cs
文件 5612 2015-06-30 10:53 GDIDemo\Properties\Resources.resx
文件 1094 2015-06-30 10:53 GDIDemo\Properties\Settings.Designer.cs
文件 249 2015-06-30 10:53 GDIDemo\Properties\Settings.settings
目录 0 2015-06-30 10:53 GDIDemo\obj\x86\Debug\TempPE
目录 0 2015-06-30 11:15 GDIDemo\obj\x86\Debug
目录 0 2015-06-30 11:11 GDIDemo\bin\Debug
目录 0 2015-06-30 10:53 GDIDemo\obj\x86
目录 0 2015-06-30 10:53 GDIDemo\bin
目录 0 2015-06-30 10:53 GDIDemo\obj
目录 0 2015-06-30 10:53 GDIDemo\Properties
目录 0 2015-06-30 10:54 GDIDemo
----------- --------- ---------- ----- ----
............此处省略2个文件信息
相关资源
- C# 软件版本更新
- C#屏幕软键盘源码,可以自己定制界面
- 智慧城市 智能家居 C# 源代码
- c#获取mobile手机的IMEI和IMSI
- C#实现简单QQ聊天程序
- 操作系统 模拟的 欢迎下载 C#版
- C#写的计算机性能监控程序
- 用C#实现邮件发送,有点类似于outlo
- MVC model层代码生成器 C#
- c#小型图书销售系统
- C# Socket Server Client 通讯应用 完整的服
- c# winform 自动登录 百度账户 源代码
- C#编写的16进制计算器
- C#TCP通信协议
- C# 数据表(Dataset)操作 合并 查询一
- C#语音识别系统speechsdk51,SpeechSDK51L
- 数据库备份还原工具1.0 C# 源码
-
[免费]xm
lDocument 节点遍历C# - EQ2008LEDc#开发实例
- DirectX.Capturec# winform 操作摄像头录像附
- c# 实现的最大最小距离方法对鸢尾花
- C#版保龄球记分代码
- C#自定义控件
- 基于c#的实验室设备管理系统621530
- C# 使用ListView控件实现图片浏览器(源
- C#简单窗体聊天程序
- C#指纹识别系统程序 报告
- c# 高校档案信息管理系统
- c#向word文件插入图片
- C#左侧导航菜单(动态生成)
评论
共有 条评论