Guide Contents
|
DigitalDan Home Page
|
Public Shared Function Is_Program_Already_Running() As Boolean
Return (Process.GetProcessesByName(Process.GetCurrentProcess.ProcessName).Length > 1)
End Function
Public Shared Function Remove_Accents(txt As String) As String
Dim normalizedString As String = txt.Normalize(System.Text.NormalizationForm.FormD)
Dim c As Char
Dim stringBuilder As New System.Text.StringBuilder
For i = 0 To normalizedString.Length - 1
c = normalizedString(i)
If System.Globalization.CharUnicodeInfo.GetUnicodeCategory(c) <> System.Globalization.UnicodeCategory.NonSpacingMark Then
stringBUilder.Append(c)
End If
Next
Return stringBuilder.ToString()
End Function
Private Shared Function Is_Point_In_Polygon(polygon As List(Of PointF), target_point As PointF) As Boolean
' points buildingpolygon - last point does not have to match first - it will always complete the polygon
' pointf appears to be fine (i.e. decimal x and y coordinates allowed (pointF uses single preceision - NOT double)
Dim path As New Drawing2D.GraphicsPath
path.AddPolygon(polygon.ToArray)
Return path.IsVisible(target_point)
End Function
Private Shared Function Column_To_Header(column As Integer) As String
Dim ret As String = String.Empty
Dim modnum As Integer
column += 1
While column > 0
modnum = (column - 1) Mod 26
ret = Chr(65 + modnum) & ret
column = CInt((column - modnum) \ 26)
End While
Return ret
End Function
Private Shared Function Header_to_Column(header As String) As Integer
' strip out any garbage from input
Dim rgx As New Regex("[^a-zA-Z ]")
header = header.ToUpper
header = rgx.Replace(header, "")
If header.Length < 1 Or header.Length > 5 Then
Return -1 ' invalid header
End If
' get column number
Dim column As Integer = 0
header = header.PadLeft(5, "@"c)
Dim tem As Integer
For Each c As Char In header
column *= 26
tem = Asc(c) - 64
column += tem
Next
Return column - 1
End Function