📄 form1.vb
字号:
Imports System.Net.Sockets
Imports System.Threading
<System.Runtime.InteropServices.ComVisibleAttribute(True)> _
Public Class Form1
Dim WithEvents user As WMClient
Private Sub Form1_Load( _
ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim fileContents As String
fileContents = My.Computer.FileSystem.ReadAllText( _
Application.StartupPath & "\VirtualEarth.html")
WebBrowser1.DocumentText = fileContents
WebBrowser1.ObjectForScripting = Me
WebBrowser2.DocumentText = fileContents
WebBrowser2.ObjectForScripting = Me
Dim t1 As New Thread(AddressOf ListenForConnections)
t1.Start()
End Sub
Private Sub ListenForConnections()
Const portNo As Integer = 3456
Dim localAdd As System.Net.IPAddress = _
System.Net.IPAddress.Parse("10.0.1.4")
Dim listener As New TcpListener(localAdd, portNo)
listener.Start()
While True
user = New WMClient(listener.AcceptTcpClient)
End While
End Sub
Private Sub LatLng( _
ByVal ID As Integer, _
ByVal lat As Double, _
ByVal lng As Double) _
Handles user.LatLng
'---display map at specific location---
Me.BeginInvoke(New _
mydelegate(AddressOf GotoLocation), _
New Object() {ID, lat, lng})
End Sub
Private Delegate Sub mydelegate( _
ByVal ID As Integer, _
ByVal lat As Double, _
ByVal lng As Double)
Private Sub GotoLocation( _
ByVal ID As Integer, _
ByVal lat As Double, _
ByVal lng As Double)
Console.WriteLine(lat & ":" & lng)
Dim param() As Object = New Object() {lat, lng}
If ID = 1 Then
txtLatitude_1.Text = lat
txtLongitude_1.Text = lng
WebBrowser1.Document.InvokeScript("goto_map_position", param)
ElseIf ID = 2 Then
txtLatitude_2.Text = lat
txtLongitude_2.Text = lng
WebBrowser2.Document.InvokeScript("goto_map_position", param)
End If
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -