資源簡(jiǎn)介
用c#實(shí)現(xiàn)畫(huà)圖功能,可以畫(huà)出各種圖形,如矩形,圓形,菱形等,還可以隨意拖動(dòng),放大縮小

代碼片段和文件信息
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?!
?屬性????????????大小?????日期????時(shí)間???名稱(chēng)
-----------?---------??----------?-----??----
?????目錄???????????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個(gè)文件信息
評(píng)論
共有 條評(píng)論