16,717
社区成员
发帖
与我相关
我的任务
分享 Private Sub menuSetting_Setting_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles menuSetting_Setting.Click
frmSetting.ShowDialog(Me)
m_Tester.SetFactModel(m_FactModel) '设置完后也要更新厂商型号
End SubPublic Class frmSetting
Private m_Form As Control
Private Sub frmSetting_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
CType(m_Form, Form).Close() '在关闭前先关闭当前设置窗体,触发当前窗体的Close事件
End Sub
Private Sub frmSetting_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Me.ShowInTaskbar = False
Me.Show()
Me.AutoScroll = True
TableLayoutPanel1.Dock = DockStyle.Fill
SetBtnColor(btnSetStep)
My.Computer.FileSystem.CopyFile(fName1, fNameTmp1, True) '创建临时文件
My.Computer.FileSystem.CopyFile(fName2, fNameTmp2, True)
LoadForm(frmSettingStep)
End Sub
Private Sub btn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSetStep.Click, btnTPLStep.Click, btnTPLCmp.Click, btnSystem.Click, btnExit.Click
If sender.Equals(btnSetStep) Then '步骤设置
SetBtnColor(btnSetStep)
LoadForm(frmSettingStep)
ElseIf sender.Equals(btnTPLStep) Then '步骤模板设置
SetBtnColor(btnTPLStep)
LoadForm(frmSettingTPLStep)
ElseIf sender.Equals(btnTPLCmp) Then '对比模板设置
SetBtnColor(btnTPLCmp)
LoadForm(frmSettingTPLCmp)
ElseIf sender.Equals(btnSystem) Then '系统变量设置
SetBtnColor(btnSystem)
LoadForm(frmSettingSystem)
ElseIf sender.Equals(btnExit) Then '退出
Me.Close()
End If
End Sub
Private Sub SetBtnColor(ByVal currentButton As Button)
Dim btn As Button
For Each btn In GBoxButton.Controls
btn.BackColor = Color.Empty
Next
currentButton.BackColor = Color.GreenYellow
End Sub
Private Sub LoadForm(ByVal ctlForm As Control)
If Not ctlForm.Equals(m_Form) Then
UnloadCurrentForm()
m_Form = ctlForm
LoadSubForm(m_Form, Me.GroupBox1)
End If
End Sub
Private Sub UnloadCurrentForm()
If Not m_Form Is Nothing Then
CType(m_Form, Form).Close() '用Form.close才能引发Form.closing事件
End If
End Sub
End Class