📄 frmmain.vb
字号:
MyBase.Dispose(disposing) If m_Tests IsNot Nothing Then m_Tests.Dispose() m_Tests = Nothing End If If m_TestExecutor IsNot Nothing Then m_TestExecutor.Dispose() m_TestExecutor = Nothing End If End Sub Private Sub frmMain_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing Try StopWork() If m_Tests IsNot Nothing Then m_Tests.Dispose() m_Tests = Nothing End If My.Settings.TestsListView_colCompiler_Width = colCompiler.Width My.Settings.TestsListView_colDate_Width = colDate.Width My.Settings.TestsListView_colFailedVerification_Width = colFailedVerification.Width My.Settings.TestsListView_colName_Width = colName.Width My.Settings.TestsListView_colResult_Width = colResult.Width My.Settings.TestsListView_colPath_Width = colPath.Width My.Settings.txtVBCCompiler_Text = cmbCompiler.Text My.Settings.txtVBNCCompiler_Text = cmbVBCCompiler.Text My.Settings.txtBasePath_Text = cmbBasepath.Text My.Settings.ContinuousTest = chkContinuous.Checked My.Settings.Save() Catch ex As Exception MsgBox(ex.Message & vbNewLine & ex.StackTrace) End Try End Sub Private Sub cmnuViewFile_Items_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Try Dim item As ToolStripMenuItem item = TryCast(sender, ToolStripMenuItem) If item IsNot Nothing Then 'Process.Start("notepad.exe", """" & item.Text & """") Process.Start("""" & item.Text & """") End If Catch ex As Exception MsgBox(ex.Message & vbNewLine & ex.StackTrace) End Try End Sub Private Sub mnuToolsRefresh_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuToolsRefresh.Click Try cmdRefresh_Click(sender, e) Catch ex As Exception MsgBox(ex.Message & vbNewLine & ex.StackTrace) End Try End Sub Private Sub cmdStop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdStop.Click Try m_TestExecutor.Stop() UpdateState() Catch ex As Exception MsgBox(ex.Message & vbNewLine & ex.StackTrace) End Try End Sub Private Sub cmdRerunGreen_Click(ByVal sender As Object, ByVal e As System.EventArgs) Try For Each t As Test In m_Tests.GetGreenTests AddWork(t, False) Next UpdateState() Catch ex As Exception MsgBox(ex.Message & vbNewLine & ex.StackTrace) End Try End Sub Private Sub cmdRerunRed_Click(ByVal sender As Object, ByVal e As System.EventArgs) Try For Each t As Test In m_Tests.GetRedTests AddWork(t, False) Next UpdateState() Catch ex As Exception MsgBox(ex.Message & vbNewLine & ex.StackTrace) End Try End Sub Private Sub cmdRerunYellow_Click(ByVal sender As Object, ByVal e As System.EventArgs) Try For Each t As Test In m_Tests.GetNotRunTests AddWork(t, False) Next UpdateState() Catch ex As Exception MsgBox(ex.Message & vbNewLine & ex.StackTrace) End Try End Sub Private Sub cmnuViewCodeAndDebugTest_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmnuViewCodeAndDebugTest.Click Try cmnuViewCode2.PerformClick() cmnuDebugTest.PerformClick() Catch ex As Exception MsgBox(ex.Message & vbNewLine & ex.StackTrace) End Try End Sub Private Sub ViewCode(ByVal Tests As Generic.List(Of Test)) For Each test As Test In Tests MainModule.ViewFiles(test.Files.ToArray) Next End Sub Private Sub DebugTest(ByVal Tests As Generic.List(Of Test)) If Tests.Count <> 1 Then MsgBox("Select only one test, please.", MsgBoxStyle.Information Or MsgBoxStyle.OkOnly) Return End If Dim test As Test = Tests(0) Dim strTestFile As String strTestFile = "/Debug" & vbNewLine For Each str As String In test.GetTestCommandLineArguments strTestFile &= """" & str & """" & vbNewLine Next IO.File.WriteAllText("..\..\vbnc\bin\debug.rsp", strTestFile) End Sub Private Sub cmdCopySummaryToClipboard_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCopySummaryToClipboard.Click Try Dim str As New System.Text.StringBuilder Dim t, r, g As Integer t = Tests.RecursiveCount r = Tests.GetRedRecursiveCount g = Tests.GetGreenRecursiveCount str.AppendLine("# of Tests: " & t.ToString) str.AppendLine("# of Tests (Successful): " & g.ToString & " = " & (g / t).ToString("0.0%")) str.AppendLine("# of Tests (Failed): " & r.ToString & " = " & (r / t).ToString("0.0%")) str.AppendLine("# of Tests (NotRun): " & (t - r - g).ToString & " = " & ((t - r - g) / t).ToString("0.0%")) Clipboard.SetText(str.ToString) Catch ex As Exception MsgBox(ex.Message & vbNewLine & ex.StackTrace) End Try End Sub Private Sub cmdVBCCompiler_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdVBCCompiler.Click Try dlgFile.FileName = cmbVBCCompiler.Text Dim tmpFilter As String = dlgFile.Filter dlgFile.Filter = "vbc.exe|vbc.exe|All files (*.*)|*.*" If dlgFile.ShowDialog = Windows.Forms.DialogResult.OK Then cmbVBCCompiler.Text = dlgFile.FileName End If dlgFile.Filter = tmpFilter Catch ex As Exception MsgBox(ex.Message) End Try End Sub Private Sub cmdReload_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdReload.Click Try LoadTests() Catch ex As Exception MsgBox(ex.Message & vbNewLine & ex.StackTrace) End Try End Sub Private Sub CreateNewTestToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CreateNewTestToolStripMenuItem.Click Try Dim tests As Tests = Me.GetSelectedTestList Using frmEditor As New frmTestEditor frmEditor.txtFolder.Text = tests.Path If frmEditor.ShowDialog(Me) = 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 CreateNewTestCopyingThisTestToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CreateNewTestCopyingThisTestToolStripMenuItem.Click Try Dim t As Test = Me.GetSelectedTest() If t Is Nothing Then MsgBox("No selected test!") ElseIf t.IsMultiFile Then MsgBox("This is a multifile test!") Else Using frmEditor As New frmTestEditor frmEditor.txtFolder.Text = t.BasePath Dim newName As String Dim base As String = IO.Path.Combine(t.BasePath, IO.Path.GetFileNameWithoutExtension(t.Files(0))) Dim i As Integer = 1 Do While IsNumeric(base.Chars(base.Length - 1)) base = base.Substring(0, base.Length - 1) Loop newName = base & i.ToString & ".vb" Do While IO.File.Exists(newName) i += 1 newName = base & i.ToString & ".vb" Loop frmEditor.txtCode.Text = IO.File.ReadAllText(t.Files(0)) frmEditor.txtFile.Text = IO.Path.GetFileName(newName) If frmEditor.ShowDialog(Me) = Windows.Forms.DialogResult.OK Then LoadTests(True) End If End Using End If Catch ex As Exception MsgBox(ex.Message & vbNewLine & ex.StackTrace) End Try End Sub Private Sub EditThisTestToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EditThisTestToolStripMenuItem.Click Try Dim t As Test = Me.GetSelectedTest() If t Is Nothing Then MsgBox("No selected test!") ElseIf t.IsMultiFile Then MsgBox("This is a multifile test!") Else Using frmEditor As New frmTestEditor frmEditor.txtFolder.Text = cmbBasepath.Text frmEditor.txtFile.Text = IO.Path.GetFileName(t.Files(0)) frmEditor.txtCode.Text = IO.File.ReadAllText(t.Files(0)) If frmEditor.ShowDialog(Me) = Windows.Forms.DialogResult.OK Then LoadTests() End If End Using End If Catch ex As Exception MsgBox(ex.Message & vbNewLine & ex.StackTrace) End Try End Sub Private Sub chkHosted_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkHosted.CheckedChanged Try If m_Tests IsNot Nothing Then m_TestExecutor.RunTestsHosted = chkHosted.Checked End If Catch ex As Exception MsgBox(ex.Message & vbNewLine & ex.StackTrace) End Try End Sub Private Sub BothAssembliesToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BothAssembliesToolStripMenuItem.Click Try Dim vbc, vbnc As String Dim test As Test = GetSelectedTest() If test Is Nothing Then MsgBox("Select a test") Return End If vbc = test.GetOutputVBCAssembly vbnc = test.GetOutputAssembly Process.Start(GetReflectorPath, """" & vbc & """ """ & vbnc & """") Catch ex As Exception MsgBox(ex.Message & vbNewLine & ex.StackTrace) End Try End Sub Private Function GetReflectorPath() As String Dim path As String path = GetSetting(Application.ProductName, Me.Name, "Reflector", Environment.ExpandEnvironmentVariables("%PROGRAMFILES%\Reflector\Reflector.exe")) If IO.File.Exists(path) = False Then path = InputBox("Path of reflector: ") End If If path <> "" Then SaveSetting(Application.ProductName, Me.Name, "Reflector", path) End If Return path End Function Private Sub VBNCAssemblyToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles VBNCAssemblyToolStripMenuItem.Click Try Dim vbnc As String Dim test As Test = GetSelectedTest() If test Is Nothing Then MsgBox("Select a test") Return End If vbnc = test.GetOutputAssembly Process.Start(GetReflectorPath, """" & vbnc & """") Catch ex As Exception MsgBox(ex.Message & vbNewLine & ex.StackTrace) End Try End Sub Private Sub VBCAssemblyToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles VBCAssemblyToolStripMenuItem.Click Try Dim vbc As String Dim test As Test = GetSelectedTest() If test Is Nothing Then MsgBox("Select a test") Return End If vbc = test.GetOutputVBCAssembly Process.Start(GetReflectorPath, """" & vbc & """") Catch ex As Exception MsgBox(ex.Message & vbNewLine & ex.StackTrace) End Try End Sub Private Sub tmrContinuous_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrContinuous.Tick Try If chkContinuous.Checked Then If m_TestExecutor IsNot Nothing AndAlso m_TestExecutor.QueueCount = 0 AndAlso m_Tests IsNot Nothing Then m_TestExecutor.RunAsyncTree(m_Tests) End If End If Catch ex As Exception MsgBox(ex.Message & vbNewLine & ex.StackTrace) End Try End Sub Private Sub NewTestToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NewTestToolStripMenuItem.Click Try Dim test As Test = Me.GetSelectedTest Dim list As Tests = Me.GetSelectedTestList Using frmNew As New frmNewTest Dim result As DialogResult
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -