View Sidebar

A Million Little Pieces Of My Mind

Organica Core: LinkDocument class

By: Paul S. Cilwa Viewed: 2/23/2024
Posted: 8/3/2018
Page Views: 592
Topics: #Computers #Programming #Organica #VB.NET
A derived Document class to follow shortcuts to a document located elsewhere.

In the Windows environment, it's common to create a "shortcut" to some program or file, perhaps on the Desktop. In most cases, Windows treats a shortcut (called a "link" in earlier versions of Windows) as if it were the file it points to.

In the Organica environment, shortcuts work similarly but, of course, they can only point to documents (including Folder documents).

Another cool feature of a LinkDocument object is that it can override various properties of the Document it points to, such as the display name or author's name. In the case of a MusicDocument (which we'll create eventually), it could be convenient to override the Track Number and Album Name so that a duplicate track needn't be literally duplicated for a Greatest Hits AlbumDocument.

For now, however, we just need the bare minimum for this class: A few basic properties, and the ability for this class to display instances of itself in the browser window.

Documents.vb (append)

Class LinkDocument Inherits Document Public IconPath As String Public LinkName As String Public Sub New(ByVal a_Pathname As String, _ Optional ByVal an_IconPath As String = "TypeUnknown.png", _ Optional ByVal a_LinkName As String = "Magical Link") MyBase.New(a_Pathname) IconPath = an_IconPath LinkName = a_LinkName End Sub Public Overloads Overrides ReadOnly Property HTML As String Get Dim Buffer As String Buffer = "<div class='organica_Document organica_Folder'>" ConCat(Buffer, "<img src='" & IconPath & "'><div>") ConCat(Buffer, "<h1>" & Filename & "</h1>") ConCat(Buffer, "<p>" & Pathname & "</p>") ConCat(Buffer, "</div>") Return Buffer End Get End Property Public Overloads Overrides ReadOnly Property Filename As String Get Return LinkName End Get End Property Public Overloads Overrides ReadOnly Property DisplayName As String Get Return Filename End Get End Property End Class