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

📄 form1.vb

📁 Mastering VBNet Include Source Code
💻 VB
字号:
Option Strict On
Public Class Form1
    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
    Friend WithEvents PictureBox1 As System.Windows.Forms.PictureBox
    Friend WithEvents Button1 As System.Windows.Forms.Button
    Friend WithEvents Button2 As System.Windows.Forms.Button
    Friend WithEvents Button3 As System.Windows.Forms.Button

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.Container

    '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.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.Button1 = New System.Windows.Forms.Button()
        Me.Button2 = New System.Windows.Forms.Button()
        Me.Button3 = New System.Windows.Forms.Button()
        Me.PictureBox1 = New System.Windows.Forms.PictureBox()
        Me.SuspendLayout()
        '
        'Button1
        '
        Me.Button1.Font = New System.Drawing.Font("Verdana", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(161, Byte))
        Me.Button1.Location = New System.Drawing.Point(8, 360)
        Me.Button1.Name = "Button1"
        Me.Button1.Size = New System.Drawing.Size(128, 23)
        Me.Button1.TabIndex = 1
        Me.Button1.Text = "Ellipses"
        '
        'Button2
        '
        Me.Button2.Font = New System.Drawing.Font("Verdana", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(161, Byte))
        Me.Button2.Location = New System.Drawing.Point(224, 360)
        Me.Button2.Name = "Button2"
        Me.Button2.Size = New System.Drawing.Size(128, 23)
        Me.Button2.TabIndex = 2
        Me.Button2.Text = "Ordinal Curves"
        '
        'Button3
        '
        Me.Button3.Font = New System.Drawing.Font("Verdana", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(161, Byte))
        Me.Button3.Location = New System.Drawing.Point(440, 360)
        Me.Button3.Name = "Button3"
        Me.Button3.Size = New System.Drawing.Size(128, 23)
        Me.Button3.TabIndex = 3
        Me.Button3.Text = "Bezier Curves"
        '
        'PictureBox1
        '
        Me.PictureBox1.Name = "PictureBox1"
        Me.PictureBox1.Size = New System.Drawing.Size(576, 352)
        Me.PictureBox1.TabIndex = 0
        Me.PictureBox1.TabStop = False
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(576, 389)
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Button3, Me.Button2, Me.Button1, Me.PictureBox1})
        Me.Name = "Form1"
        Me.Text = "GDIPlus"
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim G As Graphics
        G = GetGraphicsObject()
        G.SmoothingMode = Drawing.Drawing2D.SmoothingMode.AntiAlias
        G.FillRectangle(Brushes.Silver, ClientRectangle)
        Dim R1, R2 As Rectangle
        R1 = New Rectangle(10, 10, 160, 320)
        R2 = New Rectangle(200, 85, 320, 160)

        G.DrawEllipse(New Pen(Color.Black, 3), R1)
        G.DrawRectangle(Pens.Black, R1)
        G.DrawEllipse(New Pen(Color.Black, 3), R2)
        G.DrawRectangle(Pens.Red, R2)

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim G As Graphics
        G = GetGraphicsObject()
        G.SmoothingMode = Drawing.Drawing2D.SmoothingMode.AntiAlias
        G.FillRectangle(Brushes.Silver, ClientRectangle)
        G.SmoothingMode = Drawing.Drawing2D.SmoothingMode.HighQuality
        Dim points() As Point = {New Point(20, 50), New Point(220, 190), _
                                 New Point(330, 80), New Point(450, 280)}
        G.DrawCurve(Pens.Blue, points, 0.1)
        G.DrawCurve(Pens.Red, points, 0.5)
        G.DrawCurve(Pens.Green, points, 1)
        G.DrawCurve(Pens.Black, points, 2)
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Dim G As Graphics
        G = GetGraphicsObject()
        G.SmoothingMode = Drawing.Drawing2D.SmoothingMode.AntiAlias
        G.FillRectangle(Brushes.Silver, ClientRectangle)
        Dim P1 As New Point(120, 150)
        Dim P2 As New Point(220, 90)
        Dim P3 As New Point(330, 30)
        Dim P4 As New Point(410, 110)
        Dim sqrSize As New Size(6, 6)
        G.FillRectangle(Brushes.Black, New Rectangle(P1, sqrSize))
        G.FillRectangle(Brushes.Black, New Rectangle(P2, sqrSize))
        G.FillRectangle(Brushes.Red, New Rectangle(P3, sqrSize))
        G.FillRectangle(Brushes.Black, New Rectangle(P4, sqrSize))
        G.DrawBezier(Pens.Blue, P1, P2, P3, P4)
        P3 = New Point(330, 130)
        G.FillRectangle(Brushes.Red, New Rectangle(P3, sqrSize))
        G.DrawBezier(Pens.Blue, P1, P2, P3, P4)

        P3 = New Point(330, 230)
        G.FillRectangle(Brushes.Red, New Rectangle(P3, sqrSize))
        G.DrawBezier(Pens.Blue, P1, P2, P3, P4)

        P3 = New Point(330, 330)
        G.FillRectangle(Brushes.Red, New Rectangle(P3, sqrSize))
        G.DrawBezier(Pens.Blue, P1, P2, P3, P4)
    End Sub

    Function GetGraphicsObject() As Graphics
        Dim bmp As Bitmap
        bmp = New Bitmap(PictureBox1.Width, PictureBox1.Height)
        PictureBox1.Image = bmp
        Dim G As Graphics
        G = Graphics.FromImage(bmp)
        Return G
    End Function
End Class

⌨️ 快捷键说明

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