資源簡介
c#繪圖源碼,可以按住鼠標拖動圖形及通過八個方向拉伸圖形

代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.Collections;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Linq;
using?System.Text;
using?System.Threading.Tasks;
using?System.Windows.Forms;
namespace?DrawRect
{
????public?enum?DirectionalType
????{
????????UP_LEFT
????????UP
????????UP_RIGHT
????????RIGHT
????????DOWN_RIGHT
????????DOWN
????????DOWN_LEFT
????????LEFT
????????NONE
????}
????public?partial?class?Canvas?:?Panel
????{
????????public?Canvas()
????????{
????????????InitializeComponent();
????????????DoubleBuffered?=?true;
????????????this.Setstyle(Controlstyles.AllPaintingInWmPaint?|?Controlstyles.OptimizedDoubleBuffer?|?Controlstyles.UserPaint?true);
????????????this.m_Rect?=?new?Rectangle(8?8?this.Width-16?this.Height);
????????}
????????bool?isMove?=?false;
????????Rectangle?m_Rect?=?Rectangle.Empty;
????????Point?m_LastPoint?=?Point.Empty;
????????DirectionalType?m_StretchingType?=?DirectionalType.NONE;
????????Hashtable?m_MapStretchingTypeRect?=?new?Hashtable();
????????void?CreateRects()
????????{
????????????m_MapStretchingTypeRect.Clear();
????????????m_MapStretchingTypeRect[DirectionalType.UP]?=?new?Rectangle(this.m_Rect.Left?+?this.m_Rect.Width?/?2?-?3?this.m_Rect.Top?-?3?6?6);
????????????m_MapStretchingTypeRect[DirectionalType.RIGHT]?=?new?Rectangle(this.m_Rect.Right?-?3?this.m_Rect.Top?+?this.m_Rect.Height?/?2?-?3?6?6);
????????????m_MapStretchingTypeRect[DirectionalType.DOWN]?=?new?Rectangle(this.m_Rect.Left?+?this.m_Rect.Width?/?2?-?3?this.m_Rect.Bottom?-?3?6?6);
????????????m_MapStretchingTypeRect[DirectionalType.LEFT]?=?new?Rectangle(this.m_Rect.Left?-?3?this.m_Rect.Top?+?this.m_Rect.Height?/?2?-?3?6?6);
????????????m_MapStretchingTypeRect[DirectionalType.UP_LEFT]?=?new?Rectangle(this.m_Rect.Left?-?3?this.m_Rect.Top?-?3?6?6);
????????????m_MapStretchingTypeRect[DirectionalType.UP_RIGHT]?=?new?Rectangle(this.m_Rect.Right?-?3?this.m_Rect.Top?-?3?6?6);
????????????m_MapStretchingTypeRect[DirectionalType.DOWN_RIGHT]?=?new?Rectangle(this.m_Rect.Right?-?3?this.m_Rect.Bottom?-?3?6?6);
????????????m_MapStretchingTypeRect[DirectionalType.DOWN_LEFT]?=?new?Rectangle(this.m_Rect.Left?-?3?this.m_Rect.Bottom?-?3?6?6);
????????}
????????void?DrawRects(Graphics?g)
????????{
????????????foreach?(DictionaryEntry?item?in?m_MapStretchingTypeRect)
????????????{
????????????????DirectionalType?type?=?(DirectionalType)item.Key;
????????????????Rectangle?rect?=?(Rectangle)item.Value;
????????????????if?(m_StretchingType?==?type)
????????????????{
????????????????????g.FillRectangle(new?SolidBrush(Color.FromArgb(255?Color.Green))?rect);
????????????????????g.DrawRectangle(new?Pen(Color.Green)?rect);
????????????????}
????????????????else
????????????????{?
????????????????????g.DrawRectangle(new?Pen(Color.Green)?rect);
????????????????}
???
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2018-09-29?16:55??DrawRect\
?????文件?????????187??2018-09-29?10:24??DrawRect\App.config
?????目錄???????????0??2018-09-29?16:54??DrawRect\bin\
?????目錄???????????0??2018-09-29?16:54??DrawRect\bin\Debug\
?????文件???????12800??2018-09-29?16:54??DrawRect\bin\Debug\DrawRect.exe
?????文件?????????187??2018-09-29?10:24??DrawRect\bin\Debug\DrawRect.exe.config
?????文件???????28160??2018-09-29?16:54??DrawRect\bin\Debug\DrawRect.pdb
?????文件???????24224??2018-09-29?16:53??DrawRect\bin\Debug\DrawRect.vshost.exe
?????文件????????8885??2018-09-29?16:31??DrawRect\canvas.cs
?????文件????????1142??2018-09-29?16:19??DrawRect\Canvas.Designer.cs
?????文件????????5990??2018-09-29?16:17??DrawRect\Canvas.resx
?????文件????????4162??2018-09-29?16:19??DrawRect\DrawRect.csproj
?????文件?????????984??2018-09-29?16:55??DrawRect\DrawRect.sln
?????文件???????14848??2018-09-29?13:28??DrawRect\DrawRect.suo
?????文件???????43520??2018-09-29?16:55??DrawRect\DrawRect.v12.suo
?????文件?????????442??2018-09-29?16:21??DrawRect\FormMain.cs
?????文件????????2432??2018-09-29?16:21??DrawRect\FormMain.Designer.cs
?????文件????????5817??2018-09-29?16:21??DrawRect\FormMain.resx
?????目錄???????????0??2018-09-29?16:53??DrawRect\obj\
?????目錄???????????0??2018-09-29?16:54??DrawRect\obj\Debug\
?????文件????????6798??2018-09-29?16:31??DrawRect\obj\Debug\DesignTimeResolveAssemblyReferences.cache
?????文件????????7132??2018-09-29?16:53??DrawRect\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
?????文件?????????180??2018-09-29?16:54??DrawRect\obj\Debug\DrawRect.Canvas.resources
?????文件????????2309??2018-09-29?16:54??DrawRect\obj\Debug\DrawRect.csproj.FileListAbsolute.txt
?????文件????????1039??2018-09-29?16:54??DrawRect\obj\Debug\DrawRect.csproj.GenerateResource.Cache
?????文件???????12800??2018-09-29?16:54??DrawRect\obj\Debug\DrawRect.exe
?????文件?????????180??2018-09-29?16:54??DrawRect\obj\Debug\DrawRect.FormMain.resources
?????文件???????28160??2018-09-29?16:54??DrawRect\obj\Debug\DrawRect.pdb
?????文件?????????180??2018-09-29?16:54??DrawRect\obj\Debug\DrawRect.Properties.Resources.resources
?????文件???????????0??2018-09-29?10:24??DrawRect\obj\Debug\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs
?????文件???????????0??2018-09-29?10:24??DrawRect\obj\Debug\TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs
............此處省略17個文件信息
評論
共有 條評論