?? frmstation.vb
字號:
Public Class frmStation
Inherits System.Windows.Forms.Form
Private _frmMain As MainForm
Private _szStaName As String
#Region " Windows 窗體設計器生成的代碼 "
Public Sub New(ByVal frmMain As MainForm, ByVal stationName As String)
MyBase.New()
'該調(diào)用是 Windows 窗體設計器所必需的
InitializeComponent()
'在 InitializeComponent() 調(diào)用之后添加任何初始化
_frmMain = frmMain
_szStaName = stationName
End Sub
'窗體重寫處置以清理組件列表。
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
'Windows 窗體設計器所必需的
Private components As System.ComponentModel.IContainer
'注意:以下過程是 Windows 窗體設計器所必需的
'可以使用 Windows 窗體設計器修改此過程。
'不要使用代碼編輯器修改它。
Friend WithEvents button1 As System.Windows.Forms.Button
Friend WithEvents _label2 As System.Windows.Forms.Label
Friend WithEvents _label_Statation As System.Windows.Forms.Label
Friend WithEvents _listBox As System.Windows.Forms.ListBox
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.button1 = New System.Windows.Forms.Button()
Me._label2 = New System.Windows.Forms.Label()
Me._label_Statation = New System.Windows.Forms.Label()
Me._listBox = New System.Windows.Forms.ListBox()
Me.SuspendLayout()
'
'button1
'
Me.button1.Enabled = False
Me.button1.Location = New System.Drawing.Point(190, 2)
Me.button1.Name = "button1"
Me.button1.Size = New System.Drawing.Size(56, 24)
Me.button1.TabIndex = 11
Me.button1.Text = "定位"
'
'_label2
'
Me._label2.Anchor = ((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right)
Me._label2.Font = New System.Drawing.Font("宋體", 10.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me._label2.Location = New System.Drawing.Point(24, 32)
Me._label2.Name = "_label2"
Me._label2.Size = New System.Drawing.Size(164, 24)
Me._label2.TabIndex = 10
'
'_label_Statation
'
Me._label_Statation.Anchor = ((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right)
Me._label_Statation.Font = New System.Drawing.Font("宋體", 10.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me._label_Statation.Location = New System.Drawing.Point(24, 8)
Me._label_Statation.Name = "_label_Statation"
Me._label_Statation.Size = New System.Drawing.Size(164, 24)
Me._label_Statation.TabIndex = 9
'
'_listBox
'
Me._listBox.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._listBox.ItemHeight = 12
Me._listBox.Location = New System.Drawing.Point(24, 64)
Me._listBox.Name = "_listBox"
Me._listBox.Size = New System.Drawing.Size(168, 172)
Me._listBox.TabIndex = 8
'
'frmStation
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(256, 245)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.button1, Me._label2, Me._label_Statation, Me._listBox})
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow
Me.MaximizeBox = False
Me.MinimizeBox = False
Me.Name = "frmStation"
Me.Text = "車站信息"
Me.TopMost = True
Me.ResumeLayout(False)
End Sub
#End Region
'---------------------------------------------------------------------
Private Sub frmStation_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
_label_Statation.Text = " 車站名稱:" + _szStaName
_label2.Text = "經(jīng)過" + _szStaName + "的公交線路:"
LoadListBox()
End Sub
'---------------------------------------------------------------------
Private Sub LoadListBox()
_listBox.Items.Clear()
If "" = _szStaName Then
Return
End If
Dim typeTbl As System.Data.DataTable
typeTbl = _frmMain._environment.m_dataSet.Tables("公交車站路線")
Dim szFilter As String = "站名='" + _szStaName + "'"
If _frmMain._environment.m_szBusFilter <> "" Then
szFilter += " And "
szFilter += _frmMain._environment.m_szBusFilter
End If
Dim rowstypes As System.Data.DataRow() = typeTbl.Select(szFilter)
Dim myRow As System.Data.DataRow
For Each myRow In rowstypes
_listBox.Items.Add(myRow("線路名"))
Next
End Sub
'---------------------------------------------------------------------
Private Sub button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button1.Click
Dim szName As String = _listBox.Text ' 公交路線名稱
Dim szLayer As String = CEnvironment.BUSLINE_LAYERNAME '公交路線所在圖層名稱
Dim ly As MapObjects2.MapLayer = _frmMain.Map.Layers.Item(szLayer)
If ly Is Nothing Then
Return
End If
Dim rs As MapObjects2.Recordset = ly.SearchExpression("名稱 like '" + szName + "'")
If rs Is Nothing Then
MessageBox.Show("地圖上沒有這條公交線路!", _
"北京市地理信息公眾查詢系統(tǒng)", _
MessageBoxButtons.OK, MessageBoxIcon.Error)
Return
End If
rs.MoveFirst()
If rs.EOF Then
MessageBox.Show("地圖上沒有這條公交線路!", _
"北京市地理信息公眾查詢系統(tǒng)", _
MessageBoxButtons.OK, MessageBoxIcon.Error)
Return
End If
' 在地圖找到了這條線路,畫出來
' 首先定位
Dim pt As MapObjects2.Point
Dim line As MapObjects2.Line = rs.Fields.Item("shape").Value
pt = line.Extent.Center
If Not _frmMain.IsWithin(_frmMain.Map.Extent, pt) Then
_frmMain.Map.CenterAt(pt.X, pt.Y)
End If
' 其次設置_environment.m_drawLine和_environment.m_buses
Dim pts As MapObjects2.Points
pts = line.Parts.Item(0)
_frmMain._environment.m_drawLine = Nothing
ReDim _frmMain._environment.m_drawLine(0)
_frmMain._environment.m_drawLine(0) = New MLine()
_frmMain._environment.m_drawLine(0).nPointNumber = pts.Count
ReDim _frmMain._environment.m_drawLine(0).pPoint(pts.Count - 1)
Dim i As Integer
For i = 0 To pts.Count - 1
pt = pts.Item(i)
_frmMain._environment.m_drawLine(0).pPoint(i) = New MPoint()
_frmMain._environment.m_drawLine(0).pPoint(i).x = pt.X
_frmMain._environment.m_drawLine(0).pPoint(i).y = pt.Y
Next
_frmMain._environment.m_buses = New Buses()
Dim nCount As Integer = 0
If Not _frmMain._environment.GetStation(szName, _frmMain._environment.m_buses, nCount) Then
_frmMain._environment.m_buses = Nothing
Else
_frmMain._environment.m_buses.nNum = nCount
End If
' 閃爍,重畫
_frmMain.Map.FlashShape(rs.Fields.Item("shape").Value, 4)
_frmMain.Map.Extent = _frmMain.Map.Extent
End Sub
'---------------------------------------------------------------------
Private Sub _listBox_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles _listBox.DoubleClick
If _listBox.Text = "" Then
Return
End If
Dim frm As New frmLine(_frmMain, _listBox.Text)
Visible = False
frm.ShowDialog(_frmMain)
Close()
End Sub
'---------------------------------------------------------------------
Private Sub _listBox_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles _listBox.SelectedIndexChanged
button1.Enabled = True
End Sub
'---------------------------------------------------------------------
End Class
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -