TPS1100-Convert/DialogPripravaKartice.vb

176 lines
7.7 KiB
VB.net
Raw Permalink Normal View History

2024-07-19 23:44:24 +02:00
Imports System.IO
Imports System.Windows.Forms
2024-07-17 22:30:32 +02:00
Public Class DialogPripravaKartice
Private Sub DialogPripravaKartice_Load(sender As Object, e As EventArgs) Handles MyBase.Load
For Each drive In IO.DriveInfo.GetDrives
'get all removable and fixed drives
2024-07-19 23:44:24 +02:00
If drive.DriveType = IO.DriveType.Removable And drive.IsReady = True Then
2024-07-17 22:30:32 +02:00
'add all found drives into the combobox
ComboBox1.Items.Add(drive)
End If
Next
End Sub
' Funkcija za pripravo PC-kartice/delovne mape
Private Sub PripravaKartice()
2024-07-19 23:44:24 +02:00
' Pripravi datoteke in poti za kopiranje
2024-07-17 22:30:32 +02:00
Dim delovnaMapa = My.Application.Info.DirectoryPath.ToString
Dim karticaMapa = ComboBox1.Text
Dim fileUvozCode = delovnaMapa + "\Virtualna Kartica\CODE\TPS1100.crf"
Dim fileIzvozCode = karticaMapa + "CODE\TPS1100.crf"
2024-07-25 03:01:25 +02:00
Dim fileUvozGeoid1 = delovnaMapa + "\Virtualna Kartica\DATA\GPS\GEOID\SLO1.GEM"
Dim fileIzvozGeoid1 = karticaMapa + "DATA\GPS\GEOID\SLO1.GEM"
Dim fileUvozGeoid2 = delovnaMapa + "\Virtualna Kartica\DATA\GPS\GEOID\SLOG2000.GEM"
Dim fileIzvozGeoid2 = karticaMapa + "DATA\GPS\GEOID\SLOG2000.GEM"
Dim fileUvozGeoid3 = delovnaMapa + "\Virtualna Kartica\DATA\GPS\GEOID\SLOV2016.GEM"
Dim fileIzvozGeoid3 = karticaMapa + "DATA\GPS\GEOID\SLOV2016.GEM"
2024-07-17 22:30:32 +02:00
Dim fileUvozTps = delovnaMapa + "\Virtualna Kartica\TPS\CONF\1102_BB.PAR"
Dim fileIzvozTps = karticaMapa + "TPS\CONF\1102_BB.PAR"
Dim fileUvozGpsGsi = delovnaMapa + "\Virtualna Kartica\CONVERT\GPS-GSI.FRT"
Dim fileIzvozGpsGsi = karticaMapa + "CONVERT\GPS-GSI.FRT"
Dim fileUvozGpsKoo = delovnaMapa + "\Virtualna Kartica\CONVERT\GPS-KOO.FRT"
Dim fileIzvozGpsKoo = karticaMapa + "CONVERT\GPS-KOO.FRT"
Dim fileUvozGpsPor = delovnaMapa + "\Virtualna Kartica\CONVERT\POROCILO.FRT"
Dim fileIzvozGpsPor = karticaMapa + "CONVERT\POROCILO.FRT"
' Kopiraj datoteke na kartico
If My.Computer.FileSystem.FileExists(fileUvozCode) Then
My.Computer.FileSystem.CopyFile(fileUvozCode, fileIzvozCode, True)
End If
2024-07-25 03:01:25 +02:00
If My.Computer.FileSystem.FileExists(fileUvozGeoid1) Then
My.Computer.FileSystem.CopyFile(fileUvozGeoid1, fileIzvozGeoid1, True)
End If
If My.Computer.FileSystem.FileExists(fileUvozGeoid2) Then
My.Computer.FileSystem.CopyFile(fileUvozGeoid2, fileIzvozGeoid2, True)
End If
If My.Computer.FileSystem.FileExists(fileUvozGeoid3) Then
My.Computer.FileSystem.CopyFile(fileUvozGeoid3, fileIzvozGeoid3, True)
2024-07-17 22:30:32 +02:00
End If
If My.Computer.FileSystem.FileExists(fileUvozTps) Then
My.Computer.FileSystem.CopyFile(fileUvozTps, fileIzvozTps, True)
End If
If My.Computer.FileSystem.FileExists(fileUvozGpsGsi) Then
My.Computer.FileSystem.CopyFile(fileUvozGpsGsi, fileIzvozGpsGsi, True)
End If
If My.Computer.FileSystem.FileExists(fileUvozGpsKoo) Then
My.Computer.FileSystem.CopyFile(fileUvozGpsKoo, fileIzvozGpsKoo, True)
End If
If My.Computer.FileSystem.FileExists(fileUvozGpsPor) Then
My.Computer.FileSystem.CopyFile(fileUvozGpsPor, fileIzvozGpsPor, True)
End If
2024-07-19 23:44:24 +02:00
If My.Computer.FileSystem.DirectoryExists(karticaMapa + "GSI") = False Then
My.Computer.FileSystem.CreateDirectory(karticaMapa + "GSI")
End If
If My.Computer.FileSystem.DirectoryExists(karticaMapa + "LOG") = False Then
My.Computer.FileSystem.CreateDirectory(karticaMapa + "LOG")
End If
End Sub
2024-07-22 21:54:37 +02:00
Private Sub Button_Pripravi_Click(ByVal sender As Object, e As EventArgs) Handles Button_Pripravi.Click
2024-07-25 03:01:25 +02:00
Dim karticaMapa As String = ComboBox1.Text
Dim kartica As String = ComboBox1.Text.Replace("\", "")
Dim karticaTip As String = LabelTip.Text
Dim karticaLabel As String = TextBoxPogonIme.Text
Dim msgPriprava = MsgBox("Priprava pogona: " + kartica + " [" + karticaLabel + "]" + vbCrLf + vbCrLf +
"Na kartico bodo naloženi podatki za TPS110x in GPS500." + vbCrLf +
"Nadaljujem?",
vbYesNo + vbExclamation, "Formatiranje kartice...")
If msgPriprava = DialogResult.Yes Then
' Zaženi pripravo kartice
PripravaKartice()
' Priprava končana...
Dim msgPripravaOk = MsgBox("Kartica pripravljena... podatki naloženi." + vbCrLf + vbCrLf +
"- CODE: Kode za TPS1100" + vbCrLf +
"- CONVERT: Formati izvoza podatkov za GPS500" + vbCrLf +
"- DATA/GPS/GEOID: Geoidi za GPS500" + vbCrLf +
"- TPS/CONF: Nastavitve za TPS110x" + vbCrLf + vbCrLf +
"Odprem mapo kartice?",
vbYesNo + vbInformation, "Priprava Kartice")
If msgPripravaOk = DialogResult.Yes Then
Process.Start(karticaMapa)
End If
End If
2024-07-17 22:30:32 +02:00
2024-07-22 21:54:37 +02:00
Dim allDrives() As DriveInfo = DriveInfo.GetDrives()
Dim d As DriveInfo
Dim totalSize
Dim availSize
Dim usedSize
2024-07-17 22:30:32 +02:00
2024-07-22 21:54:37 +02:00
For Each d In allDrives
If d.Name = ComboBox1.Text Then
totalSize = Format(d.TotalSize / 1000 / 1000, "0")
availSize = Format(d.AvailableFreeSpace / 1000 / 1000, "0")
usedSize = totalSize - availSize
LabelSize.Text = totalSize.ToString + "/" + availSize.ToString + " MB"
TextBoxPogonIme.Text = d.VolumeLabel.ToString
LabelTip.Text = d.DriveFormat.ToString
ProgressBar1.Maximum = totalSize
ProgressBar1.Value = usedSize
End If
Next
2024-07-17 22:30:32 +02:00
End Sub
2024-07-19 23:44:24 +02:00
Private Sub Button_Format_Click(sender As Object, e As EventArgs) Handles Button_Format.Click
Dim kartica As String = ComboBox1.Text.Replace("\", "")
Dim karticaTip As String = LabelTip.Text
2024-07-25 03:01:25 +02:00
Dim karticaLabel As String = TextBoxPogonIme.Text
2024-07-22 21:54:37 +02:00
2024-07-25 03:01:25 +02:00
Dim msgFormat = MsgBox("Formatiranje pogona: " + kartica + " [" + karticaLabel + "]" + vbCrLf + "Vsi podatki na pogonu bodo izbrisani!" + vbCrLf + "Nadaljujem?", vbYesNo + vbExclamation, "Formatiranje kartice...")
2024-07-19 23:44:24 +02:00
2024-07-25 03:01:25 +02:00
If msgFormat = DialogResult.Yes Then
Shell("cmd /c format " + kartica + " /fs:" + karticaTip + " /v:" + karticaLabel + " /q", AppWinStyle.NormalFocus)
2024-07-22 21:54:37 +02:00
ProgressBar1.Value = 0
2024-07-19 23:44:24 +02:00
Else
2024-07-25 03:01:25 +02:00
MsgBox("Postopek prekinjen.", vbOKOnly + vbInformation)
2024-07-19 23:44:24 +02:00
End If
2024-07-17 22:30:32 +02:00
End Sub
2024-07-19 23:44:24 +02:00
Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged
Dim allDrives() As DriveInfo = DriveInfo.GetDrives()
Dim d As DriveInfo
2024-07-22 21:54:37 +02:00
Dim totalSize
Dim availSize
Dim usedSize
2024-07-17 22:30:32 +02:00
2024-07-19 23:44:24 +02:00
For Each d In allDrives
If d.Name = ComboBox1.Text Then
2024-07-22 21:54:37 +02:00
totalSize = Format(d.TotalSize / 1000 / 1000, "0")
availSize = Format(d.AvailableFreeSpace / 1000 / 1000, "0")
usedSize = totalSize - availSize
LabelSize.Text = totalSize.ToString + "/" + availSize.ToString + " MB"
TextBoxPogonIme.Text = d.VolumeLabel.ToString
2024-07-19 23:44:24 +02:00
LabelTip.Text = d.DriveFormat.ToString
2024-07-22 21:54:37 +02:00
ProgressBar1.Maximum = totalSize
ProgressBar1.Value = usedSize
2024-07-19 23:44:24 +02:00
End If
Next
2024-07-17 22:30:32 +02:00
2024-07-19 23:44:24 +02:00
Button_Format.Enabled = True
Button_Pripravi.Enabled = True
End Sub
2024-07-22 21:54:37 +02:00
Private Sub Button_Zapri_Click(sender As Object, e As EventArgs) Handles Button_Zapri.Click
Me.Close()
End Sub
2024-07-17 22:30:32 +02:00
End Class