发现智能感应,的确是很大的一个进步。
另一个就是vb.net的概念或者说语句的命名,越来越“专业”了,接近了很多windows程序设计的概念。
vb.net的绘图知识点:
1、绘制各种图:
system.drawing.graphics中有:
drawline、drawellips、drawarc、drawbezier、drawrectangle、drawpolygon等
主要技能用到pen(画线条),brush(填充),比如填充用到fillrectangle等
2、opacity透明度,好像只发现了窗体才有透明度,这个透明有点彻底,若为0,透明得基本上人眼无法看见。
另一个就是,窗体透明后,其子体,如其上的控件button也将继承透明特征。
3、客户区。以前vb6客户区没有这个命名,net有了。
一个窗体或控件的大小可以通过size来进行设置或读取了。客户区的大小一样clientsize.
下面我们来一个button1在窗体form1客户区移动并不断反弹。
把反弹运行分解为X轴和Y轴的运行。form1上添加timer1和button1
Public Class Form1
Dim i As Integer = 0
Dim xleft As Integer
Dim j As Integer = 0
Dim xtop As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
xleft = Button1.Left
xtop = Button1.Top
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If i = 0 Then
xleft += 3
If xleft > Me.ClientSize.Width - Button1.Size.Width Then
xleft = Me.ClientSize.Width - Button1.Size.Width
i = 1
End If
Else
xleft -= 3
If xleft < 0 Then
xleft = 0
i = 0
End If
End If
If j = 0 Then
xtop += 2
If xtop > Me.ClientSize.Height - Button1.Size.Height Then
xtop = Me.ClientSize.Height - Button1.Size.Height
j = 1
End If
Else
xtop -= 2
If xtop < 0 Then
xtop = 0
j = 0
End If
End If
Button1.Left = xleft
Button1.Top = xtop
End Sub
End Class
4、图形没有构造函数,导致不能用new,只能用creategraphics来创建
dim gra as graphics
gra=me.createGraphics '如果在button1上即: gra=button1.creategraphics
dim pen1 as New pen(color.Red)
gra.drawEllipse(pen1,10,120,200,160)
为什么ghraphics不能用构造函数呢?难道是不能确定“宿主”,加在参数里不就行了? 一个大大的问号在我心中。。。