defaultvb.aspx.vb

来自「Telerik是很大的第三方软件制造商」· VB 代码 · 共 179 行

VB
179
字号

Imports System
Imports System.Collections
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Web
Imports System.Web.SessionState
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls
Imports Telerik.QuickStart
Imports Telerik.WebControls


Namespace Telerik.CallbackExamplesVB.Controls.ImageButton
    '/ <summary>
    '/ Summary description for _Default.
    '/ </summary>

    Public Class DefaultVB
        Inherits XhtmlPage
        Protected TextBox1 As System.Web.UI.WebControls.TextBox
        Protected Label1 As System.Web.UI.WebControls.Label
        Protected Label2 As System.Web.UI.WebControls.Label
        Protected WithEvents label11 As System.Web.UI.WebControls.Label
        Protected WithEvents statusLabel As System.Web.UI.WebControls.Label
        Protected WithEvents LoadingPanel1 As Telerik.WebControls.LoadingPanel
        Protected WithEvents Img1 As System.Web.UI.HtmlControls.HtmlImage
        Protected WithEvents CallbackImageButton1 As Telerik.WebControls.CallbackImageButton


        Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
            If Not Page.IsPostBack Then
                Rows = 0
            End If
        End Sub 'Page_Load

#Region "Web Form Designer generated code"

        Protected Overrides Sub OnInit(ByVal e As EventArgs)
            '
            ' CODEGEN: This call is required by the ASP.NET Web Form Designer.
            '
            InitializeComponent()
            MyBase.OnInit(e)
        End Sub 'OnInit


        '/ <summary>
        '/		Required method for Designer support - do not modify
        '/		the contents of this method with the code editor.
        '/ </summary>
        Private Sub InitializeComponent()

        End Sub 'InitializeComponent

