asked on
Imports System.IO
Imports System.ComponentModel
Imports System.Threading
Imports System.Diagnostics
Public Class frmEtchOMatic
Private Const SourceFolder As String = "C:\Program Files\VisualLaserMarker\MarkingFiles"
Private _bsFiles As New BindingSource()
Private _dtFiles As New DataTable()
Private Sub frmEtchOMatic_Load(sender As Object, e As EventArgs) Handles MyBase.Load
If Not Directory.Exists(SourceFolder) Then Throw New Exception("Folder doesn't exist")
_dtFiles.Columns.Add("FilePath")
_dtFiles.Columns.Add("FileName")
RefreshFiles()
_bsFiles.DataSource = _dtFiles
lstPartNum.DisplayMember = "FileName"
lstPartNum.ValueMember = "FilePath"
lstPartNum.DataSource = _bsFiles
Me.Show()
txtPartNum.Focus()
Me.Text = "Etch-O-Matic " & String.Format("Version {0}", My.Application.Info.Version.ToString)
End Sub
Private Sub RefreshFiles()
'loop around each path and loads the files.
For Each filePath As String In IO.Directory.GetFiles(SourceFolder, "*.*", SearchOption.AllDirectories).Where(Function(x)
Return (New String() {".vlm", ".VLM"}).
Contains(System.IO.Path.GetExtension(x))
End Function)
_dtFiles.Rows.Add(New Object() {filePath, IO.Path.GetFileName(IO.Path.GetFileName(filePath))})
Next
End Sub
Private Sub txtPartNum_TextChanged(sender As Object, e As EventArgs) Handles txtPartNum.TextChanged
If String.IsNullOrWhiteSpace(txtPartNum.Text) Then
_bsFiles.RemoveFilter()
Else
_bsFiles.Filter = String.Format("FileName LIKE '%{0}%'", txtPartNum.Text)
End If
End Sub
Private Sub txtPartNum_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtPartNum.KeyPress
If e.KeyChar = Microsoft.VisualBasic.ChrW(Keys.Return) Then
SendKeys.Send("{TAB}")
e.Handled = True
End If
End Sub
Private Sub lstPartNum_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles lstPartNum.KeyDown
Dim theFile = lstPartNum.SelectedValue
If e.KeyCode = Keys.Enter Then
End If
If theFile IsNot Nothing And rbnEditPat.Checked Then
System.Diagnostics.Process.Start("C:\Program Files (x86)\Microsoft Office\root\Office16\EXCEL.EXE", theFile)
End If
If theFile IsNot Nothing And rbnBurnPat.Checked Then
System.Diagnostics.Process.Start("C:\Program Files (x86)\Microsoft Office\root\Office16\WINWORD.EXE", theFile)
End If
End Sub
Private Sub lstPartNum_MouseDoubleClick(sender As Object, e As MouseEventArgs) Handles lstPartNum.MouseDoubleClick
Dim theFile = lstPartNum.SelectedValue
If theFile IsNot Nothing And rbnEditPat.Checked Then
System.Diagnostics.Process.Start("C:\Program Files (x86)\Microsoft Office\root\Office16\EXCEL.EXE", theFile)
End If
If theFile IsNot Nothing And rbnBurnPat.Checked Then
System.Diagnostics.Process.Start("C:\Program Files (x86)\Microsoft Office\root\Office16\WINWORD.EXE", theFile)
End If
End Sub
End Class
Private Sub lstPartNum_MouseDoubleClick(sender As Object, e As MouseEventArgs) Handles lstPartNum.MouseDoubleClick
Dim theFile = lstPartNum.SelectedValue
If theFile IsNot Nothing And rbnEditPat.Checked Then
Dim procedit As New Process
procedit.StartInfo.FileName = "C:\Program Files (x86)\Microsoft Office\root\Office16\EXCEL.EXE"
procedit.StartInfo.Arguments = SourceFolder + theFile
procedit.Start()
End If
If theFile IsNot Nothing And rbnBurnPat.Checked Then
Dim procburn As New Process
procburn.StartInfo.FileName = "C:\Program Files (x86)\Microsoft Office\root\Office16\WINWORD.EXE"
procburn.StartInfo.Arguments = SourceFolder + theFile
procburn.Start()
End If
End Sub
burn-error-1.jpg