⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 splashform.vb

📁 Windows mobile 图形编程例子
💻 VB
字号:
Imports System.IO
Imports System.Reflection

Public Class SplashForm

    Private Sub SplashForm_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Show full screen
        Me.ControlBox = False

    End Sub

    Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
        Using backgroundImage As Image = _
        New Bitmap(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("MobileDevelopersHandbook.Graphic.JPG"))
            ' Use the Graphics object from the PaintEventArgs
            'e.Graphics.DrawImage(backgroundImage, 0, 0);


            ' Fill the background
            e.Graphics.Clear(Color.Black)

            ' Draw the image, but scale it
            ' SourceRect is entire image
            Dim srcRect As Rectangle = _
                    New Rectangle(0, 0, backgroundImage.Width, backgroundImage.Height)
            ' Define the destination rectangle size as 50% of the clipping rectangle
            Dim destRect As Rectangle = _
                    New Rectangle(0, 0, e.ClipRectangle.Width / 2, e.ClipRectangle.Height / 2)
            ' Reposition origin to centre the image on the screen
            destRect.Location = New Point( _
                (e.ClipRectangle.Width - destRect.Width) / 2, _
                (e.ClipRectangle.Height - destRect.Height) / 2)

            ' Draw the image
            e.Graphics.DrawImage(backgroundImage, destRect, srcRect, GraphicsUnit.Pixel)
        End Using

        ' Now draw text positioned inside a rectangle
        Dim s As String = "Mobile Developers Handbook"

        ' Set default pen and font size
        Dim penSize As Integer = 4
        Dim fontSize As Integer = 10

        ' Get dpi of current display
        Dim horResolution As Single = e.Graphics.DpiX
        If horResolution > 100.0 Then
            ' Increase pen and font size on higher resolution devices
            penSize = 5
            fontSize = 11
        End If

        Using iPen As Pen = New Pen(Color.Red, penSize)
            Using iFont As Font = New Font("Arial", fontSize, FontStyle.Regular)
                Using iBrush As SolidBrush = New SolidBrush(Color.White)

                    Dim textSize As SizeF = e.Graphics.MeasureString(s, Font)

                    ' Create a rectangle with padding space between string and box
                    Dim rectWidth As Integer = Convert.ToInt32((textSize.Width) + 10)
                    Dim rectHeight As Integer = Convert.ToInt32((textSize.Height) + 10)
                    Dim r As Rectangle = New Rectangle( _
                            (e.ClipRectangle.Width - rectWidth) / 2, _
                            15, _
                            rectWidth, _
                            rectHeight)

                    e.Graphics.DrawRectangle(iPen, r)
                    e.Graphics.DrawString(s, iFont, iBrush, r.Left + 5, r.Top + 5)

                    ' Now draw a long string, but use a formatting rectangle and a StringFormat
                    ' to wrap and align the text
                    Dim authors As String = "Authors: Andy Wigley, Daniel Moth, Peter Foot"

                    ' Define the destination rectangle
                    Dim layoutRectangle As RectangleF = New RectangleF(15, Me.Height - 50, Me.Width - 20, 100)

                    ' Create a StringFormat and set formating flags
                    Dim strFmt As StringFormat = New StringFormat()
                    strFmt.Alignment = StringAlignment.Center
                    strFmt.FormatFlags = StringFormatFlags.NoClip

                    ' Draw the string
                    e.Graphics.DrawString(authors, iFont, iBrush, layoutRectangle, strFmt)
                End Using
            End Using
        End Using


        ' Draw a line with e.Graphics.DrawLine
        ' Create pen.
        Using redPen As Pen = New Pen(Color.Red, 3)

            Dim length As Integer = e.ClipRectangle.Width - 20
            Dim x1 As Integer = 10
            Dim y1 As Integer = Me.Height - 10
            Dim x2 As Integer = length + 10
            Dim y2 As Integer = y1

            ' Draw line to screen.
            e.Graphics.DrawLine(redPen, x1, y1, x2, y2)
        End Using

    End Sub


End Class

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -