资源简介
用C#制作的简易画图小程序,包括画笔,图形,颜色选择和线条宽度,橡皮,可用于关于鼠标事件的学习。
代码片段和文件信息
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 DrawingBoard
{
enum DrawTool
{
Pen
Line
Ellipse
Rectangle
Rubber
}
public partial class Form1 : Form
{
private DrawTool tool;
private Point starPt oldPtnewPt;
private Pen pen=Pens.Red;
private Graphics g;
private Color forecolor;
private int penWidth;
private bool isDown = false;
public Form1()
{
InitializeComponent();
}
private void Form1_Load_1(object sender EventArgs e)
{
g = this.CreateGraphics();
}
private void toolColor_Click(object sender EventArgs e)
{
if (colorDialog1.ShowDialog() == DialogResult.OK)
{
forecolor = colorDialog1.Color;
pen = new Pen(forecolor penWidth);
}
}
private void toolPenWidth_SelectedIndexChanged(object sender EventArgs e)
{
toolPenWidth.Text = toolPenWidth.SelectedItem.ToString();
penWidth = int.Parse(toolPenWidth.Text);
pen = new Pen(forecolor penWidth);
}
private void toolPen_Click(object sender EventArgs e)
{
tool = DrawTool.Pen;
}
private void toolLine_Click(object sender EventArgs e)
{
tool = DrawTool.Line;
}
private void toolEllipse_Click(object sender EventArgs e)
{
tool = DrawTool.Ellipse;
}
private void toolRectangle_Click(object sender EventArgs e)
{
tool = DrawTool.Rectangle;
}
private void toolRubber_Click(object sender EventArgs e)
{
tool = DrawTool.Rubber;
}
private void Form1_MouseDown(object sender MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
starPt = new Point(e.X e.Y);
oldPt = new Point(e.X e.Y);
isDown = true;
}
}
private void Form1_MouseUp(object sender MouseEventArgs e)
{
isDown = false;
switch (tool)
{
case DrawTool.Line:
{
Point endpt = new Point(e.X e.Y);
g.DrawLine(pen starPt endpt);
break;
}
case DrawTool.Ellipse:
{
Rectangle rect = new Rectangle(starPt.X starPt.Ye.X-starPt.Xe.Y-starPt.Y);
g.DrawEllipse(pen rect);
break;
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 15872 2018-10-10 23:34 DrawingBoard\DrawingBoard\bin\Debug\DrawingBoard.exe
文件 34304 2018-10-10 23:34 DrawingBoard\DrawingBoard\bin\Debug\DrawingBoard.pdb
文件 11600 2018-10-10 23:42 DrawingBoard\DrawingBoard\bin\Debug\DrawingBoard.vshost.exe
文件 490 2017-03-19 05:00 DrawingBoard\DrawingBoard\bin\Debug\DrawingBoard.vshost.exe.manifest
文件 630 2018-10-10 19:30 DrawingBoard\DrawingBoard\Bitmap1.bmp
文件 630 2018-10-10 19:30 DrawingBoard\DrawingBoard\Bitmap2.bmp
文件 630 2018-10-10 19:30 DrawingBoard\DrawingBoard\Bitmap3.bmp
文件 630 2018-10-10 19:30 DrawingBoard\DrawingBoard\Bitmap4.bmp
文件 1270 2018-10-10 19:30 DrawingBoard\DrawingBoard\Bitmap5.bmp
文件 630 2018-10-10 19:30 DrawingBoard\DrawingBoard\Bitmap6.bmp
文件 3948 2018-10-10 19:30 DrawingBoard\DrawingBoard\DrawingBoard.csproj
文件 3898 2018-10-10 23:34 DrawingBoard\DrawingBoard\Form1.cs
文件 8515 2018-10-10 23:26 DrawingBoard\DrawingBoard\Form1.Designer.cs
文件 9742 2018-10-10 23:26 DrawingBoard\DrawingBoard\Form1.resx
文件 5420 2018-10-10 23:42 DrawingBoard\DrawingBoard\obj\x86\Debug\DesignTimeResolveAssemblyReferences.cache
文件 6920 2018-10-10 23:34 DrawingBoard\DrawingBoard\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache
文件 1290 2018-10-10 23:42 DrawingBoard\DrawingBoard\obj\x86\Debug\DrawingBoard.csproj.FileListAbsolute.txt
文件 975 2018-10-10 23:26 DrawingBoard\DrawingBoard\obj\x86\Debug\DrawingBoard.csproj.GenerateResource.Cache
文件 15872 2018-10-10 23:34 DrawingBoard\DrawingBoard\obj\x86\Debug\DrawingBoard.exe
文件 2994 2018-10-10 23:26 DrawingBoard\DrawingBoard\obj\x86\Debug\DrawingBoard.Form1.resources
文件 34304 2018-10-10 23:34 DrawingBoard\DrawingBoard\obj\x86\Debug\DrawingBoard.pdb
文件 180 2018-10-10 20:47 DrawingBoard\DrawingBoard\obj\x86\Debug\DrawingBoard.Properties.Resources.resources
文件 493 2018-10-10 19:09 DrawingBoard\DrawingBoard\Program.cs
文件 1374 2018-10-10 19:09 DrawingBoard\DrawingBoard\Properties\AssemblyInfo.cs
文件 2876 2018-10-10 19:09 DrawingBoard\DrawingBoard\Properties\Resources.Designer.cs
文件 5612 2018-10-10 19:09 DrawingBoard\DrawingBoard\Properties\Resources.resx
文件 1099 2018-10-10 19:09 DrawingBoard\DrawingBoard\Properties\Settings.Designer.cs
文件 249 2018-10-10 19:09 DrawingBoard\DrawingBoard\Properties\Settings.settings
文件 878 2018-10-10 19:09 DrawingBoard\DrawingBoard.sln
..A..H. 34304 2018-10-10 23:42 DrawingBoard\DrawingBoard.suo
............此处省略12个文件信息
- 上一篇:飞行棋代码
- 下一篇:Galil C#通讯链接范例
相关资源
- Galil C#通讯链接范例
- 飞行棋代码
- 禁止商业用途RPG游戏C#(登陆注册,背
- Huffman树练习
- C# 数字键盘实现
- C# mysql、sqlserver连接demo源码
- winform自绘波形,鼠标滚轮滚动缩放波
- C#仿真飞行仪表盘
- C#动态添加数据到折线图
- C# winform 宿舍管理系统 ,vs2010开发,
- 基于C#邮件客户端
- C#酒店管理系统(报告+代码+讲义)
- 打砖块小游戏,C#源码
- C#贪吃蛇源码
- 豆瓣API接口获取书籍详细信息C#
- 粒子群算法求解TSP问题
- 网络TCPServer转串口UART源码
- C#实现坐标转换,七参数之间进行数据
- c#基础复习题含答案
- 三角高程近似平差C#
- 高斯正反算程序窗体程序,附计算
- C#开发webservice接口,对客户端post服务
- 中国矿业大学程序设计综合实践学生
- C#实现串口通信
- 数据结构与算法-C#版
- C#评委打分系统
- C#调用IDL报错.docx
- C# winform实现简单的贪吃蛇
- 北大青鸟C# 影院售票系统完整源码
- c#软件开发综合实践登录,注册功能
评论
共有 条评论