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

📄 frmmain.vb

📁 大名鼎鼎的mono是.NET平台的跨平台(支持linux
💻 VB
📖 第 1 页 / 共 4 页
字号:
                If test IsNot Nothing Then                    result = frmNew.ShowDialog(Me, list.Path, test.Name)                Else                    result = frmNew.ShowDialog(Me, test.BasePath, "")                End If                If result = Windows.Forms.DialogResult.OK Then                    LoadTests(True)                End If            End Using        Catch ex As Exception            MsgBox(ex.Message & vbNewLine & ex.StackTrace)        End Try    End Sub    Private Sub CreateNewTestUsingThisTestAsBaseNameToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles CreateNewTestUsingThisTestAsBaseNameToolStripMenuItem.Click        NewTestToolStripMenuItem_Click(Nothing, Nothing)    End Sub    Private Sub treeTests_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles treeTests.AfterSelect        Try            Dim tests As Tests = GetSelectedTestList()            If tests IsNot Nothing Then                SelectTestList(tests.GetAllTestsInTree)            End If            UpdateSummary()        Catch ex As Exception            MsgBox(ex.Message & vbNewLine & ex.StackTrace)        End Try    End Sub    Private Sub treeTests_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles treeTests.DoubleClick        Try            Me.tabMain.SelectedTab = pageTests        Catch ex As Exception            MsgBox(ex.Message & vbNewLine & ex.StackTrace)        End Try    End Sub    Private Sub SelectTestList(ByVal Tests As Generic.IEnumerable(Of Test))        lstTests.BeginUpdate()        lstTests.Items.Clear()        Dim items As New Generic.List(Of ListViewItem)        For Each test As Test In Tests            Dim item As ListViewItem            item = m_TestView.GetListViewItem(test)            items.Add(item)        Next        lstTests.Items.AddRange(items.ToArray)        lstTests.EndUpdate()    End Sub    Private Sub SelectTest(ByVal Test As Test)        While Me.tabMain.TabPages.Count > 4            Me.tabMain.TabPages.Remove(Me.tabMain.TabPages(4))        End While        If Test Is Nothing Then            txtTestResult.Text = ""            txtMessage.Text = ""        Else            Test.Initialize()            If Test.Run Then                If Test.Success Then                    txtTestResult.Text = "Success"                Else                    txtTestResult.Text = "Failed"                End If            Else                txtTestResult.Text = "NotRun"            End If            txtMessage.Text = Test.FailedVerificationMessage            tabMain.Visible = False            For Each file As String In Test.Files                tabMain.TabPages.Add(New FileTabPage(file))            Next            If Test.ResponseFile <> "" Then tabMain.TabPages.Add(New FileTabPage(Test.ResponseFile))            If Test.RspFile <> "" Then tabMain.TabPages.Add(New FileTabPage(Test.RspFile))            tabMain.Visible = True            pageOldResults.Tag = Test        End If        gridTestProperties.SelectedObject = Test    End Sub    Private Function GetSelectedTestList() As Tests        Dim result As Tests = Nothing        If Me.treeTests.SelectedNode IsNot Nothing Then            result = TryCast(Me.treeTests.SelectedNode.Tag, Tests)        End If        Return result    End Function    Private Sub ViewQueuedTestsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ViewQueuedTestsToolStripMenuItem.Click        Try            Me.SelectTestList(m_TestExecutor.Queue)            Me.tabMain.SelectedTab = pageTests        Catch ex As Exception            MsgBox(ex.Message & vbNewLine & ex.StackTrace)        End Try    End Sub    Private Sub AllTestsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AllTestsToolStripMenuItem.Click        Try            Dim tests As Tests = Me.GetSelectedTestList            If tests IsNot Nothing Then                Me.m_TestExecutor.RunAsync(tests)            End If        Catch ex As Exception            MsgBox(ex.Message & vbNewLine & ex.StackTrace)        End Try    End Sub    Private Sub FailedTestsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FailedTestsToolStripMenuItem.Click        Try            Dim tests As Tests = Me.GetSelectedTestList            If tests IsNot Nothing Then                Me.m_TestExecutor.RunAsync(tests.GetRedTests)            End If        Catch ex As Exception            MsgBox(ex.Message & vbNewLine & ex.StackTrace)        End Try    End Sub    Private Sub SucceededTestsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SucceededTestsToolStripMenuItem.Click        Try            Dim tests As Tests = Me.GetSelectedTestList            If tests IsNot Nothing Then                Me.m_TestExecutor.RunAsync(tests.GetGreenTests)            End If        Catch ex As Exception            MsgBox(ex.Message & vbNewLine & ex.StackTrace)        End Try    End Sub    Private Sub NotRunTestsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NotRunTestsToolStripMenuItem.Click        Try            Dim tests As Tests = Me.GetSelectedTestList            If tests IsNot Nothing Then                Me.m_TestExecutor.RunAsync(tests.GetNotRunTests)            End If        Catch ex As Exception            MsgBox(ex.Message & vbNewLine & ex.StackTrace)        End Try    End Sub    Private Sub RunTestsToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RunTestsToolStripMenuItem1.Click        Try            Dim tests As Tests = Me.GetSelectedTestList            If tests IsNot Nothing Then                Me.m_TestExecutor.RunAsync(tests.GetRunTests)            End If        Catch ex As Exception            MsgBox(ex.Message & vbNewLine & ex.StackTrace)        End Try    End Sub    Private Sub m_TestExecutor_AfterExecute(ByVal Test As Test) Handles m_TestExecutor.AfterExecute        Try            If Me.InvokeRequired Then                Me.BeginInvoke(New TestExecutor.AfterExecuteDelegate(AddressOf m_TestExecutor_AfterExecute), Test)                Return            End If            UpdateSummary()            If Me.GetSelectedTest Is Test Then                lstTests_SelectedIndexChanged(lstTests, Nothing)            End If        Catch ex As Exception            MsgBox(ex.Message & vbNewLine & ex.StackTrace)        End Try    End Sub    Private Sub CreateNewTestInThisFolderToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CreateNewTestInThisFolderToolStripMenuItem.Click        NewTestToolStripMenuItem_Click(Nothing, Nothing)    End Sub    Private Sub chkDontTestIfNothingHasChanged_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkDontTestIfNothingHasChanged.CheckedChanged        Try            If m_Tests IsNot Nothing Then m_Tests.SkipCleanTests = chkDontTestIfNothingHasChanged.Checked        Catch ex As Exception            MsgBox(ex.Message & vbNewLine & ex.StackTrace)        End Try    End Sub    Private Sub OnlyRefreshToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OnlyRefreshToolStripMenuItem.Click        Try            Dim tests As Tests            tests = Me.GetSelectedTestList()            If tests IsNot Nothing Then                tests.Update()            End If            treeTests_AfterSelect(treeTests, New TreeViewEventArgs(treeTests.SelectedNode))        Catch ex As Exception            MsgBox(ex.Message & vbNewLine & ex.StackTrace)        End Try    End Sub    Private Sub lstOldResults_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles lstOldResults.SelectedIndexChanged        Try            If lstOldResults.SelectedItems.Count = 1 Then                Dim result As OldResult = TryCast(lstOldResults.SelectedItems(0).Tag, OldResult)                txtOldResult.Text = result.Text            End If        Catch ex As Exception            MsgBox(ex.Message & vbNewLine & ex.StackTrace)        End Try    End Sub    Private Sub LoadOldResults()        Static thread As Threading.Thread        Static sync As New Object        SyncLock sync            If thread Is Nothing Then                thread = New Threading.Thread(New Threading.ThreadStart(AddressOf LoadOldResults))                thread.Start()                Exit Sub            End If        End SyncLock        Try            Dim tests As Tests = m_Tests            Dim stack As New Generic.Queue(Of Tests)            stack.Enqueue(tests)            Do Until stack.Count = 0                tests = stack.Dequeue                For Each subtests As Tests In tests.ContainedTests                    stack.Enqueue(subtests)                Next                For Each test As Test In tests                    If Me.IsDisposed Then Exit Do                    Try                        Me.Invoke(New CrossAppDomainDelegate(AddressOf test.LoadOldResults))                    Catch ex As Exception                        Continue For                    End Try                    Threading.Thread.Sleep(0)                Next            Loop            thread = Nothing        Catch ex As Exception            MsgBox(ex.Message & vbNewLine & ex.StackTrace, MsgBoxStyle.Exclamation)        End Try    End Sub    Private Sub cmdSelfTest_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSelfTest.Click        Try            Static selfTests As Generic.List(Of Test)            If selfTests Is Nothing Then                selfTests = New Generic.List(Of Test)                For Each ts As Tests In m_Tests.ContainedTests                    If ts.Path.Contains("SelfTest") Then                        selfTests.AddRange(ts)                    End If                Next            End If            Me.ViewCode(selfTests)            Me.DebugTest(selfTests)            AddWork(selfTests, True)        Catch ex As System.Exception            MsgBox(ex.Message & vbNewLine & ex.StackTrace, MsgBoxStyle.Exclamation)        End Try    End Sub    Private Sub worker_DoWork(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles worker.DoWork        Try        Catch ex As System.Exception            MsgBox(ex.Message & vbNewLine & ex.StackTrace, MsgBoxStyle.Exclamation)        End Try    End Sub    Private Sub tabMain_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles tabMain.SelectedIndexChanged        Try            If tabMain.SelectedTab Is pageSummary Then                UpdateSummary()            ElseIf tabMain.SelectedTab Is pageOldResults Then                LoadOldTests()            End If        Catch ex As System.Exception            MsgBox(ex.Message & vbNewLine & ex.StackTrace, MsgBoxStyle.Exclamation)        End Try    End Sub    Private Sub LoadOldTests()        Dim oldResults As Generic.List(Of OldResult)        Dim oldResultsItem As New Generic.List(Of ListViewItem)        Dim Test As Test        lstOldResults.Items.Clear()        lstOldResults.Columns(1).Width = 600        Test = TryCast(pageOldResults.Tag, Test)        If Test Is Nothing Then Return        oldResults = Test.GetOldResults        For Each result As OldResult In oldResults            Dim newItem As New ListViewItem(result.Result.ToString)            newItem.SubItems.Add(result.Compiler)            newItem.Tag = result            Select Case result.Result                Case rt.Test.Results.Failed                    newItem.ImageIndex = Me.RedIconIndex                Case rt.Test.Results.NotRun                    newItem.ImageIndex = Me.YellowIconIndex                Case rt.Test.Results.Success                    newItem.ImageIndex = Me.GreenIconIndex            End Select            oldResultsItem.Add(newItem)        Next        oldResultsItem.Reverse()        lstOldResults.Items.AddRange(oldResultsItem.ToArray)        txtOldResult.Text = ""    End Sub    Private Sub frmMain_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load        Try            chkContinuous.Checked = My.Settings.ContinuousTest        Catch ex As Exception            MsgBox(ex.Message & vbNewLine & ex.StackTrace, MsgBoxStyle.Exclamation)        End Try    End SubEnd Class

⌨️ 快捷键说明

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