1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
| Public Class Form1
Dim LineNumber As Integer
Dim Datablock(,) As Integer
Dim TextLine As String
Dim singledataresult, SingledataType As Integer
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim OpenCameraMotionFileDialog As New OpenFileDialog()
OpenCameraMotionFileDialog.Title = "Please Select a File"
OpenCameraMotionFileDialog.InitialDirectory = "C:\\Program Files (x86)/MCSM"
OpenCameraMotionFileDialog.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"
If OpenCameraMotionFileDialog.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
Try
Dim MoCamStrm As New System.IO.StreamReader(OpenCameraMotionFileDialog.FileName)
If (MoCamStrm IsNot Nothing) Then
While Not MoCamStrm.EndOfStream
TextLine = MoCamStrm.ReadLine()
If InStr(1, TextLine, "--") = 0 Then
LineNumber = LineNumber + 1
ReDim Datablock(LineNumber, 1)
Dim StringSeparator() As String = {"|"}
Dim result() As String
result = TextLine.Split(StringSeparator, StringSplitOptions.RemoveEmptyEntries)
For Each SingleFullResult As String In result
If InStr(1, SingleFullResult, "Tx") <> 0 Then singledataresult = Val(Trim(Mid(SingleFullResult, InStr(1, SingleFullResult, "Tx") + 2))) : SingledataType = 0
If InStr(1, SingleFullResult, "Ty") <> 0 Then singledataresult = Val(Trim(Mid(SingleFullResult, InStr(1, SingleFullResult, "Ty") + 2))) : SingledataType = 1
Datablock(LineNumber, SingledataType) = singledataresult
Next SingleFullResult
End If
End While
End If
MoCamStrm.Close()
Catch Ex As Exception
MessageBox.Show("Cannot read file from disk. Original error: " & Ex.Message)
End Try
End If
Call DisplayMotionCameraData()
End Sub
Sub DisplayMotionCameraData()
Label1.Text = Datablock(LineNumber, 0)
Label2.Text = Datablock(LineNumber, 1)
Label3.Text = LineNumber
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
LineNumber = LineNumber - 1
If LineNumber < 1 Then LineNumber = 1
Call DisplayMotionCameraData()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
LineNumber = LineNumber + 1
If LineNumber > UBound(Datablock, 1) Then LineNumber = UBound(Datablock, 1)
Call DisplayMotionCameraData()
End Sub
End Class |
Partager