。net ?其實(shí)還是很好繪制圖形的
創(chuàng)新互聯(lián)公司成立于2013年,我們提供高端網(wǎng)站建設(shè)、網(wǎng)站制作公司、網(wǎng)站設(shè)計(jì)、網(wǎng)站定制、營銷型網(wǎng)站建設(shè)、微信平臺(tái)小程序開發(fā)、微信公眾號(hào)開發(fā)、seo優(yōu)化服務(wù),提供專業(yè)營銷思路、內(nèi)容策劃、視覺設(shè)計(jì)、程序開發(fā)來完成項(xiàng)目落地,為成都活動(dòng)板房企業(yè)提供源源不斷的流量和訂單咨詢。
你可以看下?Graphics ?類
Dim d As New Bitmap(Me.Width, Me.Height) ?‘一個(gè)圖片吧
? Dim g As Graphics = Graphics.FromImage(d)’繪制 ?準(zhǔn)備在這個(gè)圖片是進(jìn)行
然后 ?就是你繪制的東西了
線 就是 ??g.DrawLine()
圓 弧度 ?就用 ?g.DrawArc(Pens.Black, New Rectangle(0, 0, 400, 200), 0, 360)
復(fù)雜的就是 ? ? ?g.DrawBezier()
等 ?如果你用的是 VS的 ?編譯 ?上面都有詳細(xì)的參數(shù)說明
Dim?d?As?New?Bitmap(Me.Width,?Me.Height)
Dim?g?As?Graphics?=?Graphics.FromImage(d)
g.DrawArc(Pens.Black,?New?Rectangle(0,?0,?200,?200),?0,?360)
g.DrawLine(Pens.Red,?New?Point(0,?0),?New?Point(200,?200))
g.DrawLines(Pens.Green,?New?Point()?{New?Point(0,?0),?New?Point(50,?40),?New?Point(50,?80),?New?Point(90,?70),?New?Point(100,?400)})
g.DrawBezier(Pens.Yellow,?New?Point(0,?100),?New?Point(0,?0),?New?Point(200,?0),?New?Point(200,?200))
g.Dispose()
Me.BackgroundImage?=?d
這個(gè)類繼承自Panel,把它加到你的項(xiàng)目里面,先運(yùn)行一下,然后從工具箱里把它拖到窗體上,然后再向里面添加其它控件就可以了,支持Shift加選,Alt減選
Imports?System.Linq
Imports?System.Collections
Public?Class?MyPanel
Inherits?Panel
'?選擇模式,相交還是包含
Enum?SelectMode
Intersects
Contains
End?Enum
Dim?down?As?New?Point(-1,?-1)
Dim?rect?As?Rectangle
Dim?selected?As?New?List(Of?Control)
Dim?editting?As?IEnumerable(Of?Control)
Dim?mode?As?SelectMode?=?SelectMode.Contains
Dim?shift,?alt?As?Boolean
Public?Sub?New()
Me.DoubleBuffered?=?True
End?Sub
Protected?Overrides?Sub?OnMouseDown(e?As?MouseEventArgs)
MyBase.OnMouseDown(e)
down?=?e.Location
editting?=?selected.ToArray().ToList()
OnMouseMove(e)
End?Sub
Protected?Overrides?Sub?OnMouseMove(e?As?MouseEventArgs)
MyBase.OnMouseMove(e)
If?e.Button?=?Windows.Forms.MouseButtons.Left?Then
Dim?loc?As?New?Point(Math.Min(down.X,?e.X),?Math.Min(down.Y,?e.Y))
Dim?size?As?New?Size(Math.Abs(down.X?-?e.X),?Math.Abs(down.Y?-?e.Y))
rect?=?New?Rectangle(loc,?size)
Dim?cs?As?New?List(Of?Control)
For?Each?c?In?Controls
cs.Add(c)
Next
Dim?a?=?cs.Where(Function(n?As?Control)?(mode?=?SelectMode.Contains?And?rect.Contains(n.Bounds))?Or?(mode?=?SelectMode.Intersects?And?rect.IntersectsWith(n.Bounds)))
If?shift?Then?editting?=?a.Union(selected)?Else?If?alt?Then?editting?=?selected.Except(a)?Else?editting?=?a
Invalidate()
End?If
End?Sub
Protected?Overrides?Sub?OnMouseUp(e?As?MouseEventArgs)
MyBase.OnMouseUp(e)
down?=?New?Point(-1,?-1)
selected?=?editting.ToList()
editting?=?Nothing
Invalidate()
End?Sub
Protected?Overrides?Function?ProcessKeyPreview(ByRef?m?As?Message)?As?Boolean
Dim?KeyCode?As?Keys?=?CInt(m.WParam)?And?CInt(Keys.KeyCode)
Dim?d?As?Boolean
If?m.Msg?=?H100?Or?m.Msg?=?H104?Then?d?=?True?Else?If?m.Msg?=?H101?Or?m.Msg?=?H105?Then?d?=?False?Else?Return?MyBase.ProcessKeyPreview(m)
If?KeyCode?=?Keys.ShiftKey?Then
shift?=?d
ElseIf?KeyCode?=?Keys.Menu?Then
alt?=?d
End?If
Return?MyBase.ProcessKeyPreview(m)
End?Function
Protected?Overrides?Sub?OnPaint(e?As?PaintEventArgs)
MyBase.OnPaint(e)
For?Each?c?As?Control?In?IIf(editting?Is?Nothing,?selected,?editting)
e.Graphics.DrawRectangle(New?Pen(Color.Gray)?With?{.DashStyle?=?Drawing2D.DashStyle.DashDot},?c.Left?-?1,?c.Top?-?1,?c.Width?+?1,?c.Height?+?1)
Next
If?(down.X??0)?Then?e.Graphics.DrawRectangle(New?Pen(Color.Gray)?With?{.DashStyle?=?Drawing2D.DashStyle.DashDot},?rect)
End?Sub
End?Class
在事件里要記住鼠標(biāo)的移動(dòng)軌跡數(shù)據(jù)并保存到數(shù)組里,再用這些數(shù)據(jù)操作鼠標(biāo)就是模擬鼠標(biāo)還原了
還原時(shí)要有個(gè)時(shí)間控制 也就是每秒錄制幾個(gè)鼠標(biāo)坐標(biāo) 還原時(shí)每秒就移動(dòng)幾個(gè)坐標(biāo),思路就這樣了