📄 form1.vb
字号:
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 bttnLoad As System.Windows.Forms.Button
Friend WithEvents bttnCopy As System.Windows.Forms.Button
Friend WithEvents bttnPaste As System.Windows.Forms.Button
Friend WithEvents OpenFileDialog1 As System.Windows.Forms.OpenFileDialog
Friend WithEvents bttnClear 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.bttnCopy = New System.Windows.Forms.Button()
Me.PictureBox1 = New System.Windows.Forms.PictureBox()
Me.bttnLoad = New System.Windows.Forms.Button()
Me.OpenFileDialog1 = New System.Windows.Forms.OpenFileDialog()
Me.bttnClear = New System.Windows.Forms.Button()
Me.bttnPaste = New System.Windows.Forms.Button()
Me.SuspendLayout()
'
'bttnCopy
'
Me.bttnCopy.Font = New System.Drawing.Font("Verdana", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.bttnCopy.Location = New System.Drawing.Point(376, 112)
Me.bttnCopy.Name = "bttnCopy"
Me.bttnCopy.Size = New System.Drawing.Size(96, 32)
Me.bttnCopy.TabIndex = 2
Me.bttnCopy.Text = "Copy Image"
'
'PictureBox1
'
Me.PictureBox1.BackColor = System.Drawing.SystemColors.ControlText
Me.PictureBox1.Location = New System.Drawing.Point(8, 8)
Me.PictureBox1.Name = "PictureBox1"
Me.PictureBox1.Size = New System.Drawing.Size(344, 304)
Me.PictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage
Me.PictureBox1.TabIndex = 0
Me.PictureBox1.TabStop = False
'
'bttnLoad
'
Me.bttnLoad.Font = New System.Drawing.Font("Verdana", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.bttnLoad.Location = New System.Drawing.Point(376, 16)
Me.bttnLoad.Name = "bttnLoad"
Me.bttnLoad.Size = New System.Drawing.Size(96, 32)
Me.bttnLoad.TabIndex = 1
Me.bttnLoad.Text = "Load Image"
'
'bttnClear
'
Me.bttnClear.Font = New System.Drawing.Font("Verdana", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.bttnClear.Location = New System.Drawing.Point(376, 64)
Me.bttnClear.Name = "bttnClear"
Me.bttnClear.Size = New System.Drawing.Size(96, 32)
Me.bttnClear.TabIndex = 4
Me.bttnClear.Text = "Clear Image"
'
'bttnPaste
'
Me.bttnPaste.Font = New System.Drawing.Font("Verdana", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.bttnPaste.Location = New System.Drawing.Point(376, 160)
Me.bttnPaste.Name = "bttnPaste"
Me.bttnPaste.Size = New System.Drawing.Size(96, 32)
Me.bttnPaste.TabIndex = 3
Me.bttnPaste.Text = "Paste Image"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(488, 325)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.bttnClear, Me.bttnPaste, Me.bttnCopy, Me.bttnLoad, Me.PictureBox1})
Me.Name = "Form1"
Me.Text = "Image Clipboard"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub bttnPaste_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bttnPaste.Click
If Clipboard.GetDataObject.GetDataPresent(DataFormats.Bitmap) Then
PictureBox1.Image = Clipboard.GetDataObject.GetData(DataFormats.Bitmap)
Else
MsgBox("The Clipboard doesn't contain a bitmap!")
End If
End Sub
Private Sub bttnCopy_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bttnCopy.Click
Clipboard.SetDataObject(PictureBox1.Image)
End Sub
Private Sub bttnLoad_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bttnLoad.Click
OpenFileDialog1.Filter = "Images|*.bmp;*.tif;*.jpg;*.gif"
If OpenFileDialog1.ShowDialog() = DialogResult.OK Then
PictureBox1.Image = Image.FromFile(OpenFileDialog1.FileName)
PictureBox1.Invalidate()
End If
End Sub
Private Sub bttnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bttnClear.Click
PictureBox1.CreateGraphics.Clear(Color.Black)
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -