用VB.net绘制漂亮的splash界面
2006-03-02 11:43
477 查看
学习过程中看到的用VB.net绘制漂亮的splash界面,收藏如下:(效果可见相册中的收藏)
Option Explicit On
Option Strict On
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Convert
Public Class frmSplash
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents tmrSplash As System.Windows.Forms.Timer
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container()
Me.tmrSplash = New System.Windows.Forms.Timer(Me.components)
'
'tmrSplash
'
Me.tmrSplash.Enabled = True
Me.tmrSplash.Interval = 5000
'
'frmSplash
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(512, 357)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None
Me.Name = "frmSplash"
Me.Text = "Form1"
End Sub
#End Region
' The Paint event fires when the form is rendered. Thus, we
' perform the drawing operations in this event handler. Note that
' the second argument (e), contains a reference to an instance
' of the Graphics class.
Private Sub frmSplash_Paint(ByVal sender As Object, _
ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
' Draw the first background rectangle using a HatchBrush.
Dim recHatchFill As New Rectangle(0, 0, _
Me.ClientSize.Width, Me.ClientSize.Height)
Dim hbCurrent As New HatchBrush( _
HatchStyle.Percent90, Color.Gray)
e.Graphics.FillRectangle(hbCurrent, recHatchFill)
' All custom brushes should be explicitly disposed.
hbCurrent.Dispose()
' Draw the line along the bottom of the form.
Dim pntStart As New Point(10, Me.ClientSize.Height - 10)
Dim pntEnd As New Point(Me.ClientSize.Width - 10, Me.ClientSize.Height - 10)
Dim penLine As New Pen(Color.SkyBlue, 3)
e.Graphics.DrawLine(penLine, pntStart, pntEnd)
penLine.Dispose()
' Draw a rectangle just above the line drawn in the
' preceding statements.
Dim pntOutline As New Point(10, 260)
Dim sizOutline As New Size(Me.ClientSize.Width - 20, 80)
Dim penOutline As New Pen(Color.LightSkyBlue, 2)
Dim recOutline As New Rectangle(pntOutline, sizOutline)
e.Graphics.DrawRectangle(penOutline, recOutline)
' All custom pens must be explicitly disposed.
penOutline.Dispose()
' Create a LinearGradentBrush above the preceding rectangle.
Dim recLgb As New Rectangle(10, 10, Me.ClientSize.Width - 20, 235)
Dim lgbRectangle As New LinearGradientBrush(recLgb, _
Color.AliceBlue, Color.SteelBlue, _
LinearGradientMode.Horizontal)
e.Graphics.FillRectangle(lgbRectangle, recLgb)
' All custom brushes must be explicitly disposed.
lgbRectangle.Dispose()
' Create a font and then display text inside of a bounding
' Rectangle.
Dim recText As New Rectangle(1, 1, 390, 80)
Dim fntCurrent As New Font("Arial", 48, FontStyle.Bold)
Dim lgbCurrent As New LinearGradientBrush(recText, _
Color.AliceBlue, Color.SteelBlue, LinearGradientMode.Horizontal)
e.Graphics.DrawString("Chapter 12", fntCurrent, lgbCurrent, _
10, 260)
' Explicitly dispose of the custom font and the LinearGradientBrush.
fntCurrent.Dispose()
lgbCurrent.Dispose()
' Create a filled rectangle, and draw a border around that
' rectangle.
Dim recSolidFill As New Rectangle(50, 50, 100, 100)
e.Graphics.FillRectangle(Brushes.Thistle, recSolidFill)
e.Graphics.DrawRectangle(Pens.Black, recSolidFill)
' Fill and draw a border surrounding a polygon.
Dim pnt1 As New Point(100, 100)
Dim pnt2 As New Point(150, 200)
Dim pnt3 As New Point(50, 200)
Dim pntArray() As Point = {pnt1, pnt2, pnt3}
e.Graphics.FillPolygon(Brushes.Plum, pntArray)
e.Graphics.DrawPolygon(Pens.Black, pntArray)
' Create an ellipse. Fill the ellipse and draw a border
' around it.
Dim recCircle As New Rectangle(125, 125, 100, 100)
e.Graphics.FillEllipse(Brushes.DarkOrchid, recCircle)
e.Graphics.DrawEllipse(Pens.Black, recCircle)
' Create a pie slice. Fill the pie slice with a named
' brush, and then draw a black line to surround that same
' pie slice. Note that named brushes need not be explictly
' disposed
e.Graphics.FillPie(Brushes.Purple, recCircle, 0, 45)
e.Graphics.DrawPie(Pens.Black, recCircle, 0, 45)
' Load and display an image inside of a rectangle.
Dim imgCurrent As Image
imgCurrent = Image.FromFile("../../Data/CourseLogo.bmp")
Dim recImage As New Rectangle(300, 175, imgCurrent.Size.Width, imgCurrent.Size.Height)
e.Graphics.DrawImage(imgCurrent, recImage)
End Sub
' Close the form.
Private Sub tmrSplash_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrSplash.Tick
Me.Close()
End Sub
End Class
Option Explicit On
Option Strict On
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Convert
Public Class frmSplash
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents tmrSplash As System.Windows.Forms.Timer
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container()
Me.tmrSplash = New System.Windows.Forms.Timer(Me.components)
'
'tmrSplash
'
Me.tmrSplash.Enabled = True
Me.tmrSplash.Interval = 5000
'
'frmSplash
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(512, 357)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None
Me.Name = "frmSplash"
Me.Text = "Form1"
End Sub
#End Region
' The Paint event fires when the form is rendered. Thus, we
' perform the drawing operations in this event handler. Note that
' the second argument (e), contains a reference to an instance
' of the Graphics class.
Private Sub frmSplash_Paint(ByVal sender As Object, _
ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
' Draw the first background rectangle using a HatchBrush.
Dim recHatchFill As New Rectangle(0, 0, _
Me.ClientSize.Width, Me.ClientSize.Height)
Dim hbCurrent As New HatchBrush( _
HatchStyle.Percent90, Color.Gray)
e.Graphics.FillRectangle(hbCurrent, recHatchFill)
' All custom brushes should be explicitly disposed.
hbCurrent.Dispose()
' Draw the line along the bottom of the form.
Dim pntStart As New Point(10, Me.ClientSize.Height - 10)
Dim pntEnd As New Point(Me.ClientSize.Width - 10, Me.ClientSize.Height - 10)
Dim penLine As New Pen(Color.SkyBlue, 3)
e.Graphics.DrawLine(penLine, pntStart, pntEnd)
penLine.Dispose()
' Draw a rectangle just above the line drawn in the
' preceding statements.
Dim pntOutline As New Point(10, 260)
Dim sizOutline As New Size(Me.ClientSize.Width - 20, 80)
Dim penOutline As New Pen(Color.LightSkyBlue, 2)
Dim recOutline As New Rectangle(pntOutline, sizOutline)
e.Graphics.DrawRectangle(penOutline, recOutline)
' All custom pens must be explicitly disposed.
penOutline.Dispose()
' Create a LinearGradentBrush above the preceding rectangle.
Dim recLgb As New Rectangle(10, 10, Me.ClientSize.Width - 20, 235)
Dim lgbRectangle As New LinearGradientBrush(recLgb, _
Color.AliceBlue, Color.SteelBlue, _
LinearGradientMode.Horizontal)
e.Graphics.FillRectangle(lgbRectangle, recLgb)
' All custom brushes must be explicitly disposed.
lgbRectangle.Dispose()
' Create a font and then display text inside of a bounding
' Rectangle.
Dim recText As New Rectangle(1, 1, 390, 80)
Dim fntCurrent As New Font("Arial", 48, FontStyle.Bold)
Dim lgbCurrent As New LinearGradientBrush(recText, _
Color.AliceBlue, Color.SteelBlue, LinearGradientMode.Horizontal)
e.Graphics.DrawString("Chapter 12", fntCurrent, lgbCurrent, _
10, 260)
' Explicitly dispose of the custom font and the LinearGradientBrush.
fntCurrent.Dispose()
lgbCurrent.Dispose()
' Create a filled rectangle, and draw a border around that
' rectangle.
Dim recSolidFill As New Rectangle(50, 50, 100, 100)
e.Graphics.FillRectangle(Brushes.Thistle, recSolidFill)
e.Graphics.DrawRectangle(Pens.Black, recSolidFill)
' Fill and draw a border surrounding a polygon.
Dim pnt1 As New Point(100, 100)
Dim pnt2 As New Point(150, 200)
Dim pnt3 As New Point(50, 200)
Dim pntArray() As Point = {pnt1, pnt2, pnt3}
e.Graphics.FillPolygon(Brushes.Plum, pntArray)
e.Graphics.DrawPolygon(Pens.Black, pntArray)
' Create an ellipse. Fill the ellipse and draw a border
' around it.
Dim recCircle As New Rectangle(125, 125, 100, 100)
e.Graphics.FillEllipse(Brushes.DarkOrchid, recCircle)
e.Graphics.DrawEllipse(Pens.Black, recCircle)
' Create a pie slice. Fill the pie slice with a named
' brush, and then draw a black line to surround that same
' pie slice. Note that named brushes need not be explictly
' disposed
e.Graphics.FillPie(Brushes.Purple, recCircle, 0, 45)
e.Graphics.DrawPie(Pens.Black, recCircle, 0, 45)
' Load and display an image inside of a rectangle.
Dim imgCurrent As Image
imgCurrent = Image.FromFile("../../Data/CourseLogo.bmp")
Dim recImage As New Rectangle(300, 175, imgCurrent.Size.Width, imgCurrent.Size.Height)
e.Graphics.DrawImage(imgCurrent, recImage)
End Sub
' Close the form.
Private Sub tmrSplash_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrSplash.Tick
Me.Close()
End Sub
End Class
相关文章推荐
- vb.net GDI+入门——使用Graphics对象绘制线图
- VB.NET :Splash类与只许一个实例
- VB.NET 开发的WINDOWS 界面控件如何应用在网页中
- vb.net 初始屏幕界面透明实现方法
- vb.net 与c# 窗体绘制水晶按钮图形
- vb.net 通过线程来控制界面的方法
- VB.Net + asp.net的一个web系统,使用SQL2000数据库 现在运行时偶尔会出现一个奇怪现象,一个用户登录时,登录后的界面竟然是另一个用户
- vb.net 绘制sin函数
- 用VB.NET绘制GDI图形
- 【VB.NET2010】在PictureBox上绘制文字的相关问题
- [VB.NET源码]49_绘制线图
- [VB.NET源码]界面美化(免费界面控件)
- 分享一个漂亮的ASP.NET MVC界面框架
- VB.NET 章鱼哥 ——程序员也懂爱,动态绘制红心,很浪漫哦
- vb.net中如何快速绘制鼠标移动轨迹
- 在VC中用GDI+绘制角度可变的颜色渐变效果-.NET教程,VB.Net语言[转]
- 用VB.NET绘制GDI图形
- [VB.NET]求助---关于winows工程中窗口界面显示的问题,在线等
- VB.net绘制tan函数图像
- n[VB.NET源码]51_绘制填充图形