You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
144 lines
5.6 KiB
144 lines
5.6 KiB
Imports System.IO
|
|
Imports System.Reflection
|
|
Imports System.Drawing
|
|
Imports System.FormatException
|
|
|
|
Public Class IconHelper
|
|
|
|
Dim icfIconFile As System.Drawing.IconFile
|
|
|
|
|
|
#Region "Icons"
|
|
|
|
ReadOnly Property CurrentIcon() As IconImage
|
|
Get
|
|
If icfIconFile Is Nothing Then
|
|
Return Nothing
|
|
Else
|
|
Return icfIconFile.Entries(0)
|
|
End If
|
|
End Get
|
|
End Property
|
|
|
|
#End Region
|
|
|
|
#Region "Treeview"
|
|
Sub Load_Treeview(ByRef tv As TreeView, ByRef imglst As ImageList, ByRef imglst2 As ImageList)
|
|
Dim ds As New DataSet
|
|
Dim tn As New TreeNode
|
|
Dim tn1 As New TreeNode
|
|
Dim tn2 As New TreeNode
|
|
imglst.Images.Clear()
|
|
imglst2.images.clear()
|
|
tv.Nodes.Clear()
|
|
Dim pid As Integer
|
|
|
|
Dim IconFileName As String = ""
|
|
Try
|
|
ds.ReadXml(ApplicationPath() + "icons\komponenten.xml")
|
|
For Each dr As DataRow In ds.Tables(0).Rows
|
|
If dr.Item("Parentid") = 0 Then
|
|
tn = tv.Nodes.Add(dr.Item("Bezeichnung"))
|
|
If dr.Item("Icon") <> "" Then
|
|
IconFileName = ApplicationPath() + "Icons\" + dr.Item("Icon")
|
|
Dim x As New System.Drawing.Bitmap(IconFileName)
|
|
imglst.Images.Add(x)
|
|
tn.ImageIndex = imglst.Images.Count - 1
|
|
tn.SelectedImageIndex = imglst.Images.Count - 1
|
|
'tn.StateImageIndex = imglst.Images.Count - 1
|
|
tn.Tag = dr.Item("Type")
|
|
pid = dr.Item("Key")
|
|
End If
|
|
Else
|
|
|
|
If dr.Item("Type") = "" Then
|
|
tn1 = tn.Nodes.Add(dr.Item("Bezeichnung"))
|
|
If dr.Item("Icon") <> "" Then
|
|
IconFileName = ApplicationPath() + "Icons\" + dr.Item("Icon")
|
|
Dim x As New System.Drawing.Bitmap(IconFileName)
|
|
imglst.Images.Add(x)
|
|
tn1.ImageIndex = imglst.Images.Count - 1
|
|
tn1.SelectedImageIndex = imglst.Images.Count - 1
|
|
'tn1.StateImageIndex = imglst.Images.Count - 1
|
|
tn1.Tag = dr.Item("Type")
|
|
End If
|
|
Else
|
|
If dr.Item("parentid") = pid And dr.Item("key").ToString.Length = 2 Then
|
|
tn1 = tn.Nodes.Add(dr.Item("Bezeichnung"))
|
|
If dr.Item("Icon") <> "" Then
|
|
IconFileName = ApplicationPath() + "Icons\" + dr.Item("Icon")
|
|
Dim x As New System.Drawing.Bitmap(IconFileName)
|
|
imglst.Images.Add(x)
|
|
tn1.ImageIndex = imglst.Images.Count - 1
|
|
tn1.SelectedImageIndex = imglst.Images.Count - 1
|
|
'tn1.StateImageIndex = imglst.Images.Count - 1
|
|
tn1.Tag = dr.Item("Type")
|
|
End If
|
|
Else
|
|
tn2 = tn1.Nodes.Add(dr.Item("Bezeichnung"))
|
|
If dr.Item("Icon") <> "" Then
|
|
IconFileName = ApplicationPath() + "Icons\" + dr.Item("Icon")
|
|
Try
|
|
Dim x As New System.Drawing.Bitmap(IconFileName)
|
|
imglst.Images.Add(x)
|
|
tn2.ImageIndex = imglst.Images.Count - 1
|
|
tn2.SelectedImageIndex = imglst.Images.Count - 1
|
|
'tn2.StateImageIndex = imglst.Images.Count - 1
|
|
tn2.Tag = dr.Item("Type")
|
|
Catch ex As Exception
|
|
MsgBox(ex.Message)
|
|
End Try
|
|
|
|
End If
|
|
End If
|
|
End If
|
|
End If
|
|
If dr.Item("Icon") <> "" Then
|
|
icfIconFile = New IconFile(IconFileName)
|
|
Dim icoimage As IconImage
|
|
icoimage = icfIconFile.Entries(0)
|
|
imglst2.Images.Add(icoimage.Icon)
|
|
End If
|
|
Next
|
|
Catch ex As Exception
|
|
MsgBox(ex.Message)
|
|
End Try
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
#Region "Background"
|
|
Public Function Load_Backgroundimage(ByVal imagename As String) As Image
|
|
Dim bm As New Bitmap(ApplicationPath() + "Icons\Background_Images\" + imagename)
|
|
Return bm
|
|
End Function
|
|
|
|
Public Function Background_Images(ByRef cb As Object)
|
|
cb.items.clear()
|
|
Dim folderInfo As New IO.DirectoryInfo(ApplicationPath() + "Icons\Background_Images\")
|
|
Dim arrFilesInFolder() As IO.FileInfo
|
|
Dim fileInFolder As IO.FileInfo
|
|
arrFilesInFolder = folderInfo.GetFiles("*.*")
|
|
For Each fileInFolder In arrFilesInFolder
|
|
cb.items.add(fileinfolder.name)
|
|
Next
|
|
|
|
End Function
|
|
|
|
|
|
#End Region
|
|
|
|
|
|
#Region "Utils"
|
|
''' <summary>
|
|
''' Aktueller Applikationspfad
|
|
''' </summary>
|
|
''' <returns></returns>
|
|
''' <remarks></remarks>
|
|
Public Function ApplicationPath() As String
|
|
'Return "E:\Software-Projekte\Vertragsverwaltung\Vertragsverwaltung\bin\Debug\"
|
|
Return Path.GetDirectoryName([Assembly].GetEntryAssembly().Location) + "\"
|
|
End Function
|
|
#End Region
|
|
End Class
|