Click here to Skip to main content
Click here to Skip to main content
Articles » Languages » VB.NET » General » Downloads
 
Add your own
alternative version
Go to top

SmartLink

, 16 Dec 2006
SmartLink allows to group together the files across the network in logical folders, Groups
smartlink.zip
Setup
Debug
Setup.Exe
Setup.Ini
Setup.msi
Release
Setup.vdproj
SmartLink
SmartLink.vbproj.user
Imports System.Xml
Imports System.IO

Public Class frmLinkedFiles
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents tvwGroups As System.Windows.Forms.TreeView
    Friend WithEvents tvwFiles As System.Windows.Forms.TreeView
    Friend WithEvents txtFile As System.Windows.Forms.TextBox
    Friend WithEvents ImageList1 As System.Windows.Forms.ImageList
    Friend WithEvents panelAllGroups As System.Windows.Forms.Panel
    Friend WithEvents panelHeader As System.Windows.Forms.Panel
    Friend WithEvents btnClose As System.Windows.Forms.Button
    Friend WithEvents panelFile As System.Windows.Forms.Panel
    Friend WithEvents lblAllGroups As System.Windows.Forms.Label
    Friend WithEvents lblHeader As System.Windows.Forms.Label
    Friend WithEvents lblFile As System.Windows.Forms.Label
    Friend WithEvents ToolTip As System.Windows.Forms.ToolTip
    Friend WithEvents panelFooter As System.Windows.Forms.Panel
    Friend WithEvents UsrLogo1 As SmartLink.usrLogo
    Friend WithEvents lblLine As System.Windows.Forms.Label
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.components = New System.ComponentModel.Container
        Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(frmLinkedFiles))
        Me.tvwGroups = New System.Windows.Forms.TreeView
        Me.ImageList1 = New System.Windows.Forms.ImageList(Me.components)
        Me.tvwFiles = New System.Windows.Forms.TreeView
        Me.txtFile = New System.Windows.Forms.TextBox
        Me.panelAllGroups = New System.Windows.Forms.Panel
        Me.lblAllGroups = New System.Windows.Forms.Label
        Me.panelHeader = New System.Windows.Forms.Panel
        Me.btnClose = New System.Windows.Forms.Button
        Me.lblHeader = New System.Windows.Forms.Label
        Me.panelFile = New System.Windows.Forms.Panel
        Me.lblFile = New System.Windows.Forms.Label
        Me.ToolTip = New System.Windows.Forms.ToolTip(Me.components)
        Me.panelFooter = New System.Windows.Forms.Panel
        Me.UsrLogo1 = New SmartLink.usrLogo
        Me.lblLine = New System.Windows.Forms.Label
        Me.panelAllGroups.SuspendLayout()
        Me.panelHeader.SuspendLayout()
        Me.panelFile.SuspendLayout()
        Me.panelFooter.SuspendLayout()
        Me.SuspendLayout()
        '
        'tvwGroups
        '
        Me.tvwGroups.BackColor = System.Drawing.Color.White
        Me.tvwGroups.BorderStyle = System.Windows.Forms.BorderStyle.None
        Me.tvwGroups.ImageList = Me.ImageList1
        Me.tvwGroups.Location = New System.Drawing.Point(2, 100)
        Me.tvwGroups.Name = "tvwGroups"
        Me.tvwGroups.Size = New System.Drawing.Size(192, 416)
        Me.tvwGroups.TabIndex = 0
        '
        'ImageList1
        '
        Me.ImageList1.ImageSize = New System.Drawing.Size(16, 16)
        Me.ImageList1.ImageStream = CType(resources.GetObject("ImageList1.ImageStream"), System.Windows.Forms.ImageListStreamer)
        Me.ImageList1.TransparentColor = System.Drawing.Color.Transparent
        '
        'tvwFiles
        '
        Me.tvwFiles.BackColor = System.Drawing.Color.White
        Me.tvwFiles.BorderStyle = System.Windows.Forms.BorderStyle.None
        Me.tvwFiles.ImageList = Me.ImageList1
        Me.tvwFiles.Location = New System.Drawing.Point(195, 100)
        Me.tvwFiles.Name = "tvwFiles"
        Me.tvwFiles.Size = New System.Drawing.Size(598, 416)
        Me.tvwFiles.TabIndex = 1
        '
        'txtFile
        '
        Me.txtFile.BackColor = System.Drawing.Color.White
        Me.txtFile.Location = New System.Drawing.Point(53, 9)
        Me.txtFile.Multiline = True
        Me.txtFile.Name = "txtFile"
        Me.txtFile.ReadOnly = True
        Me.txtFile.ScrollBars = System.Windows.Forms.ScrollBars.Vertical
        Me.txtFile.Size = New System.Drawing.Size(539, 34)
        Me.txtFile.TabIndex = 10
        Me.txtFile.Text = ""
        Me.ToolTip.SetToolTip(Me.txtFile, "Selected File")
        '
        'panelAllGroups
        '
        Me.panelAllGroups.BackColor = System.Drawing.Color.Transparent
        Me.panelAllGroups.Controls.Add(Me.lblAllGroups)
        Me.panelAllGroups.Location = New System.Drawing.Point(2, 48)
        Me.panelAllGroups.Name = "panelAllGroups"
        Me.panelAllGroups.Size = New System.Drawing.Size(192, 52)
        Me.panelAllGroups.TabIndex = 15
        '
        'lblAllGroups
        '
        Me.lblAllGroups.AutoSize = True
        Me.lblAllGroups.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.lblAllGroups.ForeColor = System.Drawing.SystemColors.ControlText
        Me.lblAllGroups.Location = New System.Drawing.Point(16, 7)
        Me.lblAllGroups.Name = "lblAllGroups"
        Me.lblAllGroups.Size = New System.Drawing.Size(62, 17)
        Me.lblAllGroups.TabIndex = 18
        Me.lblAllGroups.Text = "All Groups"
        Me.lblAllGroups.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
        '
        'panelHeader
        '
        Me.panelHeader.BackColor = System.Drawing.Color.CornflowerBlue
        Me.panelHeader.BackgroundImage = CType(resources.GetObject("panelHeader.BackgroundImage"), System.Drawing.Image)
        Me.panelHeader.Controls.Add(Me.btnClose)
        Me.panelHeader.Controls.Add(Me.lblHeader)
        Me.panelHeader.Location = New System.Drawing.Point(2, 2)
        Me.panelHeader.Name = "panelHeader"
        Me.panelHeader.Size = New System.Drawing.Size(794, 44)
        Me.panelHeader.TabIndex = 18
        '
        'btnClose
        '
        Me.btnClose.Anchor = System.Windows.Forms.AnchorStyles.Right
        Me.btnClose.BackColor = System.Drawing.SystemColors.Window
        Me.btnClose.FlatStyle = System.Windows.Forms.FlatStyle.Popup
        Me.btnClose.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.btnClose.Location = New System.Drawing.Point(768, 13)
        Me.btnClose.Name = "btnClose"
        Me.btnClose.Size = New System.Drawing.Size(17, 16)
        Me.btnClose.TabIndex = 20
        Me.btnClose.Text = "�"
        Me.ToolTip.SetToolTip(Me.btnClose, "Exit")
        '
        'lblHeader
        '
        Me.lblHeader.AutoSize = True
        Me.lblHeader.BackColor = System.Drawing.Color.Transparent
        Me.lblHeader.Font = New System.Drawing.Font("Microsoft Sans Serif", 11.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.lblHeader.ForeColor = System.Drawing.Color.White
        Me.lblHeader.Location = New System.Drawing.Point(8, 11)
        Me.lblHeader.Name = "lblHeader"
        Me.lblHeader.Size = New System.Drawing.Size(92, 20)
        Me.lblHeader.TabIndex = 18
        Me.lblHeader.Text = "Linked Files"
        Me.lblHeader.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
        '
        'panelFile
        '
        Me.panelFile.BackColor = System.Drawing.Color.Transparent
        Me.panelFile.Controls.Add(Me.lblFile)
        Me.panelFile.Controls.Add(Me.txtFile)
        Me.panelFile.Location = New System.Drawing.Point(195, 48)
        Me.panelFile.Name = "panelFile"
        Me.panelFile.Size = New System.Drawing.Size(600, 52)
        Me.panelFile.TabIndex = 19
        '
        'lblFile
        '
        Me.lblFile.AutoSize = True
        Me.lblFile.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.lblFile.ForeColor = System.Drawing.SystemColors.ControlText
        Me.lblFile.Location = New System.Drawing.Point(16, 7)
        Me.lblFile.Name = "lblFile"
        Me.lblFile.Size = New System.Drawing.Size(25, 17)
        Me.lblFile.TabIndex = 19
        Me.lblFile.Text = "File"
        '
        'panelFooter
        '
        Me.panelFooter.BackColor = System.Drawing.Color.GhostWhite
        Me.panelFooter.BackgroundImage = CType(resources.GetObject("panelFooter.BackgroundImage"), System.Drawing.Image)
        Me.panelFooter.Controls.Add(Me.UsrLogo1)
        Me.panelFooter.Location = New System.Drawing.Point(2, 517)
        Me.panelFooter.Name = "panelFooter"
        Me.panelFooter.Size = New System.Drawing.Size(794, 41)
        Me.panelFooter.TabIndex = 26
        '
        'UsrLogo1
        '
        Me.UsrLogo1.BackgroundImage = CType(resources.GetObject("UsrLogo1.BackgroundImage"), System.Drawing.Image)
        Me.UsrLogo1.Location = New System.Drawing.Point(8, 6)
        Me.UsrLogo1.Name = "UsrLogo1"
        Me.UsrLogo1.Size = New System.Drawing.Size(96, 28)
        Me.UsrLogo1.TabIndex = 6
        '
        'lblLine
        '
        Me.lblLine.Location = New System.Drawing.Point(195, 100)
        Me.lblLine.Name = "lblLine"
        Me.lblLine.Size = New System.Drawing.Size(1, 416)
        Me.lblLine.TabIndex = 27
        Me.lblLine.Text = "Label1"
        '
        'frmLinkedFiles
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.BackColor = System.Drawing.Color.Black
        Me.BackgroundImage = CType(resources.GetObject("$this.BackgroundImage"), System.Drawing.Image)
        Me.ClientSize = New System.Drawing.Size(797, 560)
        Me.Controls.Add(Me.lblLine)
        Me.Controls.Add(Me.panelFooter)
        Me.Controls.Add(Me.panelFile)
        Me.Controls.Add(Me.panelHeader)
        Me.Controls.Add(Me.panelAllGroups)
        Me.Controls.Add(Me.tvwFiles)
        Me.Controls.Add(Me.tvwGroups)
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None
        Me.MaximizeBox = False
        Me.MinimizeBox = False
        Me.Name = "frmLinkedFiles"
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        Me.Text = "Linked Files"
        Me.panelAllGroups.ResumeLayout(False)
        Me.panelHeader.ResumeLayout(False)
        Me.panelFile.ResumeLayout(False)
        Me.panelFooter.ResumeLayout(False)
        Me.ResumeLayout(False)

    End Sub

#End Region

#Region "Event Handlers"
    Private Sub frmLinkedFiles_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Try
            Call LoadXML()

            If LinkPresent() = True Then
                Call LoadControls()
                Call LoadGroupFiles()
            Else
                Dim frm As New frmMessage("File '" & FILENAME & "' is not linked with any Group")
                frm.ShowDialog()
                Me.Close()
                End
            End If
        Catch ex As Exception
            MessageBox.Show(ex.Message, Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try
    End Sub

    Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click
        Me.Close()
        End
    End Sub

    Private Sub tvwGroups_DoubleClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tvwGroups.DoubleClick
        Try
            Me.Cursor = Cursors.WaitCursor

            Dim RootNode As New TreeNode(tvwGroups.SelectedNode.Text)

            tvwFiles.Nodes.Clear()
            tvwFiles.Nodes.Add(RootNode)

            Call LoadFiles(RootNode)
            RootNode.ExpandAll()

        Catch ex As Exception
            MessageBox.Show(ex.Message, Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Error)
        Finally
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub tvwFiles_DoubleClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tvwFiles.DoubleClick
        Try
            If tvwFiles.SelectedNode.Tag = "FILE" Then
                Dim process As New Process
                process.Start(tvwFiles.SelectedNode.Text)
            End If

        Catch ex As Exception
            Dim frm As New frmMessage(ex.Message)
            frm.ShowDialog()
        End Try
    End Sub
#End Region

#Region "Procedures"
    Private Sub LoadControls()
        Try
            txtFile.Text = FILENAME
        Catch ex As Exception
            MessageBox.Show(ex.Message, Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try
    End Sub

    Private Sub LoadGroupFiles()
        Try
            Me.Cursor = Cursors.WaitCursor

            Dim GroupNodes As XmlNodeList = XMLDOC.GetElementsByTagName("Group")
            tvwFiles.Nodes.Clear()

            For Each Node As XmlNode In GroupNodes
                For Each ChildNode As XmlNode In Node.ChildNodes
                    Dim GroupName As String

                    Select Case ChildNode.Name
                        Case "GroupName"
                            If ChildNode.InnerText <> "" Then
                                GroupName = ChildNode.InnerText
                                tvwGroups.Nodes.Add(GroupName)
                            End If

                        Case "File"
                            If ChildNode.InnerText = FILENAME Then
                                Dim RootNode As New TreeNode(GroupName)
                                tvwFiles.Nodes.Add(RootNode)
                                Call LoadFiles(RootNode)
                                RootNode.ExpandAll()
                            End If
                    End Select
                Next
            Next

        Catch ex As Exception
            MessageBox.Show(ex.Message, Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Error)
        Finally
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub LoadFiles(ByVal RootNode As TreeNode)
        Try
            RootNode.Nodes.Clear()

            Dim GroupNodes As XmlNodeList = XMLDOC.GetElementsByTagName("Group")

            For Each Node As XmlNode In GroupNodes
                If Node.Item("GroupName").InnerText = RootNode.Text Then
                    For Each ChildNode As XmlNode In Node.ChildNodes
                        Select Case ChildNode.Name
                            Case "File"
                                If File.Exists(ChildNode.InnerText) Then
                                    Dim FileNode As New TreeNode(ChildNode.InnerText)
                                    ImageList1.Images.Add(GetIconFileType(ChildNode.InnerText))
                                    FileNode.ImageIndex = ImageList1.Images.Count - 1
                                    FileNode.SelectedImageIndex = ImageList1.Images.Count - 1
                                    FileNode.Tag = "FILE"
                                    RootNode.Nodes.Add(FileNode)
                                End If
                        End Select

                    Next
                End If
            Next

        Catch ex As Exception
            MessageBox.Show(ex.Message, Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try

    End Sub
#End Region

#Region "Functions"
    Private Function LinkPresent() As Boolean
        Try
            Dim GroupNodes As XmlNodeList = XMLDOC.GetElementsByTagName("Group")

            For Each Node As XmlNode In GroupNodes
                For Each ChildNode As XmlNode In Node.ChildNodes
                    If ChildNode.InnerText = FILENAME Then
                        Return True
                    End If
                Next
            Next

            Return False

        Catch ex As Exception
            MessageBox.Show(ex.Message, Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try
    End Function
#End Region

End Class

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Shirish Wagh
Web Developer
India India
Hey, this is Shirish a software guy by profession. Along with my hectic job schedule, I like to work on different ideas. I am in total love with all the GUI related things. I also like to work with the databases. I enjoy, to develop some simple tools which can be useful to other software professionls like me as well the normal users.
 
Please feel free to contact me with suggestions/ideas, at mentioned email address.
shirish.wagh@yahoo.com

| Advertise | Privacy | Mobile
Web03 | 2.8.140922.1 | Last Updated 16 Dec 2006
Article Copyright 2006 by Shirish Wagh
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid