资源简介
用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;
using GraphExample.Shapes;
using GraphExample.Marks;
namespace GraphExample
{
public partial class MainForm : Form
{
Canvas canvas = new Canvas();
public MainForm()
{
InitializeComponent();
}
private void MainForm_Load(object sender EventArgs e)
{
canvas.Shapes.Add(new Box()
{
Rectangle = new Rectangle(100 100 400 500)
UserData = new PowerStation()
});
canvas.Shapes.Add(new BoxWithoutOneAngle()
{
Rectangle = new Rectangle(150 150 200 66)
UserData = new School()
});
}
private void MainForm_Paint(object sender PaintEventArgs e)
{
Draw(e.Graphics);
}
public void Draw(Graphics g)
{
canvas.Draw(g);
}
Mark markonmousedown = null;
Shape shapeonmousedown = null;
Point pointonmousedown;
Point pointInShapeonmousedown;
private void MainForm_MouseDown(object sender MouseEventArgs e)
{
pointonmousedown = e.Location;
if (e.Button == System.Windows.Forms.MouseButtons.Left)
markonmousedown = canvas.GetMark(e.X e.Y);
if (markonmousedown != null)
return;
shapeonmousedown = canvas.GetShape(e.X e.Y);
if (shapeonmousedown != null)
{
pointInShapeonmousedown = new Point(
e.Location.X -
shapeonmousedown.Rectangle.Location.X
e.Location.Y -
shapeonmousedown.Rectangle.Location.Y);
shapeonmousedown.Selected = true;
}
else
canvas.ClearSelection();
this.Refresh();
}
private void MainForm_MouseMove(object sender MouseEventArgs e)
{
if (e.Button == System.Windows.Forms.MouseButtons.Left)
{
if (markonmousedown != null)
{
markonmousedown.MoveTo(e.Location);
this.Refresh();
return;
}
else if (shapeonmousedown != null)
{
shapeonmousedown.MoveTo(
new Point(e.X - pointInShapeonmousedown.X
e.Y - pointInShapeonmousedown.Y));
this.Refresh();
this.Cursor = Cursors.SizeAll;
return;
}
}
Mark m = canvas.GetMark(e.X e.Y);
if (m !
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2012-11-04 10:32 GraphExample2\
文件 144 2012-11-04 11:01 GraphExample2\app.config
目录 0 2012-11-04 10:32 GraphExample2\bin\
目录 0 2012-11-04 10:32 GraphExample2\bin\Debug\
文件 19456 2012-12-23 22:14 GraphExample2\bin\Debug\GraphExample.exe
文件 144 2012-11-04 11:01 GraphExample2\bin\Debug\GraphExample.exe.config
文件 83456 2012-12-23 22:14 GraphExample2\bin\Debug\GraphExample.pdb
文件 11600 2012-12-28 15:49 GraphExample2\bin\Debug\GraphExample.vshost.exe
文件 144 2012-11-04 11:01 GraphExample2\bin\Debug\GraphExample.vshost.exe.config
文件 490 2012-06-06 02:06 GraphExample2\bin\Debug\GraphExample.vshost.exe.manifest
目录 0 2012-10-19 15:55 GraphExample2\bin\Release\
文件 1 2012-10-26 20:31 GraphExample2\ClassDiagram1.cd
文件 4449 2012-11-04 11:01 GraphExample2\GraphExample.csproj
文件 865 2012-10-12 17:18 GraphExample2\GraphExample.sln
文件 39424 2012-12-28 15:50 GraphExample2\GraphExample.suo
文件 46592 2012-11-02 17:24 GraphExample2\GraphExample.v11.suo
文件 3140 2012-11-02 17:10 GraphExample2\MainForm.cs
文件 1812 2012-10-19 17:18 GraphExample2\MainForm.Designer.cs
文件 5817 2012-10-19 17:18 GraphExample2\MainForm.resx
目录 0 2012-11-04 10:32 GraphExample2\Marks\
文件 2369 2012-11-02 17:02 GraphExample2\Marks\Mark.cs
文件 490 2012-11-02 17:06 GraphExample2\Marks\MarkCollection.cs
文件 777 2012-11-02 17:02 GraphExample2\Marks\ShapeMark.cs
文件 754 2012-11-02 17:02 GraphExample2\Marks\SizeMark.cs
目录 0 2012-11-04 10:32 GraphExample2\obj\
目录 0 2012-11-04 10:32 GraphExample2\obj\x86\
目录 0 2012-12-23 22:14 GraphExample2\obj\x86\Debug\
文件 4040 2012-11-13 23:33 GraphExample2\obj\x86\Debug\DesignTimeResolveAssemblyReferences.cache
文件 6108 2012-12-23 22:14 GraphExample2\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache
文件 422 2012-10-26 16:27 GraphExample2\obj\x86\Debug\GenerateResource.read.1.tlog
文件 1420 2012-10-26 16:27 GraphExample2\obj\x86\Debug\GenerateResource.write.1.tlog
............此处省略31个文件信息
相关资源
- C# TIP文件生成和拆解
- C#解析HL7消息的库135797
- C# OCR数字识别实例,采用TessnetOcr,对
- 考试管理系统 - C#源码
- asp.net C#购物车源代码
- C#实时网络流量监听源码
- C#百度地图源码
- Visual C#.2010从入门到精通配套源程序
- 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#版保龄球记分代码
评论
共有 条评论