Folge dem Video um zu sehen, wie unsere Website als Web-App auf dem Startbildschirm installiert werden kann.
Anmerkung: Diese Funktion ist in einigen Browsern möglicherweise nicht verfügbar.
Public Class RunPath
Dim RunPath As String
End Class
Public Class Argumente
Dim Argumente As String
End Class
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
Dim mk As RunPath = TryCast(TreeView1.SelectedNode.Tag, RunPath)
If mk IsNot Nothing Then
Label1.Text = RunPath
End If
Dim mk1 As Argumente = TryCast(TreeView1.SelectedNode.Tag, Argumente)
If mk1 IsNot Nothing Then
Label2.Text = Argumente
End If
End Sub
Public Class MeineXmlWerte
Dim RunPath As String
Dim Argumente As String
End Class
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
Dim mk As MeineXmlWerte = TryCast(TreeView1.SelectedNode.Tag, MeineXmlWerte)
If mk IsNot Nothing Then
Label1.Text = mk.RunPath
Label2.Text = mk.Argumente
End If
End Sub
Public Class MeineXmlWerte
Public RunPath As String
Public Argumente As String
End Class
Option Strict On
Imports System.Xml
Imports System.IO
Imports System.Text
Imports System.Text.RegularExpressions
Public Class treeViewLoadXml
Dim imgLst As New ImageList
Dim vImgPath(-1) As String, iv As Int32 = 0
Private Sub treeViewLoadXml_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Load_XML()
End Sub
Public Sub Load_XML()
Try
' Get Xml's file stream.
imgLst.ImageSize = New Drawing.Size(30, 27)
Dim vPath() As String = Split(Application.ExecutablePath, "\")
vPath(vPath.Length - 1) = "XMLFile1.xml"
Dim filepath As String = Join(vPath, "\")
Dim _rstream As New FileStream(filepath, FileMode.Open)
' Load Xml document.
'
Dim dom As New XmlDocument()
dom.Load(_rstream)
_rstream.Close()
' Initialize treeView control.
'
TreeView1.BeginUpdate()
TreeView1.Nodes.Clear()
TreeView1.Nodes.Add(New TreeNode(dom.DocumentElement.Name))
' Populate the treeView with the dom nodes.
'
AddNode(dom.DocumentElement, TreeView1.Nodes(0))
If CBool(iv) Then
For i = 0 To iv - 1
imgLst.Images.Add(Image.FromFile(vImgPath(i)))
Next
TreeView1.ImageList = imgLst
End If
TreeView1.EndUpdate()
'TreeView1.ExpandAll()
Catch xmlEx As XmlException
MessageBox.Show(xmlEx.Message)
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Private Sub AddNode(ByVal inXmlNode As XmlNode, ByVal inTreeNode As TreeNode)
Dim i As Integer
If inXmlNode.HasChildNodes Then
Dim nodeList As XmlNodeList
nodeList = inXmlNode.ChildNodes
i = 0
While i <= nodeList.Count - 1
Dim xNode As XmlNode = inXmlNode.ChildNodes(i)
Dim imgIndex As Int32 = -1
Dim SelimgIndex As Int32 = -1
If xNode.Attributes IsNot Nothing Then
For Each att As XmlAttribute In xNode.Attributes
If att.Name = "Icon" Then
imgIndex = addImage(att.Value)
SelimgIndex = addImage(att.Value)
Exit For
End If
Next
End If
Dim tNode As New TreeNode(xNode.Name)
Dim bIsTxt As Boolean = False
If tNode.Text = "#text" Then
tNode.Text = xNode.Value
bIsTxt = True
End If
If imgIndex <> -1 Then
tNode.ImageIndex = imgIndex
End If
If SelimgIndex <> -1 Then
tNode.SelectedImageIndex = SelimgIndex
End If
If bIsTxt Then
'inTreeNode.Text += " " + tNode.Text '
inTreeNode.Text = tNode.Text
Else
inTreeNode.Nodes.Add(tNode)
AddNode(xNode, tNode)
End If
i += 1
End While
If inXmlNode.Attributes IsNot Nothing AndAlso inXmlNode.Attributes("Path") IsNot Nothing Then
inTreeNode.Name = inXmlNode.Attributes("Path").Value
End If
If inXmlNode.Attributes IsNot Nothing AndAlso inXmlNode.Attributes("RunPath") IsNot Nothing Then
inTreeNode.Name = inXmlNode.Attributes("RunPath").Value
End If
If inXmlNode.Attributes IsNot Nothing AndAlso inXmlNode.Attributes("Argumente") IsNot Nothing Then
inTreeNode.Name = inXmlNode.Attributes("Argumente").Value
End If
End If
End Sub
Function addImage(path As String) As Int32
Dim i As Int32 = Array.IndexOf(vImgPath, path)
If i = -1 AndAlso IO.File.Exists(path) Then
ReDim Preserve vImgPath(iv)
Me.vImgPath(iv) = path
i = iv
iv += 1
End If
Return i
End Function
Private Sub TreeView1_NodeMouseDoubleClick(sender As Object, e As System.Windows.Forms.TreeNodeMouseClickEventArgs) Handles TreeView1.NodeMouseDoubleClick
Try
Dim Path As String = TreeView1.SelectedNode.Name
Dim Argumente As String = TreeView1.SelectedNode.Name
Dim RunPath As String = TreeView1.SelectedNode.Name
If IsNumeric(Path) Then
Dim nAction As Int32 = Int32.Parse(Path)
Select Case nAction
Case 1 'wenn was gemacht werden soll, wenn Path ist nur eine Zahl
' do job for Path="1" '
Case 2
' do job for Path="2" '
Case 3
' do job for Path="3" '
End Select
Else
Select Case e.Node.Text
Case "Visual Studio"
MsgBox("Visual Studio")
'...
Case "Excel"
MsgBox("Excel")
'...
Case "Notepad ++"
MsgBox("Notepad")
'...
End Select
If File.Exists(Path) Then
Process.Start(Path)
End If
End If
Catch ex As Exception
MsgBox("kein Programm gefunden")
End Try
End Sub
Public Class MeineXmlWerte
Public RunPath As String
Public Argumente As String
End Class
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
Dim mk As MeineXmlWerte = TryCast(TreeView1.SelectedNode.Tag, MeineXmlWerte)
If mk IsNot Nothing Then
Label1.Text = mk.RunPath
Label2.Text = mk.Argumente
End If
End Sub
End Class
Private Sub AddNode(ByVal inXmlNode As XmlNode, ByVal inTreeNode As TreeNode)
Dim mk As MeineXmlWerte = New MeineXmlWerte()
inTreeNode.Tag = mk
Dim i As Integer
If inXmlNode.HasChildNodes Then
...
If inXmlNode.Attributes IsNot Nothing AndAlso inXmlNode.Attributes("RunPath") IsNot Nothing Then
mk.RunPath = inXmlNode.Attributes("RunPath").Value
End If
If inXmlNode.Attributes IsNot Nothing AndAlso inXmlNode.Attributes("Argumente") IsNot Nothing Then
mk.Argumente = inXmlNode.Attributes("Argumente").Value
End If
...
End Sub