#End Region


        Private Property Rows() As Integer
            Get
                Return CInt(ViewState("Rows"))
            End Get
            Set(ByVal Value As Integer)
                ViewState("Rows") = Value
            End Set
        End Property


        Private Sub AddText(ByVal s As String)
            Rows += 1
            If Rows > 18 Then
                CallbackImageButton1.ResponseScript += String.Format("updateTextBox('{0}', true);", s)
                Rows = 0
            Else
                CallbackImageButton1.ResponseScript += String.Format("updateTextBox('{0}', false);", s)
            End If
        End Sub 'AddText

        Private Shared town() As String = {"Andora", "Monaco", "San Marino", "Vatikana"}
        Private Shared descr() As String = {"The site of Andorra la Vella (literally, ""Andorra the Old"") has been settled since prior to the Christian era, and it has been as the principal city of Andorra since 1278 when the French and the Episcopal co-princes agreed to joint suzerainty. In 1993, the country's first constitution established a parliamentary democracy with executive, legislative, and judicial branches located in Andorra la Vella.", "Monaco derives its name from the nearby Greek colony, Monoikos, founded in the 6th century BC by the Phoceans. According to an ancient myth, Hercules passed through the Monaco area. A temple was constructed there by Phoceans, the temple of Hercules Monoikos (Monoikos means single house or single temple).", "San Marino claims to be the world's oldest republic still in existence, being founded in A.D. 301 by a skilled builder referred to as St. Marinus. Its written constitution was adopted on October 8, 1600. The tiny nation was recognized by Napoleon's France in 1797, and by the other European nations at the 1815 Congress of Vienna.", "The city takes its name from Mons Vaticanus, also known as Vatican Hill. Mons Vaticanus and the adjacent Vatican Fields upon which St. Peter's Basilica and its Sistine Chapel, Apostolic Palace and museums were built, predates Christendom."}

        Private Shared Regions() As Rectangle = {Rectangle.FromLTRB(3, 75, 49, 116), Rectangle.FromLTRB(108, 47, 156, 78), Rectangle.FromLTRB(200, 28, 250, 68), Rectangle.FromLTRB(206, 79, 260, 119)}


        Private Function GetRectIndex(ByVal p As Point) As Integer
            Dim index As Integer = 0
            Dim rect As Rectangle
            For Each rect In Regions
                If rect.Contains(p) Then
                    Return index
                End If
                index += 1
            Next rect
            Return -1
        End Function 'GetRectIndex


        Private Sub CallbackImageButton1_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles CallbackImageButton1.Click
            Dim p As New Point(e.X, e.Y)
            AddText(("Image button is clicked on " + e.X.ToString() + ", " + e.Y.ToString()))
            Dim rectIndex As Integer = GetRectIndex(p)
            If rectIndex > -1 Then
                Label2.Text = town(rectIndex) + " - " + descr(rectIndex)
            Else
                Label2.Text = ""
            End If
        End Sub 'CallbackImageButton1_Click



        Private Sub CallbackImageButton1_Activate(ByVal sender As Object, ByVal e As System.EventArgs) Handles CallbackImageButton1.Activate

            AddText("Activated.")
        End Sub 'CallbackImageButton1_Activate


        Private Sub CallbackImageButton1_ContextMenuRequest(ByVal sender As Object, ByVal args As Telerik.WebControls.CallbackControls.MouseEventArgs) Handles CallbackImageButton1.ContextMenuRequest
            AddText("ContextMenuRequeted.")
        End Sub 'CallbackImageButton1_ContextMenuRequest


        Private Sub CallbackImageButton1_Deactivate(ByVal sender As Object, ByVal e As System.EventArgs) Handles CallbackImageButton1.Deactivate

            AddText("Deactivated.")
        End Sub 'CallbackImageButton1_Deactivate


        Private Sub CallbackImageButton1_GetFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles CallbackImageButton1.GetFocus
            AddText("Got focus.")
        End Sub 'CallbackImageButton1_GetFocus


        Private Sub CallbackImageButton1_HelpRequest(ByVal sender As Object, ByVal e As System.EventArgs)
            AddText("Help requested.")
        End Sub 'CallbackImageButton1_HelpRequest


        Private Sub CallbackImageButton1_KeyPress(ByVal sender As Object, ByVal args As Telerik.WebControls.CallbackControls.KeyEventArgs) Handles CallbackImageButton1.KeyPress
            AddText("Key press.")
        End Sub 'CallbackImageButton1_KeyPress


        Private Sub CallbackImageButton1_LoseFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles CallbackImageButton1.LoseFocus
            AddText("Focus lost.")
        End Sub 'CallbackImageButton1_LoseFocus


        Private Sub CallbackImageButton1_MouseDblClick(ByVal sender As Object, ByVal args As Telerik.WebControls.CallbackControls.MouseEventArgs) Handles CallbackImageButton1.MouseDblClick
            AddText("Mouse double click.")
        End Sub 'CallbackImageButton1_MouseDblClick


        Private Sub CallbackImageButton1_MouseDown(ByVal sender As Object, ByVal args As Telerik.WebControls.CallbackControls.MouseEventArgs)
            AddText("Mouse down.")
        End Sub 'CallbackImageButton1_MouseDown


        Private Sub CallbackImageButton1_MouseOut(ByVal sender As Object, ByVal args As Telerik.WebControls.CallbackControls.MouseEventArgs) Handles CallbackImageButton1.MouseOut
            AddText("Mouse out.")
        End Sub 'CallbackImageButton1_MouseOut


        Private Sub CallbackImageButton1_MouseOver(ByVal sender As Object, ByVal args As Telerik.WebControls.CallbackControls.MouseEventArgs) Handles CallbackImageButton1.MouseOver
            AddText("Mouse over.")
        End Sub 'CallbackImageButton1_MouseOver


        Private Sub CallbackImageButton1_MouseUp(ByVal sender As Object, ByVal args As Telerik.WebControls.CallbackControls.MouseEventArgs)
            AddText("Mouse up.")
        End Sub 'CallbackImageButton1_MouseUp


        Private Sub CallbackImageButton1_MouseWheel(ByVal sender As Object, ByVal args As Telerik.WebControls.CallbackControls.MouseEventArgs) Handles CallbackImageButton1.MouseWheel
            AddText("Mouse wheel.")
        End Sub 'CallbackImageButton1_MouseWheel
    End Class 'DefaultVB
End Namespace 'Telerik.CallbackExamplesVB.Controls.ImageButton

⌨️ 快捷键说明

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