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

📄 splashform.vb

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

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"))

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

            ' The .NET Compact Framework supports transparency but with 
            ' only one transparency color.
            ' The SetColorKey method must have the same color specified 
            ' for the low color and high color range.
            Dim attr As System.Drawing.Imaging.ImageAttributes = New System.Drawing.Imaging.ImageAttributes()

            ' Sets the transparency color key based on the upper left pixel of the image
            attr.SetColorKey((CType(backgroundImage, Bitmap)).GetPixel(0, 0), (CType(backgroundImage, Bitmap)).GetPixel(0, 0))

            ' Draw the image, but scale it to 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 using the image attributes.
            e.Graphics.DrawImage(backgroundImage, destRect, 0, 0, backgroundImage.Width, backgroundImage.Height, GraphicsUnit.Pixel, attr)
        End Using

        ' Create string to draw.
        Dim drawString As String = "Mobile Developers Handbook"

        ' Create font at 90 degrees.
        Using ft As Font = CreateLogFont(90)
            Dim strSize As SizeF = e.Graphics.MeasureString(drawString, ft)

            ' Create Rectangle just bigger than the size of the string
            ' Note that in sizing this rectangle, we switch the height and width
            ' returned by MeasureString, which doesn't take font angle into account
            Dim areaWidth As Integer = CType(strSize.Height + 10, Integer)
            Dim areaHeight As Integer = CType(strSize.Width + 10, Integer)

            ' Fill into a bitmap and then draw that onto e.Graphics.
            Using bm As Bitmap = New Bitmap(areaWidth, areaHeight)
                Using gr As Graphics = System.Drawing.Graphics.FromImage(bm)
                    ' Fill the rectangular bitmap using gradient fill
                    GradientFill.Fill( _
                        gr, New Rectangle(0, 0, areaWidth, areaHeight), _
                        Color.Yellow, Color.Red, _
                        GradientFill.FillDirection.TopToBottom)

                    ' Draw the bitmap to the screen
                    e.Graphics.DrawImage(bm, 0, Me.Height - 15 - areaHeight)
                End Using
            End Using

            ' Create brush.
            Using drawBrush As SolidBrush = New SolidBrush(Color.DarkBlue)
                ' Draw the string over the top
                e.Graphics.DrawString(drawString, ft, drawBrush, 5, Me.Height - 20, New StringFormat(StringFormatFlags.NoClip Or StringFormatFlags.NoWrap))
            End Using
        End Using

        MyBase.OnPaint(e)


    End Sub

    Private Const POINTS_PER_INCH As Single = 72.0F

    Private Function CreateLogFont(ByVal angle As Integer) As Font
        ' Create and define a LogFont structure.
        Dim fontStruct As LogFont = New LogFont()

        Using g As Graphics = Me.CreateGraphics()
            ' Scale 10point for the dpi of the current display
            ' also make it negative, means match against character 
            ' height of available fonts
            fontStruct.Height = -1 * CType((12.0F * (g.DpiY / POINTS_PER_INCH)), Integer)
        End Using

        ' Since font width is usually dependent on the height, 
        ' usual to set width to zero
        fontStruct.Width = 0

        ' Set the font angle.
        ' Remember to multiply by 10.
        fontStruct.Escapement = angle * 10

        ' The Escapement member specifies both the
        ' escapement and orientation. You should set
        ' Escapement and Orientation to the same value.
        fontStruct.Orientation = fontStruct.Escapement

        ' No formatting.
        fontStruct.Italic = 0
        fontStruct.Underline = 0
        fontStruct.StrikeOut = 0
        ' Weight: 0 = default, 400 = normal, 700 = bold
        fontStruct.Weight = 0

        fontStruct.CharSet = LogFontCharSet.Default
        fontStruct.OutPrecision = LogFontPrecision.Default
        fontStruct.ClipPrecision = LogFontClipPrecision.Default
        fontStruct.Quality = LogFontQuality.Default
        fontStruct.PitchAndFamily = LogFontPitchAndFamily.Default

        fontStruct.FaceName = "Arial"

        ' Create the font from the LogFont structure.
        Return Font.FromLogFont(fontStruct)
    End Function



End Class

⌨️ 快捷键说明

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