真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

vb.net多個(gè)矩形 vb矩形代碼

誰知道怎么用VB.NET編寫一個(gè)算長(zhǎng)方形面積的程序?

dim a as single=...'自己輸入長(zhǎng)方形的長(zhǎng)

專注于為中小企業(yè)提供成都網(wǎng)站設(shè)計(jì)、網(wǎng)站建設(shè)服務(wù),電腦端+手機(jī)端+微信端的三站合一,更高效的管理,為中小企業(yè)臺(tái)兒免費(fèi)做網(wǎng)站提供優(yōu)質(zhì)的服務(wù)。我們立足成都,凝聚了一批互聯(lián)網(wǎng)行業(yè)人才,有力地推動(dòng)了千余家企業(yè)的穩(wěn)健成長(zhǎng),幫助中小企業(yè)通過網(wǎng)站建設(shè)實(shí)現(xiàn)規(guī)模擴(kuò)充和轉(zhuǎn)變。

dim b as single=...'自己輸入長(zhǎng)方形的寬

dim c as single=a*b'計(jì)算面積

textbox1.text=c'顯示面積

vb.net畫一個(gè)矩形圖片的代碼

g?=?Me.picDisplay.CreateGraphics

Dim?mybrush?As?Brush?=?New?SolidBrush(Map_Empty_Color)

Dim?rect2?As?System.Drawing.Rectangle?=?New?System.Drawing.Rectangle(0,?0,?Map_Width,?Map_Height)

g.FillRectangle(mybrush,?rect2)

VB.NET我要用鼠標(biāo)軌跡畫一個(gè)矩形框 然后選中控件。就像星際和魔獸爭(zhēng)霸里對(duì)部隊(duì)單位的選中一樣~等大神回答

這個(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

VB.net一個(gè)很簡(jiǎn)單的UI問題

花了二十分鐘給你寫了代碼,已測(cè)試。建議學(xué)習(xí)并使用System.Drawing繪制。

主要是掌握Graphics.FillRectangle和DrawString的使用。

Imports?System.Drawing

Public?Class?進(jìn)度條UI

Public?上面筆刷?As?SolidBrush?=?New?SolidBrush(Color.FromArgb(192,?175,?238,?238))

Public?下面筆刷?As?SolidBrush?=?New?SolidBrush(Color.FromArgb(192,?30,?144,?255))

Public?文字筆?As?SolidBrush?=?New?SolidBrush(Color.FromArgb(255,?255,?255,?255))

Public?字體?As?Font?=?New?Font("微軟雅黑",?14.0)

Public?文字格式?As?StringFormat?=?New?StringFormat()?With

{.Alignment?=?StringAlignment.Center,?.LineAlignment?=?StringAlignment.Center}

'''?summary

'''?繪制指定進(jìn)度的圖像。

'''?當(dāng)進(jìn)度變化時(shí)調(diào)用一次本方法,建議將創(chuàng)建的Graphics對(duì)象保存到變量而不要重復(fù)創(chuàng)建。。

'''?/summary

'''?param?name="控件"繪制到此控件的工作區(qū)/param

'''?param?name="g"繪制到控件的Graphics對(duì)象,例如?Button1.CreateGraphics()/param

'''?param?name="進(jìn)度"進(jìn)度百分比實(shí)數(shù),57%?=?0.57/param

Public?Sub?繪制(ByRef?控件?As?Control,?ByRef?g?As?Graphics,?ByVal?進(jìn)度?As?Double)

Dim?矩形?=?控件.ClientRectangle?'獲取控件的工作區(qū)矩形

Dim?下面高度?=?CInt(矩形.Height?*?進(jìn)度)?'獲取下面顏色塊的高度

Dim?中間位置?=?矩形.Top?+?矩形.Height?-?下面高度?'獲取中間分界線的Y坐標(biāo)

Dim?上矩形?=?New?Rectangle(矩形.X,?矩形.Y,?矩形.Width,?矩形.Height?-?下面高度)

Dim?下矩形?=?New?Rectangle(矩形.X,?中間位置,?矩形.Width,?下面高度)

g.FillRectangle(上面筆刷,?上矩形)

g.FillRectangle(下面筆刷,?下矩形)

'繪制文字

Dim?文字?As?String?=?String.Format("{0:0.00}%",?進(jìn)度?*?100)

g.DrawString(文字,?字體,?文字筆,?矩形,?文字格式)

End?Sub

End?Class

下面是Form1窗體的代碼:添加一個(gè)Button1和Timer1控件,將Button1尺寸拖大點(diǎn)

Public?Class?Form1

Public?g?As?Graphics

Public?進(jìn)度條UI?As?New?進(jìn)度條UI

Public?進(jìn)度?As?Double

Private?Sub?Button1_Click(ByVal?sender?As?System.Object,?ByVal?e?As?System.EventArgs)?Handles?Button1.Click

g?=?Button1.CreateGraphics()

Timer1.Enabled?=?Not?Timer1.Enabled

End?Sub

Private?Sub?Timer1_Tick(ByVal?sender?As?System.Object,?ByVal?e?As?System.EventArgs)?Handles?Timer1.Tick

進(jìn)度?+=?0.01

進(jìn)度條UI.繪制(Button1,?g,?進(jìn)度)

End?Sub

End?Class


新聞標(biāo)題:vb.net多個(gè)矩形 vb矩形代碼
文章地址:http://weahome.cn/article/ddddioj.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部