资源简介
用C#编写的一个简单的绘图工具,用鼠标拖动画圆,矩形,线条等,适合初学者。
代码片段和文件信息
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Collections;
namespace DrawDesigns
{
public partial class Form1 : Form
{
Boolean mouseDown = false; //鼠标左键是否按下
String drawShape = “Line“; //椭什么形状,初始为线
Point StartPoint = Point.Empty EndPoint = Point.Empty; //鼠标移动的起始点
Color color = Color.Black; //定义图像边框颜色
ArrayList appendList = new ArrayList(); //图形属性列表
Cursor LineCursor CurveCursor EraserCursor; //鼠标样式
public Form1()
{
InitializeComponent();
}
//移动
private void MoveButton_Click(object sender EventArgs e)
{
this.Canvas.Cursor = Cursors.Default;
this.drawShape = ““;
}
//直线
private void DrawLine_Click(object sender EventArgs e)
{
LineCursor = new Cursor(“./MouseIcon/Pen.ico“);
this.drawShape = “Line“;
this.Canvas.Cursor = LineCursor;
}
//曲线
private void DrawCurve_Click(object sender EventArgs e)
{
CurveCursor = new Cursor(“./MouseIcon/Curve.ico“);
this.drawShape = “Curve“;
this.Canvas.Cursor = CurveCursor;
}
//椭圆
private void DrawEllipse_Click(object sender EventArgs e)
{
this.drawShape = “Ellipse“;
this.Canvas.Cursor = Cursors.Cross;
}
//矩形
private void DrawRectangle_Click(object sender EventArgs e)
{
this.drawShape = “Rectangle“;
this.Canvas.Cursor = Cursors.Cross;
}
//擦除
private void EraserTool_Click(object sender EventArgs e)
{
EraserCursor = new Cursor(“./MouseIcon/Eraser.ico“);
this.drawShape = “Eraser“;
this.Canvas.Cursor = EraserCursor;
}
///
/// 图形属性列表
///
public struct ShapeType
{
public string type;
public Point StartPoint EndPoint;
public Color foreColor backColor;
public Brush brush;
public ShapeType(string type Point StartPoint Point EndPoint Color foreColor Color backColor Brush brush)
{
this.type = type;
this.StartPoint = StartPoint;
this.EndPoint = EndPoint;
this.foreColor = foreColor;
this.backColor = backColor;
this.brush = brush;
}
}
//鼠标按下事件
private void Canvas_MouseDown(object sender MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
this.StartPoint = ne
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 30208 2010-11-15 15:01 DrawDesigns\DrawDesigns\bin\Debug\DrawDesigns.exe
文件 32256 2010-11-15 15:01 DrawDesigns\DrawDesigns\bin\Debug\DrawDesigns.pdb
文件 14328 2010-11-15 15:01 DrawDesigns\DrawDesigns\bin\Debug\DrawDesigns.vshost.exe
文件 490 2007-07-21 01:33 DrawDesigns\DrawDesigns\bin\Debug\DrawDesigns.vshost.exe.manifest
文件 2238 2010-07-27 23:25 DrawDesigns\DrawDesigns\bin\Debug\MouseIcon\Curve.ico
文件 4710 2010-07-27 10:52 DrawDesigns\DrawDesigns\bin\Debug\MouseIcon\Eraser.ico
文件 3638 2010-07-27 10:37 DrawDesigns\DrawDesigns\bin\Debug\MouseIcon\Pen.ico
..A.SH. 6656 2010-11-15 14:47 DrawDesigns\DrawDesigns\bin\Debug\MouseIcon\Thumbs.db
文件 4258 2010-11-15 14:50 DrawDesigns\DrawDesigns\DrawDesigns.csproj
文件 15596 2010-11-15 14:59 DrawDesigns\DrawDesigns\Form1.cs
文件 15148 2010-11-15 14:59 DrawDesigns\DrawDesigns\Form1.designer.cs
文件 9871 2010-11-15 14:59 DrawDesigns\DrawDesigns\Form1.resx
文件 2238 2010-11-15 14:48 DrawDesigns\DrawDesigns\ICO\Clear.ico
文件 2238 2010-11-15 14:48 DrawDesigns\DrawDesigns\ICO\Curve.ico
文件 4710 2010-11-15 14:48 DrawDesigns\DrawDesigns\ICO\Eraser.ico
文件 2238 2010-11-15 14:48 DrawDesigns\DrawDesigns\ICO\Icon.ico
文件 3638 2010-11-15 14:48 DrawDesigns\DrawDesigns\ICO\Pen.ico
..A.SH. 16896 2010-11-15 14:54 DrawDesigns\DrawDesigns\ICO\Thumbs.db
文件 2238 2010-11-15 14:48 DrawDesigns\DrawDesigns\Icon.ico
文件 2374 2010-11-15 14:48 DrawDesigns\DrawDesigns\Image\CircleShape.png
文件 8097 2010-11-15 14:48 DrawDesigns\DrawDesigns\Image\color.jpg
文件 3819 2010-11-15 14:48 DrawDesigns\DrawDesigns\Image\cursor.png
文件 3289 2010-11-15 14:48 DrawDesigns\DrawDesigns\Image\Rectangle.png
..A.SH. 14336 2010-11-15 14:54 DrawDesigns\DrawDesigns\Image\Thumbs.db
文件 512 2010-11-15 15:01 DrawDesigns\DrawDesigns\obj\Debug\DrawDesigns.csproj.FileListAbsolute.txt
文件 1094 2010-11-15 15:01 DrawDesigns\DrawDesigns\obj\Debug\DrawDesigns.csproj.GenerateResource.Cache
文件 30208 2010-11-15 15:01 DrawDesigns\DrawDesigns\obj\Debug\DrawDesigns.exe
文件 2804 2010-11-15 15:01 DrawDesigns\DrawDesigns\obj\Debug\DrawDesigns.Form1.resources
文件 32256 2010-11-15 15:01 DrawDesigns\DrawDesigns\obj\Debug\DrawDesigns.pdb
文件 7930 2010-11-15 15:01 DrawDesigns\DrawDesigns\obj\Debug\DrawDesigns.Properties.Resources.resources
............此处省略23个文件信息
- 上一篇:asp.net c# http https 代理服务器源码
- 下一篇:C#外文文献
评论
共有 条评论