Imports Microsoft.VisualBasic.Devices
Imports System.Management

Public Class frmInfo

    Private Sub frmInfo_KeyDown(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
        'Fenster bei Escape schließen
        If e.KeyValue = Keys.Escape Then Me.Close()
    End Sub

    Private Sub frmInfo_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        lblVersion.Text = "Version " & Application.ProductVersion
        txtVersionsinfo.Text = Parkzeit.My.Resources.Versionsinfo.ToString
    End Sub

    Private Sub btnOKInfo_Click(sender As System.Object, e As System.EventArgs) Handles btnOKInfo.Click
        Me.Close()
    End Sub

    Private Sub btnSysteminfos_Click(sender As System.Object, e As System.EventArgs) Handles btnSysteminfos.Click
        lblText.Text = "Systeminfos"

        Dim ci As New ComputerInfo()

        txtVersionsinfo.Text = "DATENBANK" & vbCrLf
        txtVersionsinfo.Text += "Connection: " & vbTab & frmMain.ConnStrInfo & vbCrLf & vbCrLf

        txtVersionsinfo.Text += "ANWENDER" & vbCrLf
        txtVersionsinfo.Text += "Username: " & vbTab & SystemInformation.UserName.ToString & vbCrLf

        Dim query2 As New SelectQuery("Win32_ComputerSystem")
        Dim mos2 As New ManagementObjectSearcher(query2)

        Dim query As New SelectQuery("Win32_Processor")
        Dim mos As New ManagementObjectSearcher(query)

        For Each mo As ManagementObject In mos2.[Get]()
            txtVersionsinfo.Text += "Domäne: " & vbTab & vbTab & mo("Domain").ToString() & vbCrLf
        Next

        txtVersionsinfo.Text += vbCrLf & "COMPUTER" & vbCrLf
        txtVersionsinfo.Text += "Computername: " & vbTab & SystemInformation.ComputerName.ToString & vbCrLf
        For Each mo As ManagementObject In mos2.[Get]()

            txtVersionsinfo.Text += "Computermodell: " & vbTab & mo("Manufacturer").ToString & " " & mo("Model").ToString & vbCrLf
        Next
        For Each mo As ManagementObject In mos.[Get]()
            txtVersionsinfo.Text += "Prozessor: " & vbTab & mo("Name").ToString() & vbCrLf
            txtVersionsinfo.Text += "Prozessor-Speed: " & vbTab & mo("CurrentClockSpeed").ToString() & "MHz" & vbCrLf
        Next
        txtVersionsinfo.Text += "verwendeter RAM: " & vbTab & Format(((New ComputerInfo()).TotalPhysicalMemory / 1024 / 1024 / 1024), "#0.00") & " GB" & vbCrLf
        txtVersionsinfo.Text += "Monitorauflösung: " & vbTab & SystemInformation.PrimaryMonitorSize.ToString & vbCrLf

        txtVersionsinfo.Text += vbCrLf & "SOFTWARE" & vbTab & vbCrLf
        txtVersionsinfo.Text += "Betriebssystem: " & vbTab & ci.OSFullName & vbCrLf
        txtVersionsinfo.Text += "Service Pack: " & vbTab & Environment.OSVersion.ServicePack & vbCrLf
        txtVersionsinfo.Text += "Plattform:      " & vbTab & ci.OSPlatform & vbCrLf
        txtVersionsinfo.Text += ".net-Framework: " & vbTab & "Version " & Environment.Version.ToString & vbCrLf

        mos.Dispose()
        mos2.Dispose()

        txtVersionsinfo.Focus()
        txtVersionsinfo.Select(1, 0)
    End Sub

    Private Sub lblVersion_Click(sender As System.Object, e As System.EventArgs) Handles lblVersion.Click
        lblText.Text = "Versionshistorie"
        txtVersionsinfo.Text = My.Resources.Versionsinfo.ToString
    End Sub

    Private Sub lblAndi_Click(sender As System.Object, e As System.EventArgs) Handles lblAndi.Click
        'eMail-Programm wird gestartet werden
        Dim hMail As String = "mailto:engelsberger@inext.at?subject=Parkzeit-Programm"
        System.Diagnostics.Process.Start(hMail)
    End Sub

End Class