📄 form1.vb
字号:
Imports System.Runtime.InteropServices
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
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'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.
Friend WithEvents AxAgent1 As AxAgentObjects.AxAgent
Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
Friend WithEvents cmdStop As System.Windows.Forms.Button
Friend WithEvents cmdPlay As System.Windows.Forms.Button
Friend WithEvents lstAnimations As System.Windows.Forms.ListBox
Friend WithEvents GroupBox2 As System.Windows.Forms.GroupBox
Friend WithEvents GroupBox3 As System.Windows.Forms.GroupBox
Friend WithEvents cmdClose As System.Windows.Forms.Button
Friend WithEvents cmdSpeak As System.Windows.Forms.Button
Friend WithEvents txtSpeak As System.Windows.Forms.TextBox
Friend WithEvents cmdMove As System.Windows.Forms.Button
Friend WithEvents txtX As System.Windows.Forms.TextBox
Friend WithEvents txtY As System.Windows.Forms.TextBox
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Label2 As System.Windows.Forms.Label
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(Form1))
Me.AxAgent1 = New AxAgentObjects.AxAgent()
Me.txtSpeak = New System.Windows.Forms.TextBox()
Me.GroupBox1 = New System.Windows.Forms.GroupBox()
Me.cmdStop = New System.Windows.Forms.Button()
Me.cmdPlay = New System.Windows.Forms.Button()
Me.lstAnimations = New System.Windows.Forms.ListBox()
Me.GroupBox2 = New System.Windows.Forms.GroupBox()
Me.GroupBox3 = New System.Windows.Forms.GroupBox()
Me.cmdClose = New System.Windows.Forms.Button()
Me.cmdSpeak = New System.Windows.Forms.Button()
Me.cmdMove = New System.Windows.Forms.Button()
Me.txtX = New System.Windows.Forms.TextBox()
Me.txtY = New System.Windows.Forms.TextBox()
Me.Label1 = New System.Windows.Forms.Label()
Me.Label2 = New System.Windows.Forms.Label()
CType(Me.AxAgent1, System.ComponentModel.ISupportInitialize).BeginInit()
Me.GroupBox1.SuspendLayout()
Me.GroupBox2.SuspendLayout()
Me.GroupBox3.SuspendLayout()
Me.SuspendLayout()
'
'AxAgent1
'
Me.AxAgent1.Enabled = True
Me.AxAgent1.Location = New System.Drawing.Point(328, 0)
Me.AxAgent1.Name = "AxAgent1"
Me.AxAgent1.OcxState = CType(resources.GetObject("AxAgent1.OcxState"), System.Windows.Forms.AxHost.State)
Me.AxAgent1.Size = New System.Drawing.Size(32, 32)
Me.AxAgent1.TabIndex = 0
'
'txtSpeak
'
Me.txtSpeak.AcceptsReturn = True
Me.txtSpeak.Location = New System.Drawing.Point(8, 20)
Me.txtSpeak.Multiline = True
Me.txtSpeak.Name = "txtSpeak"
Me.txtSpeak.Size = New System.Drawing.Size(232, 48)
Me.txtSpeak.TabIndex = 4
Me.txtSpeak.Text = ""
'
'GroupBox1
'
Me.GroupBox1.Anchor = (((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right)
Me.GroupBox1.Controls.AddRange(New System.Windows.Forms.Control() {Me.cmdStop, Me.cmdPlay, Me.lstAnimations})
Me.GroupBox1.FlatStyle = System.Windows.Forms.FlatStyle.System
Me.GroupBox1.Location = New System.Drawing.Point(8, 8)
Me.GroupBox1.Name = "GroupBox1"
Me.GroupBox1.Size = New System.Drawing.Size(384, 144)
Me.GroupBox1.TabIndex = 5
Me.GroupBox1.TabStop = False
Me.GroupBox1.Text = "Animate"
'
'cmdStop
'
Me.cmdStop.FlatStyle = System.Windows.Forms.FlatStyle.System
Me.cmdStop.Location = New System.Drawing.Point(248, 48)
Me.cmdStop.Name = "cmdStop"
Me.cmdStop.Size = New System.Drawing.Size(72, 20)
Me.cmdStop.TabIndex = 6
Me.cmdStop.Text = "Stop"
'
'cmdPlay
'
Me.cmdPlay.FlatStyle = System.Windows.Forms.FlatStyle.System
Me.cmdPlay.Location = New System.Drawing.Point(248, 24)
Me.cmdPlay.Name = "cmdPlay"
Me.cmdPlay.Size = New System.Drawing.Size(72, 20)
Me.cmdPlay.TabIndex = 5
Me.cmdPlay.Text = "Play"
'
'lstAnimations
'
Me.lstAnimations.Anchor = ((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
Or System.Windows.Forms.AnchorStyles.Left)
Me.lstAnimations.IntegralHeight = False
Me.lstAnimations.Location = New System.Drawing.Point(8, 21)
Me.lstAnimations.Name = "lstAnimations"
Me.lstAnimations.Size = New System.Drawing.Size(232, 110)
Me.lstAnimations.TabIndex = 4
'
'GroupBox2
'
Me.GroupBox2.Anchor = ((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right)
Me.GroupBox2.Controls.AddRange(New System.Windows.Forms.Control() {Me.cmdSpeak, Me.txtSpeak})
Me.GroupBox2.FlatStyle = System.Windows.Forms.FlatStyle.System
Me.GroupBox2.Location = New System.Drawing.Point(8, 160)
Me.GroupBox2.Name = "GroupBox2"
Me.GroupBox2.Size = New System.Drawing.Size(384, 80)
Me.GroupBox2.TabIndex = 6
Me.GroupBox2.TabStop = False
Me.GroupBox2.Text = "Speak"
'
'GroupBox3
'
Me.GroupBox3.Anchor = ((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right)
Me.GroupBox3.Controls.AddRange(New System.Windows.Forms.Control() {Me.Label2, Me.Label1, Me.txtY, Me.txtX, Me.cmdMove})
Me.GroupBox3.FlatStyle = System.Windows.Forms.FlatStyle.System
Me.GroupBox3.Location = New System.Drawing.Point(8, 248)
Me.GroupBox3.Name = "GroupBox3"
Me.GroupBox3.Size = New System.Drawing.Size(384, 64)
Me.GroupBox3.TabIndex = 7
Me.GroupBox3.TabStop = False
Me.GroupBox3.Text = "Move"
'
'cmdClose
'
Me.cmdClose.Anchor = (System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right)
Me.cmdClose.FlatStyle = System.Windows.Forms.FlatStyle.System
Me.cmdClose.Location = New System.Drawing.Point(295, 328)
Me.cmdClose.Name = "cmdClose"
Me.cmdClose.Size = New System.Drawing.Size(96, 24)
Me.cmdClose.TabIndex = 8
Me.cmdClose.Text = "Close"
'
'cmdSpeak
'
Me.cmdSpeak.FlatStyle = System.Windows.Forms.FlatStyle.System
Me.cmdSpeak.Location = New System.Drawing.Point(248, 20)
Me.cmdSpeak.Name = "cmdSpeak"
Me.cmdSpeak.Size = New System.Drawing.Size(72, 20)
Me.cmdSpeak.TabIndex = 6
Me.cmdSpeak.Text = "Speak"
'
'cmdMove
'
Me.cmdMove.FlatStyle = System.Windows.Forms.FlatStyle.System
Me.cmdMove.Location = New System.Drawing.Point(248, 24)
Me.cmdMove.Name = "cmdMove"
Me.cmdMove.Size = New System.Drawing.Size(72, 20)
Me.cmdMove.TabIndex = 7
Me.cmdMove.Text = "Move"
'
'txtX
'
Me.txtX.Location = New System.Drawing.Point(36, 24)
Me.txtX.Name = "txtX"
Me.txtX.Size = New System.Drawing.Size(36, 21)
Me.txtX.TabIndex = 8
Me.txtX.Text = ""
'
'txtY
'
Me.txtY.Location = New System.Drawing.Point(104, 24)
Me.txtY.Name = "txtY"
Me.txtY.Size = New System.Drawing.Size(36, 21)
Me.txtY.TabIndex = 9
Me.txtY.Text = ""
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(16, 28)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(20, 16)
Me.Label1.TabIndex = 10
Me.Label1.Text = "X:"
'
'Label2
'
Me.Label2.Location = New System.Drawing.Point(84, 28)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(20, 16)
Me.Label2.TabIndex = 11
Me.Label2.Text = "Y:"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 14)
Me.ClientSize = New System.Drawing.Size(400, 366)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.cmdClose, Me.GroupBox3, Me.GroupBox2, Me.GroupBox1, Me.AxAgent1})
Me.Font = New System.Drawing.Font("Tahoma", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Name = "Form1"
Me.Text = "Agent Test"
CType(Me.AxAgent1, System.ComponentModel.ISupportInitialize).EndInit()
Me.GroupBox1.ResumeLayout(False)
Me.GroupBox2.ResumeLayout(False)
Me.GroupBox3.ResumeLayout(False)
Me.ResumeLayout(False)
End Sub
#End Region
Private Controller As AgentController
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Controller = New AgentController(AxAgent1, "Genie")
lstAnimations.Items.AddRange(Controller.GetAnimations())
Controller.Show()
End Sub
Private Sub cmdPlay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdPlay.Click
Controller.Animate(lstAnimations.Text)
End Sub
Private Sub cmdStop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdStop.Click
Controller.StopAll()
End Sub
Private Sub cmdClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdClose.Click
Me.Close()
End Sub
Private Sub cmdSpeak_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSpeak.Click
Controller.Speak(txtSpeak.Text)
End Sub
Private Sub cmdMove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdMove.Click
Controller.MoveTo(Val(txtX.Text), Val(txtY.Text))
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -