Projektdateien hinzufügen.
This commit is contained in:
170
Aviso/cProgramFunctions.vb
Normal file
170
Aviso/cProgramFunctions.vb
Normal file
@@ -0,0 +1,170 @@
|
||||
Imports System.Management
|
||||
Imports System.IO
|
||||
|
||||
Public Class cProgramFunctions
|
||||
|
||||
Shared Function updateUpdater() As Boolean
|
||||
Try
|
||||
Dim aktVersion = My.Resources.UpdaterVersion ' Aktuelle Updater Version
|
||||
Dim F = "F:\Programme\AVISO_install\"
|
||||
Dim doUpdaterUpdate = False
|
||||
If IO.File.Exists(AppDomain.CurrentDomain.BaseDirectory & "\AVISOUPDATER_Version.txt") Then 'Updater muss auch existieren, sonst wird er auch beim Developer Rechner eingefügt...
|
||||
Dim fs As New FileStream(AppDomain.CurrentDomain.BaseDirectory & "\AVISOUPDATER_Version.txt", FileMode.Open, FileAccess.Read)
|
||||
Dim strmReader As New StreamReader(fs)
|
||||
Dim Version = strmReader.ReadLine
|
||||
If IsNumeric(Version.Replace(".", "")) Then
|
||||
If Version.Replace(".", "") < aktVersion.Replace(".", "") Then
|
||||
doUpdaterUpdate = True
|
||||
End If
|
||||
End If
|
||||
fs.Close()
|
||||
strmReader.Close()
|
||||
Else
|
||||
doUpdaterUpdate = True
|
||||
End If
|
||||
If Not doUpdaterUpdate Then Return False
|
||||
|
||||
If IO.Directory.Exists(F) And IO.File.Exists(AppDomain.CurrentDomain.BaseDirectory & "\AVISOUPDATER.exe") Then 'Updater muss auch existieren, sonst wird er auch beim Developer Rechner eingefügt...
|
||||
For Each file As String In IO.Directory.GetFiles(F) ' Ermittelt alle Dateien des Ordners
|
||||
IO.File.Copy(file, AppDomain.CurrentDomain.BaseDirectory & cut_file(file), True) ' Kopiert die Dateien Next
|
||||
Next
|
||||
For Each file As String In IO.Directory.GetDirectories(F) ' Ermittelt alle Unterordner des Ordners
|
||||
My.Computer.FileSystem.CopyDirectory(file, AppDomain.CurrentDomain.BaseDirectory & cut_file(file), True)
|
||||
Next
|
||||
Return True
|
||||
End If
|
||||
Return False
|
||||
Catch ex As Exception
|
||||
Return False
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Shared Function cut_file(ByVal file As String) As String ' Funktion zum Entfernen der Backslashs / Ordner While file.Contains("\") file = file.Remove(0, 1) End While Return file End Function
|
||||
While file.Contains("\")
|
||||
file = file.Remove(0, 1)
|
||||
End While
|
||||
Return file
|
||||
End Function
|
||||
|
||||
Public Sub screenshot()
|
||||
Dim form As New Form
|
||||
form = form.ActiveForm
|
||||
Dim bounds As Rectangle
|
||||
Dim screenshot As System.Drawing.Bitmap
|
||||
Dim graph As Graphics
|
||||
bounds = form.Bounds 'Screen.PrimaryScreen.Bounds
|
||||
|
||||
screenshot = New System.Drawing.Bitmap(bounds.Width, bounds.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb)
|
||||
graph = Graphics.FromImage(screenshot)
|
||||
graph.CopyFromScreen(bounds.X, bounds.Y, 0, 0, bounds.Size, CopyPixelOperation.SourceCopy)
|
||||
' PictureBox1.Image = screenshot
|
||||
If Not My.Computer.FileSystem.DirectoryExists(My.Computer.FileSystem.SpecialDirectories.Desktop & "\Screenshots_" & My.Application.Info.AssemblyName & "\") Then
|
||||
My.Computer.FileSystem.CreateDirectory(My.Computer.FileSystem.SpecialDirectories.Desktop & "\Screenshots_" & My.Application.Info.AssemblyName & "\")
|
||||
End If
|
||||
Dim cnt As Integer = 1
|
||||
Dim strname As String = My.Computer.FileSystem.SpecialDirectories.Desktop & "\Screenshots_" & My.Application.Info.AssemblyName & "\" & form.Name & "_" & Now.ToString("ddMMyyyy_HHmm_")
|
||||
While System.IO.File.Exists(strname & cnt & ".bmp") : cnt += 1 : End While
|
||||
screenshot.Save(strname & cnt & ".bmp")
|
||||
End Sub
|
||||
Public Function TakeScreenShot(ByVal Control As Control) As Bitmap
|
||||
Dim tmpImg As New Bitmap(Control.Width, Control.Height)
|
||||
Using g As Graphics = Graphics.FromImage(tmpImg)
|
||||
g.CopyFromScreen(Control.PointToScreen(New Point(0, 0)), New Point(0, 0), New Size(Control.Width, Control.Height))
|
||||
End Using
|
||||
Return tmpImg
|
||||
End Function
|
||||
|
||||
Public Function MinToTime(ByRef rMinute As Long) As String
|
||||
Dim m_TimeSpan As TimeSpan = New TimeSpan(0, rMinute, 0)
|
||||
MinToTime = Format((m_TimeSpan.Days * 24) + m_TimeSpan.Hours, "0") & " Std. " & Format(m_TimeSpan.Minutes, "00") & " min"
|
||||
End Function
|
||||
|
||||
Public Function MinToTime2(ByRef rMinute As Long) As String
|
||||
Dim m_TimeSpan As TimeSpan = New TimeSpan(0, rMinute, 0)
|
||||
Select Case rMinute
|
||||
Case Is < 60
|
||||
MinToTime2 = Format(m_TimeSpan.Minutes) & " min"
|
||||
Case Is < 1440
|
||||
MinToTime2 = Format((m_TimeSpan.Days * 24) + m_TimeSpan.Hours, "0") & " Std. " & Format(m_TimeSpan.Minutes, "00") & " min"
|
||||
Case Else
|
||||
MinToTime2 = Format(m_TimeSpan.Days, "0") & " T " & Format(m_TimeSpan.Hours, "00") & " Std" '& ":" & Format(m_TimeSpan.Minutes, "00") & " min"
|
||||
End Select
|
||||
End Function
|
||||
|
||||
Function isPrinterOnline(name) As Boolean 'Defalut=true
|
||||
|
||||
' Set management scope
|
||||
|
||||
Dim scope As New ManagementScope("\root\cimv2")
|
||||
scope.Connect()
|
||||
' Select Printers from WMI Object Collections
|
||||
|
||||
Dim searcher As New ManagementObjectSearcher("SELECT * FROM Win32_Printer")
|
||||
Dim printerName As String = ""
|
||||
|
||||
For Each printer As ManagementObject In searcher.[Get]()
|
||||
|
||||
printerName = printer("Name").ToString().ToLower()
|
||||
' MsgBox(printerName & " _ " & name.ToString.ToLower)
|
||||
If printerName.Equals(name.ToString.ToLower) Then
|
||||
|
||||
If printer("WorkOffline").ToString().ToLower().Equals("true") Then
|
||||
|
||||
' printer is offline by user
|
||||
Return False
|
||||
' MsgBox(printer("Name") & ": Your Plug-N-Play printer is not connected.")
|
||||
|
||||
Else
|
||||
|
||||
' printer is not offline
|
||||
Return True
|
||||
' MsgBox(printer("Name") & ": Your Plug-N-Play printer is connected.")
|
||||
|
||||
End If
|
||||
|
||||
End If
|
||||
|
||||
Next
|
||||
Return True
|
||||
End Function
|
||||
|
||||
|
||||
Function getPrinterList() As List(Of PrinterList) 'Defalut=true
|
||||
|
||||
Dim ll As New List(Of PrinterList)
|
||||
Dim scope As New ManagementScope("\root\cimv2")
|
||||
scope.Connect()
|
||||
' Select Printers from WMI Object Collections
|
||||
|
||||
Dim searcher As New ManagementObjectSearcher("SELECT * FROM Win32_Printer")
|
||||
Dim printerName As String = ""
|
||||
|
||||
For Each printer As ManagementObject In searcher.[Get]()
|
||||
Dim l As New PrinterList
|
||||
l.Name = printer("Name").ToString().ToLower()
|
||||
If printer("WorkOffline").ToString().ToLower().Equals("true") Then
|
||||
' printer is offline by user
|
||||
l.isOnline = False
|
||||
Else
|
||||
' printer is not offline
|
||||
l.isOnline = True
|
||||
End If
|
||||
ll.Add(l)
|
||||
Next
|
||||
Return ll
|
||||
End Function
|
||||
Function isPrinterOnlineByList(ll As List(Of PrinterList), name As String) As Boolean 'Defalut=true
|
||||
For Each l As PrinterList In ll
|
||||
If l.Name.ToLower = name.ToLower Then
|
||||
Return l.isOnline
|
||||
End If
|
||||
Next
|
||||
Return True
|
||||
End Function
|
||||
|
||||
|
||||
End Class
|
||||
Public Class PrinterList
|
||||
Property Name As String
|
||||
Property isOnline As Boolean
|
||||
End Class
|
||||
Reference in New Issue
Block a user