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

📄 kernel.vb

📁 这个是国外大学的项目代码
💻 VB
📖 第 1 页 / 共 2 页
字号:
        Me.txtd.TabIndex = 12
        Me.txtd.Text = "1"
        Me.txtd.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
        '
        'btnCheck
        '
        Me.btnCheck.FlatStyle = System.Windows.Forms.FlatStyle.Flat
        Me.btnCheck.Location = New System.Drawing.Point(144, 184)
        Me.btnCheck.Name = "btnCheck"
        Me.btnCheck.Size = New System.Drawing.Size(56, 20)
        Me.btnCheck.TabIndex = 13
        Me.btnCheck.Text = "Check"
        '
        'btnOK
        '
        Me.btnOK.FlatStyle = System.Windows.Forms.FlatStyle.Flat
        Me.btnOK.Location = New System.Drawing.Point(72, 160)
        Me.btnOK.Name = "btnOK"
        Me.btnOK.Size = New System.Drawing.Size(64, 24)
        Me.btnOK.TabIndex = 14
        Me.btnOK.Text = "OK"
        '
        'btnCancel
        '
        Me.btnCancel.AccessibleRole = System.Windows.Forms.AccessibleRole.None
        Me.btnCancel.FlatStyle = System.Windows.Forms.FlatStyle.Flat
        Me.btnCancel.Location = New System.Drawing.Point(160, 160)
        Me.btnCancel.Name = "btnCancel"
        Me.btnCancel.Size = New System.Drawing.Size(64, 24)
        Me.btnCancel.TabIndex = 15
        Me.btnCancel.Text = "Cancel"
        '
        'grpImage
        '
        Me.grpImage.Controls.Add(Me.cboDestination)
        Me.grpImage.Controls.Add(Me.cboSource)
        Me.grpImage.Controls.Add(Me.lblDestination)
        Me.grpImage.Controls.Add(Me.lblSource)
        Me.grpImage.Location = New System.Drawing.Point(8, 8)
        Me.grpImage.Name = "grpImage"
        Me.grpImage.Size = New System.Drawing.Size(304, 136)
        Me.grpImage.TabIndex = 14
        Me.grpImage.TabStop = False
        Me.grpImage.Text = "Image:"
        '
        'cboDestination
        '
        Me.cboDestination.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
        Me.cboDestination.ItemHeight = 13
        Me.cboDestination.Location = New System.Drawing.Point(8, 104)
        Me.cboDestination.Name = "cboDestination"
        Me.cboDestination.Size = New System.Drawing.Size(288, 21)
        Me.cboDestination.TabIndex = 1
        '
        'cboSource
        '
        Me.cboSource.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
        Me.cboSource.ItemHeight = 13
        Me.cboSource.Location = New System.Drawing.Point(8, 48)
        Me.cboSource.Name = "cboSource"
        Me.cboSource.Size = New System.Drawing.Size(288, 21)
        Me.cboSource.TabIndex = 0
        '
        'lblDestination
        '
        Me.lblDestination.AutoSize = True
        Me.lblDestination.Location = New System.Drawing.Point(8, 80)
        Me.lblDestination.Name = "lblDestination"
        Me.lblDestination.Size = New System.Drawing.Size(64, 16)
        Me.lblDestination.TabIndex = 20
        Me.lblDestination.Text = "Destination:"
        '
        'lblSource
        '
        Me.lblSource.AutoSize = True
        Me.lblSource.Location = New System.Drawing.Point(8, 24)
        Me.lblSource.Name = "lblSource"
        Me.lblSource.Size = New System.Drawing.Size(43, 16)
        Me.lblSource.TabIndex = 19
        Me.lblSource.Text = "Source:"
        '
        'lblLg
        '
        Me.lblLg.Location = New System.Drawing.Point(8, 192)
        Me.lblLg.Name = "lblLg"
        Me.lblLg.Size = New System.Drawing.Size(304, 32)
        Me.lblLg.TabIndex = 16
        Me.lblLg.Text = "Note: The multiplication and division will be performed with values power of two " & _
        "(left or right shifting) and zero."
        '
        'frmImageProcess
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(546, 231)
        Me.Controls.Add(Me.lblLg)
        Me.Controls.Add(Me.grpImage)
        Me.Controls.Add(Me.btnCancel)
        Me.Controls.Add(Me.btnOK)
        Me.Controls.Add(Me.grbKernel)
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
        Me.MaximizeBox = False
        Me.MinimizeBox = False
        Me.Name = "frmImageProcess"
        Me.ShowInTaskbar = False
        Me.Text = "Process"
        Me.grbKernel.ResumeLayout(False)
        Me.grpK.ResumeLayout(False)
        Me.grpImage.ResumeLayout(False)
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub frmImageProcess_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim tmp As String
        tmp = cboSource.SelectedItem
        cboSource.Items.Clear()
        For item As Integer = 0 To IMGLST.Items.Count - 1
            cboSource.Items.Add(IMGLST.Items.Item(item))
            If IMGLST.Items.Item(item) = tmp Then
                cboSource.SelectedItem = tmp
            End If
        Next
        'cboDestination.Items.Clear()
    End Sub

    Private Sub cboSource_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboSource.SelectedIndexChanged
        Dim bmpsrc, bmpdest As Drawing.Bitmap
        Dim tmp As String

        If cboSource.SelectedIndex = -1 Then
            Exit Sub
        End If
        tmp = cboDestination.SelectedItem
        bmpsrc = IMGCOLL.Item(cboSource.SelectedIndex + 1)
        cboDestination.Items.Clear()
        cboDestination.Items.Add("New image...")
        For item As Integer = 1 To IMGCOLL.Count
            bmpdest = IMGCOLL.Item(item)
            If (Equals(bmpdest.Size, bmpsrc.Size)) Then
                cboDestination.Items.Add(IMGLST.Items.Item(item - 1))
                If IMGLST.Items.Item(item - 1) = tmp Then
                    cboDestination.SelectedItem = tmp
                End If
            End If
        Next
    End Sub

    Private Sub cboDestination_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboDestination.SelectedIndexChanged
        Dim bmp As Drawing.Bitmap
        If cboDestination.SelectedIndex <> 0 Then
            Exit Sub
        End If
        bmp = IMGCOLL.Item(IMGLST.Items.IndexOf(cboSource.SelectedItem) + 1)
        If CheckDataSize(bmp) Then
            cboDestination.SelectedIndex = -1
            MsgBox("Data size would exceede memory capacity.", MsgBoxStyle.Information)
        End If
    End Sub

    Private Sub txtk0_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) _
        Handles txtk0.GotFocus, txtk1.GotFocus, txtk2.GotFocus, txtk3.GotFocus, txtk4.GotFocus, _
        txtk5.GotFocus, txtk6.GotFocus, txtk7.GotFocus, txtk8.GotFocus, txtd.GotFocus
        sender.text = ""
    End Sub

    Private Sub txtk0_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) _
        Handles txtk0.LostFocus, txtk1.LostFocus, txtk2.LostFocus, txtk3.LostFocus, txtk4.LostFocus, _
        txtk5.LostFocus, txtk6.LostFocus, txtk7.LostFocus, txtk8.LostFocus, txtd.LostFocus
        If IsNumeric(sender.text) Then
            If sender.text > 16 Then
                sender.text = 16
            ElseIf sender.text < -16 Then
                sender.text = -16
            End If
        Else
            sender.text = "0"
        End If
    End Sub

    Private Sub txtk0_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) _
        Handles txtk0.KeyPress, txtk1.KeyPress, txtk2.KeyPress, txtk3.KeyPress, txtk4.KeyPress, _
        txtk5.KeyPress, txtk6.KeyPress, txtk7.KeyPress, txtk8.KeyPress, txtd.KeyPress
        If e.KeyChar = "-" Then
            If sender.text = "" Or sender.text = "0" Then
                sender.text = "-"
            ElseIf sender.text = "-" Then
                sender.text = ""
            ElseIf IsNumeric(sender.text) Then
                sender.text = 0 - sender.text
            End If
        ElseIf Char.IsDigit(e.KeyChar) Then
            sender.text = sender.text & e.KeyChar
        End If
        e.Handled() = True
    End Sub
    Private Sub txtk0_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) _
        Handles txtk0.TextChanged, txtk1.TextChanged, txtk2.TextChanged, txtk3.TextChanged, txtk4.TextChanged, _
        txtk5.TextChanged, txtk6.TextChanged, txtk7.TextChanged, txtk8.TextChanged, txtd.TextChanged
        sender.SelectionStart = sender.Text.Length
    End Sub

    Private Sub btnCheck_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCheck.Click
        ValidateKernel()
    End Sub

    Public Function ValidateKernel() As Integer()
        Dim kern() As Integer
        ReDim kern(9)
        For Each txt As TextBox In grpK.Controls
            kern(txt.Name.Substring(4, 1)) = txt.Text
        Next
        kern(9) = txtd.Text
        Return kern
    End Function

    Public Sub SetKernel(ByVal kern() As Integer)
        Dim item As Integer
        For Each txt As TextBox In grpK.Controls
            txt.Text = kern(txt.Name.Substring(4, 1))
        Next
        txtd.Text = kern(9)
    End Sub

    Private Sub cmbKernel_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbKernel.SelectedIndexChanged
        Dim item As Integer
        For Each txt As TextBox In grpK.Controls
            txt.Text = kerns(cmbKernel.SelectedIndex, txt.Name.Substring(4, 1))
        Next
        txtd.Text = kerns(cmbKernel.SelectedIndex, 9)
    End Sub

    Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click
        If cboDestination.SelectedIndex = -1 Or cboSource.SelectedIndex = -1 Then
            Exit Sub
        End If
        Me.DialogResult = DialogResult.OK
        Me.Close()
    End Sub

    Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
        Me.DialogResult = DialogResult.Cancel
        Me.Close()
    End Sub

End Class

⌨️ 快捷键说明

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