TPS1100-Convert/Form1.vb
2024-06-16 05:10:11 +02:00

595 lines
32 KiB
VB.net

Imports System.IO
Public Class Form1
Public DatotekaLogfile As String = My.Settings.DatLogfile
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
If DatotekaLogfile = "" Then
DatotekaLogfile = System.IO.Path.Combine(My.Computer.FileSystem.SpecialDirectories.MyDocuments, "tps1100_log.txt")
My.Settings.DatLogfile = DatotekaLogfile
My.Settings.Save()
End If
My.Forms.Form1.Text = My.Application.Info.Title + " " + My.Application.Info.Version.Major.ToString + "." + My.Application.Info.Version.Minor.ToString
RichTextBox1.AppendText(My.Settings.DatLogfile.ToString)
If My.Settings.Pisava = "" Then
My.Settings.Pisava = RichTextBox1.Font.Name
My.Settings.PisavaVelikost = RichTextBox1.Font.Size
My.Settings.Save()
End If
RichTextBox1.Font = New Font(My.Settings.Pisava, My.Settings.PisavaVelikost)
End Sub
Public streamLines As Integer = 0
Private Sub tsbOpenFile_Click(sender As Object, e As EventArgs) Handles tsbOpenFile.Click
OpenFileDialog1.ReadOnlyChecked = False
If OpenFileDialog1.ShowDialog = DialogResult.OK Then
RichTextBox1.Clear()
ToolStripProgressBar1.Value = 0
streamLines = 0
Dim streamReader As StreamReader = New StreamReader(OpenFileDialog1.FileName)
Do Until streamReader.EndOfStream
RichTextBox1.AppendText(streamReader.ReadLine + vbCrLf)
streamLines = streamLines + 1
Loop
ToolStripProgressBar1.Maximum = streamLines
streamReader.Close()
streamReader.Dispose()
My.Settings.Datoteka = OpenFileDialog1.SafeFileName
My.Settings.ZadnjaMapa = Path.GetDirectoryName(OpenFileDialog1.FileName)
tsbFileName.Text = My.Settings.Datoteka
ToolStripStatusLabel1.Text = My.Settings.ZadnjaMapa
tsbSaveAs.Text = "Shrani ..."
tsbSaveAs.Enabled = False
tsbConvert.Enabled = True
tsbPointsOnly.Enabled = True
ToolStripButtonGeo.Enabled = True
ButtonUrediDat.Enabled = True
RichTextBox1.BackColor = SystemColors.Info
LabelDatoteka.Image = My.Resources.icons8_ok_50
My.Settings.Save()
Else
tsbFileName.Text = "Odpri GSI datoteko..."
RichTextBox1.Clear()
tsbSaveAs.Text = "Shrani ..."
tsbSaveAs.Enabled = False
tsbConvert.Enabled = False
tsbPointsOnly.Enabled = False
End If
OpenFileDialog1.Dispose()
End Sub
Private Sub tsbConvert_Click(sender As Object, e As EventArgs) Handles tsbConvert.Click
ToolStripStatusLabel1.Text = "Procesiranje..."
RichTextBox1.Clear()
RichTextBox1.BackColor = SystemColors.Info
RichTextBox1.AppendText("TPS 1100 Zapisnik" + vbCrLf + "++++++++++++++++++++++" + vbCrLf)
ToolStripProgressBar1.Maximum = streamLines
' prepare StreamReader
Dim streamReader As StreamReader = New StreamReader(OpenFileDialog1.FileName)
Dim i As Integer = 0
Dim PodatkiStojisce As Boolean = False
Dim dataStolpci As String = ""
If My.Settings.Stolpci = 0 Then
dataStolpci = " "
ElseIf My.Settings.Stolpci = 1 Then
dataStolpci = vbTab
End If
Dim dataKoda As String = ""
' loop untill end of stream
Do Until streamReader.EndOfStream
' Read and Split each line to separate it into fields
Dim line() As String = streamReader.ReadLine().Split(" ")
' Remove * sign from index line
line(0) = Replace(line(0), "*", "")
ToolStripProgressBar1.Value = i
' Check if it's a new station setup
If Microsoft.VisualBasic.Left(line(1), 2) = "25" Then
RichTextBox1.AppendText(vbCrLf + "Station:" + vbCrLf + "****************" + vbCrLf)
RichTextBox1.AppendText("PtID" + dataStolpci + "HzCor" + dataStolpci + "StnE" + dataStolpci + "StnN" + dataStolpci + "StnH" + dataStolpci + "RefHt" + dataStolpci + "InstHt" + vbCrLf)
End If
If Microsoft.VisualBasic.Left(line(1), 2) = "84" Then
RichTextBox1.AppendText(vbCrLf + "Station:" + vbCrLf + "****************" + vbCrLf)
RichTextBox1.AppendText("PtID" + dataStolpci + "StnE" + dataStolpci + "StnN" + dataStolpci + "StnH" + dataStolpci + "RefHt" + dataStolpci + "InstHt" + vbCrLf)
End If
' Seaparate word index and data
For Each readLine As String In line
If readLine = "" Then
' do nothing
Else
' wordindex is always 6 characters long and is read fron left to right
Dim wordIndex As String
wordIndex = Microsoft.VisualBasic.Left(readLine, 2)
' data is always 17 characters long and is read from right to left and has a +/- sign in first place
Dim data As String
Dim dataTmp As String
Dim numData As Double
data = Microsoft.VisualBasic.Right(readLine, 17)
If wordIndex = "11" Then
data = Microsoft.VisualBasic.Right(data, 16).TrimStart("0"c)
ElseIf wordIndex = "19" Then ' Date/Time
data = dataStolpci + "DateTime= " + Microsoft.VisualBasic.Right(data, 8)
ElseIf wordIndex = "21" Then ' Horizontal angle
numData = data / 100000
data = dataStolpci + Format(numData, "0.0000")
ElseIf wordIndex = "22" Then ' Vertical angle
numData = data / 100000
data = dataStolpci + Format(numData, "0.0000")
ElseIf wordIndex = "25" Then ' Hz. Orientation correction
numData = data / 100000
data = dataStolpci + Format(numData, "0.0000")
ElseIf wordIndex = "31" Then ' Slope distance
numData = data / 1000
data = dataStolpci + Format(numData, "0.000")
ElseIf wordIndex = "32" Then ' Horizontal distance
numData = data / 1000
data = dataStolpci + Format(numData, "0.000")
ElseIf wordIndex = "33" Then ' Height difference
numData = data / 1000
data = dataStolpci + Format(numData, "0.000")
ElseIf wordIndex = "34" Then ' Stationing
numData = data / 1000
data = dataStolpci + "Station= " + Format(numData, "0.000")
ElseIf wordIndex = "35" Then ' Info za offset???
numData = data / 1000
data = dataStolpci + "Offset= " + Format(numData, "0.000")
ElseIf wordIndex = "41" Then ' Code
'numData = data
dataKoda = Microsoft.VisualBasic.Right(data, 16).TrimStart("0"c)
If My.Settings.KodeUporabnik = "Da" Then
If dataKoda = My.Settings.KodaQuickSet Then
data = vbCrLf + "Setup: Quick Set" + vbCrLf + "======================" + vbCrLf + "Hz" + dataStolpci + "V" + dataStolpci + "SD"
PodatkiStojisce = True
End If
If dataKoda = My.Settings.KodaSetAzi Then
data = vbCrLf + "Setup: Set Hz" + vbCrLf + "======================" + vbCrLf + "PtID" + dataStolpci + "HZ" + dataStolpci + "V" + dataStolpci + "SD" + dataStolpci + "HD" + dataStolpci + "RefHt" + dataStolpci + "PrCons" + dataStolpci + "HtDif" + dataStolpci + "PtCode"
PodatkiStojisce = True
End If
If dataKoda = My.Settings.KodaResection Then
data = vbCrLf + "Setup: Resection" + vbCrLf + "======================" + vbCrLf + "PtID" + dataStolpci + "HZ" + dataStolpci + "V" + dataStolpci + "SD" + dataStolpci + "HD" + dataStolpci + "RefHt" + dataStolpci + "PrCons" + dataStolpci + "HtDif" + dataStolpci + "PtCode"
PodatkiStojisce = True
End If
If dataKoda = My.Settings.KodaFreeStation Then
data = vbCrLf + "Setup: Free Station" + vbCrLf + "======================" + vbCrLf + "PtID" + dataStolpci + "HZ" + dataStolpci + "V" + dataStolpci + "SD" + dataStolpci + "HD" + dataStolpci + "RefHt" + dataStolpci + "PrCons" + dataStolpci + "HtDif" + dataStolpci + "PtCode"
PodatkiStojisce = True
End If
If dataKoda = My.Settings.KodaOriHtTrans Then
data = vbCrLf + "Setup: Orientation & Ht. transfer" + vbCrLf + "======================" + vbCrLf + "PtID" + dataStolpci + "HZ" + dataStolpci + "V" + dataStolpci + "SD" + dataStolpci + "HD" + dataStolpci + "RefHt" + dataStolpci + "PrCons" + dataStolpci + "HtDif" + dataStolpci + "PtCode"
PodatkiStojisce = True
End If
If dataKoda = My.Settings.KodaMeasOri Then
data = vbCrLf + "Orientation:" + vbCrLf + "----------------------" + vbCrLf + "PtID" + dataStolpci + "Azi" + dataStolpci + "V" + dataStolpci + "SD" + dataStolpci + "HD" + dataStolpci + "RefHt" + dataStolpci + "PrCons" + dataStolpci + "HtDif" + dataStolpci + "E" + dataStolpci + "N" + dataStolpci + "H" + dataStolpci + "PtCode"
PodatkiStojisce = False
End If
If dataKoda = My.Settings.KodaMeas Then
data = vbCrLf + "Measured:" + vbCrLf + "----------------------" + vbCrLf + "PtID" + dataStolpci + "Azi" + dataStolpci + "V" + dataStolpci + "SD" + dataStolpci + "HD" + dataStolpci + "RefHt" + dataStolpci + "PrCons" + dataStolpci + "HtDif" + dataStolpci + "E" + dataStolpci + "N" + dataStolpci + "H" + dataStolpci + "PtCode"
PodatkiStojisce = False
End If
If dataKoda = My.Settings.KodaStake Then
data = vbCrLf + "Staked:" + vbCrLf + "----------------------" + vbCrLf + "PtID" + dataStolpci + "Azi" + dataStolpci + "V" + dataStolpci + "SD" + dataStolpci + "HD" + dataStolpci + "RefHt" + dataStolpci + "PrCons" + dataStolpci + "HtDif" + dataStolpci + "E" + dataStolpci + "N" + dataStolpci + "H" + dataStolpci + "PtCode"
PodatkiStojisce = False
End If
If dataKoda = My.Settings.KodaUserImport Then
data = vbCrLf + "Imported/User-Entered:" + vbCrLf + "----------------------" + vbCrLf + "PtID" + dataStolpci + "E" + dataStolpci + "N" + dataStolpci + "H"
PodatkiStojisce = False
End If
If dataKoda = My.Settings.KodaStojisce Then
data = vbCrLf + "Stojišče:" + vbCrLf + "----------------------" + vbCrLf + "PtID" + dataStolpci + "InstHt"
PodatkiStojisce = False
End If
If dataKoda = My.Settings.KodaStojisceInfo Then
data = vbCrLf + "Temperatura/Pritisk:" + vbCrLf + "----------------------" + vbCrLf + "Temp" + dataStolpci + "Pritisk"
PodatkiStojisce = False
End If
If dataKoda = "STA_OFFS" Then
data = "Offsets:" + vbCrLf
PodatkiStojisce = False
End If
End If
ElseIf wordIndex = "42" Then ' Code: Info 1
data = dataStolpci + "Info1= " + Microsoft.VisualBasic.Right(data, 16).TrimStart("0"c)
ElseIf wordIndex = "43" Then ' Code: Info 2
data = dataStolpci + "Info2= " + Microsoft.VisualBasic.Right(data, 16).TrimStart("0"c)
ElseIf wordIndex = "44" Then ' Code: Info 3
data = dataStolpci + "Info3= " + Microsoft.VisualBasic.Right(data, 16).TrimStart("0"c)
ElseIf wordIndex = "45" Then ' Code: Info 4
data = dataStolpci + "Info4= " + Microsoft.VisualBasic.Right(data, 16).TrimStart("0"c)
ElseIf wordIndex = "47" Then ' Code: Info 6
data = dataStolpci + "Info6= " + Microsoft.VisualBasic.Right(data, 16).TrimStart("0"c)
ElseIf wordIndex = "58" Then ' Prism constant
numData = data / 10000
data = dataStolpci + Format(numData, "0.0000")
ElseIf wordIndex = "71" Or wordIndex = "72" Then ' Point Code
dataTmp = Microsoft.VisualBasic.Right(data, 16).TrimStart("0"c)
If dataKoda = My.Settings.KodaStojisce Then
data = dataTmp
Else
data = dataStolpci + dataTmp
End If
ElseIf wordIndex = "79" Then ' Point Code
dataTmp = Microsoft.VisualBasic.Right(data, 16).TrimStart("0"c)
If dataTmp = "" Then
data = ""
Else
data = dataStolpci + dataTmp
End If
ElseIf wordIndex = "81" And PodatkiStojisce = False Then ' Target Easting
numData = data / 1000
data = dataStolpci + Format(numData, "0.000")
ElseIf wordIndex = "82" And PodatkiStojisce = False Then ' Target Northing
numData = data / 1000
data = dataStolpci + Format(numData, "0.000")
ElseIf wordIndex = "83" And PodatkiStojisce = False Then ' Target Height
numData = data / 1000
data = dataStolpci + Format(numData, "0.000")
ElseIf wordIndex = "84" Then ' Station Easting
numData = data / 1000
data = dataStolpci + Format(numData, "0.000")
ElseIf wordIndex = "85" Then ' Station Northing
numData = data / 1000
data = dataStolpci + Format(numData, "0.000")
ElseIf wordIndex = "86" Then ' Station Height
numData = data / 1000
data = dataStolpci + Format(numData, "0.000")
ElseIf wordIndex = "87" Then ' Reflector height
numData = data / 1000
data = dataStolpci + Format(numData, "0.000")
ElseIf wordIndex = "88" Then ' Instriment height
numData = data / 1000
data = dataStolpci + Format(numData, "0.000")
ElseIf wordIndex = "18" Then ' DATE YY.ss
numData = data / 1000000
data = dataStolpci + "Year.Sec= " + Format(numData, "0.00")
Else
numData = 0
data = ""
End If
If My.Settings.DecimalnoLocilo = "Pika" Then
If wordIndex IsNot "11" Then
data = data.ToString.Replace(",", ".")
End If
End If
RichTextBox1.AppendText(data)
End If
Next
RichTextBox1.AppendText(vbCrLf)
i = i + 1
Loop
streamReader.Close()
ToolStripStatusLabel1.Text = "Prebrano: " + i.ToString + "/" + ToolStripProgressBar1.Maximum.ToString + " vrstic"
SaveFileDialog1.Filter = "Zapisnik meritve|*.mer|Text file|*.txt|All files|*.*"
tsbSaveAs.Enabled = True
tsbSaveAs.Text = "Shrani Zapisnik"
End Sub
Private Sub tsbPointsOnly_Click(sender As Object, e As EventArgs) Handles tsbPointsOnly.Click
Dim dataStolpci As String = ""
If My.Settings.Stolpci = 0 Then
dataStolpci = " "
ElseIf My.Settings.Stolpci = 1 Then
dataStolpci = vbTab
End If
RichTextBox1.Clear()
RichTextBox1.BackColor = SystemColors.Info
Dim measuredPoints As Integer = 0
Dim dataKoda As Integer = 0
Dim streamReader As StreamReader = New StreamReader(OpenFileDialog1.FileName)
Dim i As Integer = 0
Dim lin As Integer = 0
Do Until streamReader.EndOfStream
' Read and Split each line to separate it into fields
Dim line() As String = streamReader.ReadLine().Split(" ")
' Remove * sign from index line
line(0) = Replace(line(0), "*", "")
If Microsoft.VisualBasic.Left(line(0), 2) = "41" Then
dataKoda = 1
Else
dataKoda = 0
End If
ToolStripProgressBar1.Value = i
'If Microsoft.VisualBasic.Left(line(1), 2) = "81" Then
' measuredPoints = 1
'Else
If Microsoft.VisualBasic.Left(line(1), 2) = "25" Or Microsoft.VisualBasic.Left(line(1), 2) = "84" Then
measuredPoints = 2
End If
' Seaparate word index and data
For Each readLine As String In line
If readLine = "" Then
' do nothing
Else
' wordindex is always 6 characters long and is read fron left to right
Dim wordIndex As String
Dim data As String
Dim numData As Double
wordIndex = Microsoft.VisualBasic.Left(readLine, 2)
data = Microsoft.VisualBasic.Right(readLine, 17)
If wordIndex = "41" Then
Dim dataInfo As String = Microsoft.VisualBasic.Right(readLine, 16).TrimStart("0"c)
If dataInfo = My.Settings.KodaMeas Or dataInfo = My.Settings.KodaStake Then
measuredPoints = 1
ElseIf dataInfo = My.Settings.KodaUserImport Then
measuredPoints = 2
ElseIf dataInfo = My.Settings.KodaMeasOri Then
measuredPoints = 3
Else
measuredPoints = 0
End If
End If
If wordIndex = "71" And measuredPoints >= 1 Then ' Point Code
data = Microsoft.VisualBasic.Right(data, 16).TrimStart("0"c)
If data = "" Then
' nič
Else
RichTextBox1.AppendText(dataStolpci + data)
End If
End If
If wordIndex = "11" And measuredPoints >= 1 Then
data = Microsoft.VisualBasic.Right(data, 16).TrimStart("0"c)
RichTextBox1.AppendText(data)
i = i + 1
ElseIf wordIndex = "81" And measuredPoints >= 1 Then ' Target Easting
numData = data / 1000
data = Format(numData, "0.000")
If My.Settings.DecimalnoLocilo = "Pika" Then
data = data.ToString.Replace(",", ".")
End If
RichTextBox1.AppendText(dataStolpci + data)
ElseIf wordIndex = "82" And measuredPoints >= 1 Then ' Target Northing
numData = data / 1000
data = Format(numData, "0.000")
If My.Settings.DecimalnoLocilo = "Pika" Then
data = data.ToString.Replace(",", ".")
End If
RichTextBox1.AppendText(dataStolpci + data)
ElseIf wordIndex = "83" And measuredPoints >= 1 Then ' Target Height
numData = data / 1000
data = Format(numData, "0.000")
If My.Settings.DecimalnoLocilo = "Pika" Then
data = data.ToString.Replace(",", ".")
End If
If measuredPoints = 1 Then
RichTextBox1.AppendText(dataStolpci + data + dataStolpci + "MEAS")
ElseIf measuredPoints = 2 Then
RichTextBox1.AppendText(dataStolpci + data + dataStolpci + "REF")
ElseIf measuredPoints = 3 Then
RichTextBox1.AppendText(dataStolpci + data + dataStolpci + "ORI")
End If
ElseIf wordIndex = "84" And measuredPoints >= 1 Then ' Station Easting
numData = data / 1000
data = Format(numData, "0.000")
If My.Settings.DecimalnoLocilo = "Pika" Then
data = data.ToString.Replace(",", ".")
End If
RichTextBox1.AppendText(dataStolpci + data)
ElseIf wordIndex = "85" And measuredPoints >= 1 Then ' Station Northing
numData = data / 1000
data = Format(numData, "0.000")
If My.Settings.DecimalnoLocilo = "Pika" Then
data = data.ToString.Replace(",", ".")
End If
RichTextBox1.AppendText(dataStolpci + data)
ElseIf wordIndex = "86" And measuredPoints >= 1 Then ' Station Height
numData = data / 1000
data = Format(numData, "0.000")
If My.Settings.DecimalnoLocilo = "Pika" Then
data = data.ToString.Replace(",", ".")
End If
RichTextBox1.AppendText(dataStolpci + data + dataStolpci + "STA")
Else
numData = 0
data = ""
End If
End If
Next
If dataKoda = 0 And measuredPoints >= 1 Then
RichTextBox1.AppendText(vbCrLf)
End If
lin = lin + 1
ToolStripProgressBar1.Value = lin
Loop
ToolStripStatusLabel1.Text = "Prebrano točk: " + i.ToString
SaveFileDialog1.Filter = "KOO|*.koo|TXT|*.txt|All files|*.*"
streamReader.Close()
tsbSaveAs.Enabled = True
tsbSaveAs.Text = "Shrani Točke"
End Sub
Private Sub tsbSaveAs_Click(sender As Object, e As EventArgs) Handles tsbSaveAs.Click
SaveFileDialog1.FileName = Path.GetFileNameWithoutExtension(OpenFileDialog1.FileName)
SaveFileDialog1.InitialDirectory = My.Settings.MapaShrani
If SaveFileDialog1.ShowDialog = DialogResult.OK Then
RichTextBox1.SaveFile(SaveFileDialog1.FileName, RichTextBoxStreamType.PlainText)
My.Computer.FileSystem.WriteAllText(DatotekaLogfile, System.DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + " | " + OpenFileDialog1.FileName.ToString + " -> " + SaveFileDialog1.FileName.ToString + vbCrLf, True)
My.Settings.MapaShrani = Path.GetDirectoryName(SaveFileDialog1.FileName)
My.Settings.Save()
ToolStripStatusLabel1.Text = "Datoteka shranjena >>> " + SaveFileDialog1.FileName.ToString
RichTextBox1.BackColor = SystemColors.ControlLightLight
End If
End Sub
Private Sub tsbHelp_Click(sender As Object, e As EventArgs) Handles tsbHelp.Click
' MessageBox.Show("Za konvertiranje GSI datoteke najprej izberi datoteko, ki jo želiš konvertirati z ukazom 'Open File'. Nato izberi metodo konverzije (Poročilo, Merjene točke, Vse točke). Po končani knverziji shrani novo datoteko z ukazom 'Save As...'","Kratka navodila")
SplashScreen1.ShowDialog()
End Sub
Private Sub ToolStripButton1_Click(sender As Object, e As EventArgs) Handles ButtonUrediDat.Click
Form2.ShowDialog()
End Sub
Private Sub ToolStripButtonNast_Click(sender As Object, e As EventArgs) Handles ToolStripButtonNast.Click
FormNastavitve.ShowDialog()
End Sub
Private Sub ToolStripButtonPripravi_Click(sender As Object, e As EventArgs) Handles ToolStripButtonPripravi.Click
If OpenFileDialogTocke.ShowDialog = DialogResult.OK Then
RichTextBox1.Clear()
Dim streamReader As StreamReader = New StreamReader(OpenFileDialogTocke.FileName)
Do Until streamReader.EndOfStream
streamLines = streamLines + 1
Dim readLine As String = streamReader.ReadLine().Replace(" ", vbTab)
readLine = readLine.Replace(";", vbTab)
readLine = readLine.Replace(".", ",")
Dim line() As String = readLine.Split(vbTab)
Dim podPtId As String = "*11" + Format(streamLines, "0000") + "+" + line(0).PadLeft(16, "0") + " "
Dim izrE As Double = line(1) * 1000
Dim podE As String = "81..00+" + Format(izrE, "#0000000000000000") + " "
Dim izrN As Double = line(2) * 1000
Dim podN As String = "82..00+" + Format(izrN, "#0000000000000000") + " "
Dim izrH As Double = line(3) * 1000
Dim podH As String = "83..00+" + Format(izrH, "#0000000000000000") + " "
' Dim podE As String = "81..00+" + izrE2.PadLeft(16, "0") + " "
RichTextBox1.AppendText(podPtId + podE + podN + podH + vbCrLf)
Loop
ToolStripProgressBar1.Maximum = streamLines
streamReader.Close()
streamReader.Dispose()
ToolStripStatusLabel1.Text = "Prebrano: " + streamLines.ToString + "/" + ToolStripProgressBar1.Maximum.ToString + " vrstic"
SaveFileDialog1.Filter = "GSI datoteka|*.GSI"
SaveFileDialog1.FileName = Path.GetFileNameWithoutExtension(OpenFileDialogTocke.FileName)
tsbSaveAs.Enabled = True
tsbSaveAs.Text = "Shrani GSI"
End If
End Sub
Private Sub ToolStripButtonGeo_Click(sender As Object, e As EventArgs) Handles ToolStripButtonGeo.Click
RichTextBox1.Clear()
RichTextBox1.BackColor = Color.LemonChiffon
Dim measuredPoints As Integer = 0
Dim dataKoda As String = ""
Dim streamReader As StreamReader = New StreamReader(OpenFileDialog1.FileName)
Dim i As Integer = 0
Dim lin As Integer = 0
Do Until streamReader.EndOfStream
' Read and Split each line to separate it into fields
Dim izpisText As String = ""
Dim line() As String = streamReader.ReadLine().Split(" ")
line(0) = Replace(line(0), "*", "")
If Microsoft.VisualBasic.Left(line(0), 2) = "41" Then
dataKoda = Microsoft.VisualBasic.Right(line(0), 16).TrimStart("0"c)
If dataKoda = My.Settings.KodaMeas Then
izpisText = "0 0" + vbCrLf
measuredPoints = 1
End If
If dataKoda = My.Settings.KodaMeasOri Then
izpisText = "20 759.81" + vbCrLf
measuredPoints = 0
End If
If dataKoda = My.Settings.KodaQuickSet And lin > 0 Then
izpisText = "-1 0 0 0 0" + vbCrLf
measuredPoints = 0
End If
If dataKoda = My.Settings.KodaSetAzi And lin > 0 Then
izpisText = "-1 0 0 0 0" + vbCrLf
measuredPoints = 0
End If
If dataKoda = My.Settings.KodaResection And lin > 0 Then
izpisText = "-1 0 0 0 0" + vbCrLf
measuredPoints = 0
End If
If dataKoda = My.Settings.KodaFreeStation And lin > 0 Then
izpisText = "-1 0 0 0 0" + vbCrLf
measuredPoints = 0
End If
If dataKoda = My.Settings.KodaOriHtTrans And lin > 0 Then
izpisText = "-1 0 0 0 0" + vbCrLf
measuredPoints = 0
End If
End If
If Microsoft.VisualBasic.Left(line(0), 2) = "11" Then
If dataKoda = My.Settings.KodaMeas Then
Dim dataId As String
dataId = Microsoft.VisualBasic.Right(line(0), 16).TrimStart("0"c)
Dim dataAzi As String
dataAzi = Microsoft.VisualBasic.Right(line(1), 17)
Dim numAzi As Double
numAzi = dataAzi / 100000
Dim dataV As String
dataV = Microsoft.VisualBasic.Right(line(2), 17)
Dim numV As Double
numV = dataV / 100000
Dim dataSD As String
dataSD = Microsoft.VisualBasic.Right(line(3), 17)
Dim numSD As Double
numSD = dataSD / 1000
Dim dataHr As String
dataHr = Microsoft.VisualBasic.Right(line(5), 17)
Dim numHr As Double
numHr = dataHr / 1000
izpisText = dataId + " " + Format(numAzi, "0.0000").ToString + " " + Format(numV, "0.0000").ToString + " " + Format(numSD, "0.000").ToString + " " + Format(numHr, "0.000").ToString + vbCrLf
End If
If dataKoda = My.Settings.KodaMeasOri Then
Dim dataId As String
dataId = Microsoft.VisualBasic.Right(line(0), 16).TrimStart("0"c)
Dim dataAzi As Double
dataAzi = Microsoft.VisualBasic.Right(line(1), 17)
Dim numAzi As Double
numAzi = dataAzi / 100000
izpisText = dataId + " " + Format(numAzi, "0.0000").ToString + vbCrLf
End If
If dataKoda = My.Settings.KodaQuickSet Then
If Microsoft.VisualBasic.Left(line(1), 2) = "84" Then
Dim dataSta As String
dataSta = Microsoft.VisualBasic.Right(line(0), 16).TrimStart("0"c)
Dim dataHi As Double
dataHi = Microsoft.VisualBasic.Right(line(4), 17)
Dim numHi As Double
numHi = dataHi / 1000
izpisText = dataSta + " " + Format(numHi, "0.000").ToString + vbCrLf
End If
End If
' ElseIf dataKoda = My.Settings.KodaSetAzi Then
'
' ElseIf dataKoda = My.Settings.KodaResection Then
'
If dataKoda = My.Settings.KodaFreeStation Then
If Microsoft.VisualBasic.Left(line(1), 2) = "25" Then
Dim dataSta As String
dataSta = Microsoft.VisualBasic.Right(line(0), 16).TrimStart("0"c)
Dim dataHi As Double
dataHi = Microsoft.VisualBasic.Right(line(6), 17)
Dim numHi As Double
numHi = dataHi / 1000
izpisText = dataSta + " " + Format(numHi, "0.000").ToString + vbCrLf
End If
End If
' ElseIf dataKoda = My.Settings.KodaOriHtTrans Then
End If
RichTextBox1.AppendText(izpisText)
lin = lin + 1
ToolStripProgressBar1.Value = lin
Loop
RichTextBox1.AppendText("-1 0 0 0 0" + vbCrLf)
streamReader.Close()
streamReader.Dispose()
ToolStripStatusLabel1.Text = "Prebrano: " + lin.ToString + "/" + ToolStripProgressBar1.Maximum.ToString + " vrstic"
SaveFileDialog1.Filter = "GEO datoteka|*.GEO"
SaveFileDialog1.FileName = Path.GetFileNameWithoutExtension(OpenFileDialogTocke.FileName)
tsbSaveAs.Enabled = True
tsbSaveAs.Text = "Shrani GEO"
End Sub
End Class