⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmbusresult.vb

📁 地理信息系统二次开发实例教程VB.NET及源代码
💻 VB
字号:
Public Class frmBusResult
    Inherits System.Windows.Forms.Form

    Private _arrayResult As ArrayList = Nothing  ' 换乘方案结果
    Private _frmMain As MainForm = Nothing

#Region " Windows 窗体设计器生成的代码 "

    Public Sub New(ByVal frmMain As MainForm, ByVal result As ArrayList)
        MyBase.New()

        '该调用是 Windows 窗体设计器所必需的。
        InitializeComponent()

        '在 InitializeComponent() 调用之后添加任何初始化
        _frmMain = frmMain
        _arrayResult = result
    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 As System.Windows.Forms.Label
    Friend WithEvents _listBox As System.Windows.Forms.ListBox
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me._label = New System.Windows.Forms.Label()
        Me._listBox = New System.Windows.Forms.ListBox()
        Me.SuspendLayout()
        '
        '_label
        '
        Me._label.Font = New System.Drawing.Font("宋体", 10.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
        Me._label.Location = New System.Drawing.Point(16, 25)
        Me._label.Name = "_label"
        Me._label.Size = New System.Drawing.Size(224, 27)
        Me._label.TabIndex = 5
        Me._label.Text = "label1"
        '
        '_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.Font = New System.Drawing.Font("宋体", 10.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
        Me._listBox.Location = New System.Drawing.Point(16, 62)
        Me._listBox.Name = "_listBox"
        Me._listBox.Size = New System.Drawing.Size(304, 186)
        Me._listBox.TabIndex = 4
        '
        'frmBusResult
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
        Me.ClientSize = New System.Drawing.Size(336, 273)
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me._label, Me._listBox})
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow
        Me.Name = "frmBusResult"
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        Me.Text = "乘车路线查询结果"
        Me.ResumeLayout(False)

    End Sub

#End Region
    '---------------------------------------------------------------------
    Private Sub frmBusResult_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
        _label.Text = "总共查询到" + _arrayResult.Count.ToString() + "种方案"
        LoadListBox()
    End Sub
    '---------------------------------------------------------------------
    Private Sub LoadListBox()
        _listBox.Items.Clear()  ' 清除列表框
        Dim index As Integer = 1
        Dim i As Integer
        For i = 0 To _arrayResult.Count - 1
            Dim node As PathNode = _arrayResult(i)
            Dim str As String
            str = "第" + index.ToString() + "方案:"

            Dim j As Integer
            For j = 0 To node.nSegNumber - 1
                If j > 0 Then
                    str += ",转车,坐"
                Else
                    str += "坐"
                End If

                str += node.szRoutineName(j)
                str += "车,从"
                str += node.szFromStationName(j)
                str += "到"
                str += node.szToStationName(j)
            Next j

            _listBox.Items.Add(str)
            index = index + 1
        Next i
    End Sub
    '---------------------------------------------------------------------
    Private Sub _listBox_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles _listBox.DoubleClick
        If _listBox.SelectedIndex < 0 Then
            Return
        End If

        Dim node As PathNode = _arrayResult(_listBox.SelectedIndex)
        ReDim _frmMain._environment.m_drawLine(node.nSegNumber - 1)

        _frmMain._environment.m_buses = New Buses()
        Dim nCount As Integer = 0
        Dim bBus As Boolean = True

        Dim j As Integer
        For j = 0 To node.nSegNumber - 1
            Dim moline As MapObjects2.Line
            moline = _frmMain._environment.GetLine(node.szRoutineName(j))
            If moline Is Nothing Then
                _frmMain._environment.m_drawLine = Nothing
                _frmMain._environment.m_buses = Nothing

                _frmMain.Map.Extent = _frmMain.Map.Extent
                Return
            End If
            Dim pt As MapObjects2.Point
            Dim pt1 As New MPoint()
            Dim pt2 As New MPoint()

            pt = _frmMain._environment.GetPoint(node.szFromStationName(j))
            If pt Is Nothing Then
                _frmMain._environment.m_drawLine = Nothing
                _frmMain._environment.m_buses = Nothing
                _frmMain.Map.Extent = _frmMain.Map.Extent
                Return
            End If

            pt1.x = pt.X
            pt1.y = pt.Y
            pt = _frmMain._environment.GetPoint(node.szToStationName(j))
            If pt Is Nothing Then
                _frmMain._environment.m_drawLine = Nothing
                _frmMain._environment.m_buses = Nothing
                _frmMain.Map.Extent = _frmMain.Map.Extent
                Return
            End If

            pt2.x = pt.X
            pt2.y = pt.Y

            Dim line As MLine = _frmMain._environment.CreateLine(moline)
            Dim busLine As New CBusLine()
            _frmMain._environment.m_drawLine(j) = New MLine()
            busLine.CutLine(line, pt1, pt2, _frmMain._environment.m_drawLine(j))

            If bBus Then
                bBus = _frmMain._environment.GetStation(node, j, _frmMain._environment.m_buses, nCount)
            End If
        Next

        If Not bBus Then
            _frmMain._environment.m_buses = Nothing
        Else
            _frmMain._environment.m_buses.nNum = nCount
        End If

        _frmMain.Map.CenterAt(_frmMain._environment.m_drawLine(0).pPoint(0).x, _
                              _frmMain._environment.m_drawLine(0).pPoint(0).y)
        _frmMain.Map.RefreshLayer(0, _frmMain.Map.Extent)
        _frmMain._mapEye.Extent = _frmMain._mapEye.Extent
    End Sub
    '---------------------------------------------------------------------
End Class

⌨️ 快捷键说明

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