TPS1100-Convert/FormGrafika.vb

190 lines
8.7 KiB
VB.net
Raw Normal View History

2024-07-11 01:26:11 +02:00
Imports System.IO
Public Class FormGrafika
Public g As Graphics
Private Sub FormGrafika_Load(sender As Object, e As EventArgs) Handles MyBase.Load
g = Me.CreateGraphics()
2024-07-17 22:30:32 +02:00
2024-07-11 01:26:11 +02:00
End Sub
2024-07-22 21:54:37 +02:00
' Gumb: Prikaži
2024-07-11 01:26:11 +02:00
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
GrafikaIzris()
2024-07-22 21:54:37 +02:00
Form1.tsbSaveAs.Enabled = False
2024-07-25 03:01:25 +02:00
Form1.ShraniToolStripMenuItem.Enabled = False
2024-07-22 21:54:37 +02:00
End Sub
' Gumb: Zapri
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Me.Dispose()
Me.Close()
2024-07-11 01:26:11 +02:00
End Sub
Public Sub DrawLineMer(ByVal xPos As Single, ByVal yPos As Single, ByVal xPos2 As Single, ByVal yPos2 As Single)
2024-07-22 21:54:37 +02:00
g.DrawLine(Pens.LightGray, New Point(xPos, yPos), New Point(xPos2, yPos2))
2024-07-11 01:26:11 +02:00
End Sub
Public Sub GrafikaIzris()
Dim dataStolpci As String = ""
If My.Settings.Stolpci = 0 Then
dataStolpci = " "
ElseIf My.Settings.Stolpci = 1 Then
dataStolpci = vbTab
End If
Form1.RichTextBox1.Clear()
Form1.RichTextBox1.BackColor = Color.PaleTurquoise
2024-07-22 21:54:37 +02:00
Form1.RichTextBox1.Text = "Koordinate točk v grafiki..." + vbCrLf
2024-07-11 01:26:11 +02:00
Dim streamReader As StreamReader = New StreamReader(Form1.OpenFileDialog1.FileName)
Dim i As Integer = 0
Dim lin As Integer = 0
' Pripravi variable za stojišče in merjene točke
Dim measuredPoints As Integer = 0
Dim stojiceSt As Integer = 0
Dim meritevSt As Integer = 0
Dim dataKoda As Integer = 0
Dim staX As Double = 0
Dim staY As Double = 0
Dim merX As Double = 0
Dim merY As Double = 0
Dim imeToc As String = ""
2024-07-22 21:54:37 +02:00
g.DrawRectangle(Pens.Gray, 5, 5, 1000, 1000)
2024-07-11 01:26:11 +02:00
Do Until streamReader.EndOfStream
Form1.ToolStripProgressBar1.Value = i
' 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
If Microsoft.VisualBasic.Left(line(1), 2) = "25" Or Microsoft.VisualBasic.Left(line(1), 2) = "84" Then
2024-07-17 22:30:32 +02:00
measuredPoints = 1
2024-07-11 01:26:11 +02:00
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 Then
measuredPoints = 2
ElseIf dataInfo = My.Settings.KodaMeasOri Then
measuredPoints = 3
2024-07-17 22:30:32 +02:00
ElseIf dataInfo = My.Settings.KodaUserImport Then
measuredPoints = 0
2024-07-11 01:26:11 +02:00
Else
measuredPoints = 0
End If
End If
2024-07-17 22:30:32 +02:00
If wordIndex = "11" And measuredPoints >= 1 Then
2024-07-11 01:26:11 +02:00
data = Microsoft.VisualBasic.Right(data, 16).TrimStart("0"c)
imeToc = data
Form1.RichTextBox1.AppendText(data)
i = i + 1
2024-07-17 22:30:32 +02:00
ElseIf wordIndex = "81" And measuredPoints >= 2 Then ' Target Easting
2024-07-11 01:26:11 +02:00
numData = data / 1000
data = Format(numData, "0.000")
If My.Settings.DecimalnoLocilo = "Pika" Then
data = data.ToString.Replace(",", ".")
End If
merX = (numData - Form1.kooEMin) * Form1.kooFaktor
Form1.RichTextBox1.AppendText(dataStolpci + CInt(merX).ToString)
2024-07-17 22:30:32 +02:00
ElseIf wordIndex = "82" And measuredPoints >= 2 Then ' Target Northing
2024-07-11 01:26:11 +02:00
numData = data / 1000
data = Format(numData, "0.000")
If My.Settings.DecimalnoLocilo = "Pika" Then
data = data.ToString.Replace(",", ".")
End If
merY = (numData - Form1.kooNMin) * Form1.kooFaktor
Form1.RichTextBox1.AppendText(dataStolpci + CInt(merY).ToString)
2024-07-17 22:30:32 +02:00
ElseIf wordIndex = "83" And measuredPoints >= 2 Then ' Target Height
2024-07-11 01:26:11 +02:00
numData = data / 1000
data = Format(numData, "0.000")
If My.Settings.DecimalnoLocilo = "Pika" Then
data = data.ToString.Replace(",", ".")
End If
2024-07-17 22:30:32 +02:00
If measuredPoints = 2 Then
Form1.RichTextBox1.AppendText(dataStolpci + "MEAS")
2024-07-22 21:54:37 +02:00
g.DrawRectangle(Pens.Blue, CInt(merX) + 19, CInt(merY) + 19, 2, 2)
g.DrawString(imeToc, DefaultFont, Brushes.Blue, CInt(merX) + 22, CInt(merY) + 22)
2024-07-17 22:30:32 +02:00
' ElseIf measuredPoints = 4 Then
' Form1.RichTextBox1.AppendText(dataStolpci + data + dataStolpci + "REF")
ElseIf measuredPoints = 3 Then
Form1.RichTextBox1.AppendText(dataStolpci + "ORI")
2024-07-22 21:54:37 +02:00
g.DrawRectangle(Pens.DarkMagenta, CInt(merX) + 19, CInt(merY) + 19, 2, 2)
g.DrawString(imeToc, DefaultFont, Brushes.Magenta, CInt(merX) + 22, CInt(merY) + 22)
DrawLineMer(CInt(staX) + 20, CInt(staY) + 20, CInt(merX) + 20, CInt(merY) + 20)
2024-07-17 22:30:32 +02:00
End If
2024-07-11 01:26:11 +02:00
If stojiceSt > 0 Then
meritevSt = meritevSt + 1
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
staX = (numData - Form1.kooEMin) * Form1.kooFaktor
Form1.RichTextBox1.AppendText(dataStolpci + CInt(staX).ToString)
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
staY = (numData - Form1.kooNMin) * Form1.kooFaktor
Form1.RichTextBox1.AppendText(dataStolpci + CInt(staY).ToString)
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
2024-07-17 22:30:32 +02:00
Form1.RichTextBox1.AppendText(dataStolpci + "STA")
2024-07-11 01:26:11 +02:00
stojiceSt = stojiceSt + 1
meritevSt = 0
2024-07-17 22:30:32 +02:00
Label1.Text = stojiceSt.ToString
2024-07-22 21:54:37 +02:00
g.DrawRectangle(Pens.DarkOrange, CInt(staX) + 18, CInt(staY) + 18, 4, 4)
g.DrawString(imeToc, DefaultFont, Brushes.DarkOrange, CInt(staX) + 25, CInt(staY) + 25)
2024-07-11 01:26:11 +02:00
Else
numData = 0
data = ""
End If
End If
2024-07-17 22:30:32 +02:00
' If stojiceSt > 0 And meritevSt > 0 Then
'
' 'DrawLineMer(CInt(staX), CInt(staY), CInt(merX), CInt(merY))
' End If
2024-07-11 01:26:11 +02:00
Next
2024-07-17 22:30:32 +02:00
If dataKoda = 0 And measuredPoints >= 1 Then
2024-07-11 01:26:11 +02:00
Form1.RichTextBox1.AppendText(vbCrLf)
End If
lin = lin + 1
Form1.ToolStripProgressBar1.Value = lin
Loop
streamReader.Close()
End Sub
End Class