📄 frmline.vb
字号:
Public Class frmLine
Inherits System.Windows.Forms.Form
Private _frmMain As MainForm = Nothing
Private _szLineName As String = ""
#Region " Windows 窗体设计器生成的代码 "
Public Sub New(ByVal frmMain As MainForm, ByVal lineName As String)
MyBase.New()
'该调用是 Windows 窗体设计器所必需的。
InitializeComponent()
'在 InitializeComponent() 调用之后添加任何初始化
_frmMain = frmMain
_szLineName = lineName
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 _label_transfline As System.Windows.Forms.Label
Friend WithEvents _label_Sta As System.Windows.Forms.Label
Friend WithEvents _listBox_Line As System.Windows.Forms.ListBox
Friend WithEvents _listBox_sta As System.Windows.Forms.ListBox
Friend WithEvents _label_line As System.Windows.Forms.Label
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me._label_transfline = New System.Windows.Forms.Label()
Me._label_Sta = New System.Windows.Forms.Label()
Me._listBox_Line = New System.Windows.Forms.ListBox()
Me._listBox_sta = New System.Windows.Forms.ListBox()
Me._label_line = New System.Windows.Forms.Label()
Me.SuspendLayout()
'
'_label_transfline
'
Me._label_transfline.Font = New System.Drawing.Font("宋体", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me._label_transfline.Location = New System.Drawing.Point(160, 32)
Me._label_transfline.Name = "_label_transfline"
Me._label_transfline.Size = New System.Drawing.Size(128, 16)
Me._label_transfline.TabIndex = 14
Me._label_transfline.Text = "在此站可转的车:"
'
'_label_Sta
'
Me._label_Sta.Font = New System.Drawing.Font("宋体", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me._label_Sta.Location = New System.Drawing.Point(8, 32)
Me._label_Sta.Name = "_label_Sta"
Me._label_Sta.Size = New System.Drawing.Size(128, 16)
Me._label_Sta.TabIndex = 13
Me._label_Sta.Text = "经过的公交车站:"
'
'_listBox_Line
'
Me._listBox_Line.ItemHeight = 12
Me._listBox_Line.Location = New System.Drawing.Point(160, 48)
Me._listBox_Line.Name = "_listBox_Line"
Me._listBox_Line.Size = New System.Drawing.Size(128, 196)
Me._listBox_Line.TabIndex = 12
'
'_listBox_sta
'
Me._listBox_sta.ItemHeight = 12
Me._listBox_sta.Location = New System.Drawing.Point(8, 48)
Me._listBox_sta.Name = "_listBox_sta"
Me._listBox_sta.Size = New System.Drawing.Size(144, 196)
Me._listBox_sta.TabIndex = 11
'
'_label_line
'
Me._label_line.Font = New System.Drawing.Font("宋体", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me._label_line.Location = New System.Drawing.Point(8, 8)
Me._label_line.Name = "_label_line"
Me._label_line.Size = New System.Drawing.Size(248, 24)
Me._label_line.TabIndex = 10
Me._label_line.Text = "公交路线:"
'
'frmLine
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(296, 253)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me._label_transfline, Me._label_Sta, Me._listBox_Line, Me._listBox_sta, Me._label_line})
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow
Me.MaximizeBox = False
Me.MinimizeBox = False
Me.Name = "frmLine"
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent
Me.Text = "公交路线信息"
Me.TopMost = True
Me.ResumeLayout(False)
End Sub
#End Region
'---------------------------------------------------------------------
Private Sub frmLine_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
_label_line.Text = "线路名称:" + _szLineName
LoadStationListBox()
End Sub
'---------------------------------------------------------------------
Private Sub LoadStationListBox()
_listBox_sta.Items.Clear()
If "" = _szLineName Then
Return
End If
Dim typeTbl As System.Data.DataTable = _frmMain._environment.m_dataSet.Tables("公交车站路线")
Dim rowstypes As System.Data.DataRow() = typeTbl.Select("线路名='" + _szLineName + "'", "顺序")
Dim nIndex As Integer = 1
Dim myRow As System.Data.DataRow
For Each myRow In rowstypes
_listBox_sta.Items.Add(myRow("站名"))
nIndex = nIndex + 1
Next
End Sub
'---------------------------------------------------------------------
Private Sub _listBox_sta_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles _listBox_sta.SelectedIndexChanged
If _listBox_sta.Text <> "" Then
LoadLineList(_listBox_sta.Text)
End If
End Sub
'---------------------------------------------------------------------
Private Sub LoadLineList(ByVal szStaName As String)
If "" = szStaName Then
Return
End If
_listBox_Line.Items.Clear()
Dim typeTbl As System.Data.DataTable = _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_Line.Items.Add(myRow("线路名"))
Next
End Sub
'---------------------------------------------------------------------
Private Sub _listBox_sta_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles _listBox_sta.DoubleClick
Dim szName As String = _listBox_sta.Text
Dim szLayer As String = _frmMain._environment.GetLayerName(szName, "地名索引")
Dim szTable As String = _frmMain._environment.GetTableName(szName, "地名索引")
Dim nIndex As Integer = _frmMain._environment.GetLayerIndexByName(szTable)
If nIndex < 0 Then
Return
End If
Dim rs As MapObjects2.Recordset
rs = _frmMain._environment.m_layerInfos(nIndex).layer.SearchExpression("名称 like '" + szName + "'")
If Not rs Is Nothing Then
rs.MoveFirst()
If Not rs.EOF Then
Dim pt As MapObjects2.Point = rs.Fields.Item("shape").Value
If Not _frmMain.IsWithin(_frmMain.Map.Extent, pt) Then
_frmMain.Map.CenterAt(pt.X, pt.Y)
End If
If _frmMain._environment.m_layerInfos(nIndex).nCharacterIndex >= 0 And _
_frmMain._environment.m_layerInfos(nIndex).layer.shapeType = MapObjects2.ShapeTypeConstants.moShapeTypePoint Then
_frmMain._environment.m_selectedSymbol = New MapObjects2.Symbol()
_frmMain._environment.m_selectedSymbol.SymbolType = MapObjects2.SymbolTypeConstants.moPointSymbol
_frmMain._environment.m_selectedSymbol.Font.Name = _frmMain._environment.m_layerInfos(nIndex).szFontName
_frmMain._environment.m_selectedSymbol.Style = 4
_frmMain._environment.m_selectedSymbol.Size = _frmMain._environment.m_layerInfos(nIndex).nSymSize
_frmMain._environment.m_selectedSymbol.CharacterIndex = _frmMain._environment.m_layerInfos(nIndex).nCharacterIndex
_frmMain._environment.m_selectedSymbol.Color = System.Convert.ToUInt32(MapObjects2.ColorConstants.moRed)
Else
_frmMain._environment.m_selectedSymbol = Nothing
End If
_frmMain._environment.m_selectedFeature = rs.Fields.Item("shape").Value
_frmMain.Map.FlashShape(_frmMain._environment.m_selectedFeature, 4)
_frmMain.Map.Extent = _frmMain.Map.Extent
End If
End If
End Sub
'---------------------------------------------------------------------
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -