Click here to Skip to main content
15,891,473 members
Articles / Programming Languages / Visual Basic

GN Wizard Framework

Rate me:
Please Sign up or sign in to vote.
4.73/5 (51 votes)
21 Dec 2006CPOL3 min read 176.4K   1.7K   94  
A simple Wizard framework.
Imports System.Reflection
Imports System.Windows.Forms
Imports System.IO
Imports System.Drawing
Imports System.Text.RegularExpressions
Imports Microsoft.Win32

''' <summary>
''' generic, self-contained About Box dialog
''' </summary>
''' <remarks>
''' </remarks>
Public Class About
    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.
    Private WithEvents OKButton As System.Windows.Forms.Button
    Private WithEvents AppTitleLabel As System.Windows.Forms.Label
    Private WithEvents AppDescriptionLabel As System.Windows.Forms.Label
    Private WithEvents AppVersionLabel As System.Windows.Forms.Label
    Private WithEvents AppCopyrightLabel As System.Windows.Forms.Label
    Private WithEvents AppDateLabel As System.Windows.Forms.Label
    Friend WithEvents lblCompany As System.Windows.Forms.LinkLabel
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(About))
        Me.OKButton = New System.Windows.Forms.Button
        Me.AppTitleLabel = New System.Windows.Forms.Label
        Me.AppDescriptionLabel = New System.Windows.Forms.Label
        Me.AppVersionLabel = New System.Windows.Forms.Label
        Me.AppCopyrightLabel = New System.Windows.Forms.Label
        Me.AppDateLabel = New System.Windows.Forms.Label
        Me.lblCompany = New System.Windows.Forms.LinkLabel
        Me.SuspendLayout()
        '
        'OKButton
        '
        Me.OKButton.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.OKButton.BackColor = System.Drawing.Color.Transparent
        Me.OKButton.DialogResult = System.Windows.Forms.DialogResult.Cancel
        Me.OKButton.FlatStyle = System.Windows.Forms.FlatStyle.System
        Me.OKButton.Location = New System.Drawing.Point(259, 183)
        Me.OKButton.Name = "OKButton"
        Me.OKButton.Size = New System.Drawing.Size(76, 23)
        Me.OKButton.TabIndex = 1
        Me.OKButton.Text = "OK"
        '
        'AppTitleLabel
        '
        Me.AppTitleLabel.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
                    Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.AppTitleLabel.BackColor = System.Drawing.Color.Transparent
        Me.AppTitleLabel.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.AppTitleLabel.Location = New System.Drawing.Point(56, 80)
        Me.AppTitleLabel.Name = "AppTitleLabel"
        Me.AppTitleLabel.Size = New System.Drawing.Size(264, 16)
        Me.AppTitleLabel.TabIndex = 2
        Me.AppTitleLabel.Text = "%title%"
        '
        'AppDescriptionLabel
        '
        Me.AppDescriptionLabel.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
                    Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.AppDescriptionLabel.BackColor = System.Drawing.Color.Transparent
        Me.AppDescriptionLabel.Location = New System.Drawing.Point(56, 101)
        Me.AppDescriptionLabel.Name = "AppDescriptionLabel"
        Me.AppDescriptionLabel.Size = New System.Drawing.Size(181, 16)
        Me.AppDescriptionLabel.TabIndex = 4
        Me.AppDescriptionLabel.Text = "%description%"
        '
        'AppVersionLabel
        '
        Me.AppVersionLabel.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
                    Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.AppVersionLabel.BackColor = System.Drawing.Color.Transparent
        Me.AppVersionLabel.Location = New System.Drawing.Point(56, 120)
        Me.AppVersionLabel.Name = "AppVersionLabel"
        Me.AppVersionLabel.Size = New System.Drawing.Size(135, 16)
        Me.AppVersionLabel.TabIndex = 5
        Me.AppVersionLabel.Text = "Version %version%"
        '
        'AppCopyrightLabel
        '
        Me.AppCopyrightLabel.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
                    Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.AppCopyrightLabel.BackColor = System.Drawing.Color.Transparent
        Me.AppCopyrightLabel.Location = New System.Drawing.Point(32, 192)
        Me.AppCopyrightLabel.Name = "AppCopyrightLabel"
        Me.AppCopyrightLabel.Size = New System.Drawing.Size(227, 16)
        Me.AppCopyrightLabel.TabIndex = 6
        Me.AppCopyrightLabel.Text = "Copyright �%copyright%"
        '
        'AppDateLabel
        '
        Me.AppDateLabel.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
                    Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.AppDateLabel.BackColor = System.Drawing.Color.Transparent
        Me.AppDateLabel.Location = New System.Drawing.Point(56, 140)
        Me.AppDateLabel.Name = "AppDateLabel"
        Me.AppDateLabel.Size = New System.Drawing.Size(240, 16)
        Me.AppDateLabel.TabIndex = 8
        Me.AppDateLabel.Text = "Built on %builddate%"
        '
        'lblCompany
        '
        Me.lblCompany.BackColor = System.Drawing.Color.Transparent
        Me.lblCompany.ImageAlign = System.Drawing.ContentAlignment.MiddleRight
        Me.lblCompany.LinkBehavior = System.Windows.Forms.LinkBehavior.HoverUnderline
        Me.lblCompany.Location = New System.Drawing.Point(160, 8)
        Me.lblCompany.Name = "lblCompany"
        Me.lblCompany.Size = New System.Drawing.Size(176, 16)
        Me.lblCompany.TabIndex = 10
        Me.lblCompany.TabStop = True
        Me.lblCompany.Text = "%company%"
        Me.lblCompany.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'About
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.BackgroundImage = CType(resources.GetObject("$this.BackgroundImage"), System.Drawing.Image)
        Me.CancelButton = Me.OKButton
        Me.ClientSize = New System.Drawing.Size(343, 211)
        Me.Controls.Add(Me.OKButton)
        Me.Controls.Add(Me.lblCompany)
        Me.Controls.Add(Me.AppDateLabel)
        Me.Controls.Add(Me.AppCopyrightLabel)
        Me.Controls.Add(Me.AppVersionLabel)
        Me.Controls.Add(Me.AppDescriptionLabel)
        Me.Controls.Add(Me.AppTitleLabel)
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None
        Me.MaximizeBox = False
        Me.MaximumSize = New System.Drawing.Size(343, 211)
        Me.MinimizeBox = False
        Me.MinimumSize = New System.Drawing.Size(343, 211)
        Me.Name = "About"
        Me.ShowInTaskbar = False
        Me.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        Me.Text = "About %title%"
        Me.TransparencyKey = System.Drawing.Color.Magenta
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private _mIsPainted As Boolean = False
    Private _mstrEntryAssemblyName As String
    Private _mstrCallingAssemblyName As String
    Private _mstrExecutingAssemblyName As String
    Private _mstrEntryAssembly As System.Reflection.Assembly
    Private _mstrEntryAssemblyAttribCollection As Specialized.NameValueCollection
    Private _mLocalAppCalling As Boolean

#Region "Properties"

    ''' <summary>
    ''' Returns the entry assembly for the current application domain
    ''' </summary>
    ''' <remarks>
    ''' This is usually read-only, but in some weird cases (Smart Client apps) 
    ''' you won't have an entry assembly, so you may want to set this manually.
    ''' </remarks>
    Public Property AppEntryAssembly() As System.Reflection.Assembly
        Get
            Return _mstrEntryAssembly
        End Get
        Set(ByVal Value As System.Reflection.Assembly)
            _mstrEntryAssembly = Value
        End Set
    End Property

    ''' <summary>
    ''' single line of text to show in the application title section of the about box dialog
    ''' </summary>
    ''' <remarks>
    ''' defaults to "%title%" 
    ''' %title% = Assembly: AssemblyTitle
    ''' </remarks>
    Public Property AppTitle() As String
        Get
            Return AppTitleLabel.Text
        End Get
        Set(ByVal Value As String)
            AppTitleLabel.Text = Value
        End Set
    End Property

    ''' <summary>
    ''' single line of text to show in the description section of the about box dialog
    ''' </summary>
    ''' <remarks>
    ''' defaults to "%description%"
    ''' %description% = Assembly: AssemblyDescription
    ''' </remarks>
    Public Property AppDescription() As String
        Get
            Return AppDescriptionLabel.Text
        End Get
        Set(ByVal Value As String)
            If Value = "" Then
                AppDescriptionLabel.Visible = False
            Else
                AppDescriptionLabel.Visible = True
                AppDescriptionLabel.Text = Value
            End If
        End Set
    End Property


    ''' <summary>
    ''' single line of text to show in the description section of the about box dialog
    ''' </summary>
    ''' <remarks>
    ''' defaults to "%description%"
    ''' %description% = Assembly: AssemblyDescription
    ''' </remarks>
    Public WriteOnly Property IsCallingAssembly() As Boolean
        Set(ByVal Value As Boolean)
            _mLocalAppCalling = Value
        End Set
    End Property

    ''' <summary>
    ''' single line of text to show in the version section of the about dialog
    ''' </summary>
    ''' <remarks>
    ''' defaults to "Version %version%"
    ''' %version% = Assembly: AssemblyVersion
    ''' </remarks>
    Public Property AppVersion() As String
        Get
            Return AppVersionLabel.Text
        End Get
        Set(ByVal Value As String)
            If Value = "" Then
                AppVersionLabel.Visible = False
            Else
                AppVersionLabel.Visible = True
                AppVersionLabel.Text = Value
            End If
        End Set
    End Property

    ''' <summary>
    ''' single line of text to show in the copyright section of the about dialog
    ''' </summary>
    ''' <remarks>
    ''' defaults to "Copyright � %year%, %company%"
    ''' %company% = Assembly: AssemblyCompany
    ''' %year% = current 4-digit year
    ''' </remarks>
    Public Property AppCopyright() As String
        Get
            Return AppCopyrightLabel.Text
        End Get
        Set(ByVal Value As String)
            If Value = "" Then
                AppCopyrightLabel.Visible = False
            Else
                AppCopyrightLabel.Visible = True
                AppCopyrightLabel.Text = Value
            End If
        End Set
    End Property

#End Region

    ''' <summary>
    ''' exception-safe retrieval of LastWriteTime for this assembly.
    ''' </summary>
    ''' <returns>File.GetLastWriteTime, or DateTime.MaxValue if exception was encountered.</returns>
    Private Shared Function AssemblyLastWriteTime(ByVal a As System.Reflection.Assembly) As DateTime
        Try
            Return File.GetLastWriteTime(a.Location)
        Catch ex As Exception
            Return DateTime.MaxValue
        End Try
    End Function

    ''' <summary>
    ''' Returns DateTime this Assembly was last built. Will attempt to calculate from build number, if possible. 
    ''' If not, the actual LastWriteTime on the assembly file will be returned.
    ''' </summary>
    ''' <param name="a">Assembly to get build date for</param>
    ''' <param name="ForceFileDate">Don't attempt to use the build number to calculate the date</param>
    ''' <returns>DateTime this assembly was last built</returns>
    Private Shared Function AssemblyBuildDate(ByVal a As System.Reflection.Assembly, _
        Optional ByVal ForceFileDate As Boolean = False) As DateTime

        Dim AssemblyVersion As System.Version = a.GetName.Version
        Dim dt As DateTime

        If ForceFileDate Then
            dt = AssemblyLastWriteTime(a)
        Else
            dt = CType("01/01/2000", DateTime). _
                AddDays(AssemblyVersion.Build). _
                AddSeconds(AssemblyVersion.Revision * 2)
            If TimeZone.IsDaylightSavingTime(dt, TimeZone.CurrentTimeZone.GetDaylightChanges(dt.Year)) Then
                dt = dt.AddHours(1)
            End If
            If dt > DateTime.Now Or AssemblyVersion.Build < 730 Or AssemblyVersion.Revision = 0 Then
                dt = AssemblyLastWriteTime(a)
            End If
        End If

        Return dt
    End Function

    ''' <summary>
    ''' returns string name / string value pair of all attribs
    ''' for specified assembly
    ''' </summary>
    ''' <remarks>
    ''' note that Assembly* values are pulled from AssemblyInfo file in project folder
    '''
    ''' Trademark       = AssemblyTrademark string
    ''' Debuggable      = True
    ''' GUID            = 7FDF68D5-8C6F-44C9-B391-117B5AFB5467
    ''' CLSCompliant    = True
    ''' Product         = AssemblyProduct string
    ''' Copyright       = AssemblyCopyright string
    ''' Company         = AssemblyCompany string
    ''' Description     = AssemblyDescription string
    ''' Title           = AssemblyTitle string
    ''' </remarks>
    Private Function AssemblyAttribs(ByVal a As System.Reflection.Assembly) As Specialized.NameValueCollection
        Dim TypeName As String
        Dim Name As String
        Dim Value As String
        Dim nvc As New Specialized.NameValueCollection
        Dim r As New Regex("(\.Assembly|\.)(?<Name>[^.]*)Attribute$", RegexOptions.IgnoreCase)

        For Each attrib As Object In a.GetCustomAttributes(False)
            TypeName = attrib.GetType().ToString
            Name = r.Match(TypeName).Groups("Name").ToString
            Value = ""
            Select Case TypeName
                Case "System.CLSCompliantAttribute"
                    Value = CType(attrib, CLSCompliantAttribute).IsCompliant.ToString
                Case "System.Diagnostics.DebuggableAttribute"
                    Value = CType(attrib, Diagnostics.DebuggableAttribute).IsJITTrackingEnabled.ToString
                Case "System.Reflection.AssemblyCompanyAttribute"
                    Value = CType(attrib, AssemblyCompanyAttribute).Company.ToString
                Case "System.Reflection.AssemblyConfigurationAttribute"
                    Value = CType(attrib, AssemblyConfigurationAttribute).Configuration.ToString
                Case "System.Reflection.AssemblyCopyrightAttribute"
                    Value = CType(attrib, AssemblyCopyrightAttribute).Copyright.ToString
                Case "System.Reflection.AssemblyDefaultAliasAttribute"
                    Value = CType(attrib, AssemblyDefaultAliasAttribute).DefaultAlias.ToString
                Case "System.Reflection.AssemblyDelaySignAttribute"
                    Value = CType(attrib, AssemblyDelaySignAttribute).DelaySign.ToString
                Case "System.Reflection.AssemblyDescriptionAttribute"
                    Value = CType(attrib, AssemblyDescriptionAttribute).Description.ToString
                Case "System.Reflection.AssemblyInformationalVersionAttribute"
                    Value = CType(attrib, AssemblyInformationalVersionAttribute).InformationalVersion.ToString
                Case "System.Reflection.AssemblyKeyFileAttribute"
                    Value = CType(attrib, AssemblyKeyFileAttribute).KeyFile.ToString
                Case "System.Reflection.AssemblyProductAttribute"
                    Value = CType(attrib, AssemblyProductAttribute).Product.ToString
                Case "System.Reflection.AssemblyTrademarkAttribute"
                    Value = CType(attrib, AssemblyTrademarkAttribute).Trademark.ToString
                Case "System.Reflection.AssemblyTitleAttribute"
                    Value = CType(attrib, AssemblyTitleAttribute).Title.ToString
                Case "System.Resources.NeutralResourcesLanguageAttribute"
                    Value = CType(attrib, Resources.NeutralResourcesLanguageAttribute).CultureName.ToString
                Case "System.Resources.SatelliteContractVersionAttribute"
                    Value = CType(attrib, Resources.SatelliteContractVersionAttribute).Version.ToString
                Case "System.Runtime.InteropServices.ComCompatibleVersionAttribute"
                    Dim x As Runtime.InteropServices.ComCompatibleVersionAttribute
                    x = CType(attrib, Runtime.InteropServices.ComCompatibleVersionAttribute)
                    Value = x.MajorVersion & "." & x.MinorVersion & "." & x.RevisionNumber & "." & x.BuildNumber
                Case "System.Runtime.InteropServices.ComVisibleAttribute"
                    Value = CType(attrib, Runtime.InteropServices.ComVisibleAttribute).Value.ToString
                Case "System.Runtime.InteropServices.GuidAttribute"
                    Value = CType(attrib, Runtime.InteropServices.GuidAttribute).Value.ToString
                Case "System.Runtime.InteropServices.TypeLibVersionAttribute"
                    Dim x As Runtime.InteropServices.TypeLibVersionAttribute
                    x = CType(attrib, Runtime.InteropServices.TypeLibVersionAttribute)
                    Value = x.MajorVersion & "." & x.MinorVersion
                Case "System.Security.AllowPartiallyTrustedCallersAttribute"
                    Value = "(Present)"
                Case Else
                    '-- debug.writeline("** unknown assembly attribute '" & TypeName & "'")
                    Value = TypeName
            End Select

            If nvc.Item(Name) = "" Then
                nvc.Add(Name, Value)
            End If
        Next

        '-- add some extra values that are not in the AssemblyInfo, but nice to have
        With nvc
            '-- codebase
            Try
                .Add("CodeBase", a.CodeBase.Replace("file:///", ""))
            Catch ex As System.NotSupportedException
                .Add("CodeBase", "(not supported)")
            End Try
            '-- build date
            Dim dt As DateTime = AssemblyBuildDate(a)
            If dt = DateTime.MaxValue Then
                .Add("BuildDate", "(unknown)")
            Else
                .Add("BuildDate", dt.ToString("dd-MM-yyyy hh:mm tt"))
            End If
            '-- location
            Try
                .Add("Location", a.Location)
            Catch ex As System.NotSupportedException
                .Add("Location", "(not supported)")
            End Try
            '-- version
            Try
                If a.GetName.Version.Major = 0 And a.GetName.Version.Minor = 0 Then
                    .Add("Version", "(unknown)")
                Else
                    .Add("Version", a.GetName.Version.ToString)
                End If
            Catch ex As Exception
                .Add("Version", "(unknown)")
            End Try

            .Add("FullName", a.FullName)
        End With

        Return nvc
    End Function

    ''' <summary>
    ''' reads an HKLM Windows Registry key value
    ''' </summary>
    Private Function RegistryHklmValue(ByVal KeyName As String, ByVal SubKeyRef As String) As String
        Dim rk As RegistryKey
        Try
            rk = Registry.LocalMachine.OpenSubKey(KeyName)
            Return CType(rk.GetValue(SubKeyRef, ""), String)
        Catch ex As Exception
            Return ""
        End Try
    End Function

    ''' <summary>
    ''' launch the MSInfo "system information" application
    ''' </summary>
    Private Sub ShowSysInfo()
        Dim strSysInfoPath As String = ""

        strSysInfoPath = RegistryHklmValue("SOFTWARE\Microsoft\Shared Tools Location", "MSINFO")
        If strSysInfoPath = "" Then
            strSysInfoPath = RegistryHklmValue("SOFTWARE\Microsoft\Shared Tools\MSINFO", "PATH")
        End If

        If strSysInfoPath = "" Then
            MessageBox.Show("System Information is unavailable at this time." & _
                Environment.NewLine & _
                Environment.NewLine & _
                "(couldn't find path for Microsoft System Information Tool in the registry.)", _
                Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning)
            Return
        End If

        Try
            Process.Start(strSysInfoPath)
        Catch ex As Exception
            MessageBox.Show("System Information is unavailable at this time." & _
                Environment.NewLine & _
                Environment.NewLine & _
                "(couldn't launch '" & strSysInfoPath & "')", _
                Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Stop)
        End Try

    End Sub

    ''' <summary>
    ''' populate a listview with the specified key and value strings
    ''' </summary>
    Private Sub Populate(ByVal lvw As ListView, ByVal Key As String, ByVal Value As String)
        If Value = "" Then Return
        Dim lvi As New Windows.Forms.ListViewItem
        lvi.Text = Key
        lvi.SubItems.Add(Value)
        lvw.Items.Add(lvi)
    End Sub

    ''' <summary>
    ''' retrieves a cached value from the entry assembly attribute lookup collection
    ''' </summary>
    Private Function EntryAssemblyAttrib(ByVal strName As String) As String
        If _mstrEntryAssemblyAttribCollection(strName) = "" Then
            Return "<Assembly: Assembly" & strName & "("""")>"
        Else
            Return _mstrEntryAssemblyAttribCollection(strName).ToString
        End If
    End Function

    ''' <summary>
    ''' Populate all the form labels with tokenized text
    ''' </summary>
    Private Sub PopulateLabels()

        Try

        '-- get entry assembly attribs
        _mstrEntryAssemblyAttribCollection = AssemblyAttribs(_mstrEntryAssembly)

        '-- replace all labels and window title
        Me.Text = ReplaceTokens(Me.Text)
        AppTitleLabel.Text = ReplaceTokens(AppTitleLabel.Text)
        If AppDescriptionLabel.Visible Then
            AppDescriptionLabel.Text = ReplaceTokens(AppDescriptionLabel.Text)
        End If
        If AppCopyrightLabel.Visible Then
            AppCopyrightLabel.Text = ReplaceTokens(AppCopyrightLabel.Text)
        End If
        If AppVersionLabel.Visible Then
            AppVersionLabel.Text = ReplaceTokens(AppVersionLabel.Text)
        End If
        If AppDateLabel.Visible Then
            AppDateLabel.Text = ReplaceTokens(AppDateLabel.Text)
        End If

        lblCompany.Text = ReplaceTokens(lblCompany.Text)

        Catch ex As Exception

        End Try

    End Sub

    ''' <summary>
    ''' perform assemblyinfo to string replacements on labels
    ''' </summary>
    Private Function ReplaceTokens(ByVal s As String) As String
        s = s.Replace("%title%", EntryAssemblyAttrib("title"))
        s = s.Replace("%copyright%", EntryAssemblyAttrib("copyright"))
        s = s.Replace("%description%", EntryAssemblyAttrib("description"))
        s = s.Replace("%company%", EntryAssemblyAttrib("company"))
        s = s.Replace("%product%", EntryAssemblyAttrib("product"))
        s = s.Replace("%trademark%", EntryAssemblyAttrib("trademark"))
        s = s.Replace("%year%", Year(EntryAssemblyAttrib("builddate")))
        s = s.Replace("%version%", ": " & EntryAssemblyAttrib("version"))
        s = s.Replace("%builddate%", ": " & CDate(EntryAssemblyAttrib("builddate")).ToString("dd-MM-yyyy hh:mm tt"))
        Return s
    End Function

    ''' <summary>
    ''' matches assembly by Assembly.GetName.Name; returns nothing if no match
    ''' </summary>
    Private Function MatchAssemblyByName(ByVal AssemblyName As String) As [Assembly]
        For Each a As [Assembly] In AppDomain.CurrentDomain.GetAssemblies
            If a.GetName.Name = AssemblyName Then
                Return a
                Exit For
            End If
        Next
    End Function

    ''' <summary>
    ''' things to do when form is loaded
    ''' </summary>
    Private Sub AboutBox_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        '-- if the user didn't provide an assembly, try to guess which one is 
        '-- the entry assembly

        'Application.DoEvents()

        SetformRegion()
        Application.DoEvents()

        If _mstrEntryAssembly Is Nothing Then
            If Not _mLocalAppCalling Then
                _mstrEntryAssembly = [Assembly].GetEntryAssembly
            Else
                _mstrEntryAssembly = [Assembly].GetExecutingAssembly
            End If
        End If
        If _mstrEntryAssembly Is Nothing Then
            If Not _mLocalAppCalling Then
                _mstrEntryAssembly = [Assembly].GetEntryAssembly
            Else
                _mstrEntryAssembly = [Assembly].GetExecutingAssembly
            End If
        End If

        _mstrExecutingAssemblyName = [Assembly].GetExecutingAssembly.GetName.Name
        _mstrCallingAssemblyName = [Assembly].GetCallingAssembly.GetName.Name
        Try
            '-- for web hosted apps, GetEntryAssembly = nothing
            _mstrEntryAssemblyName = [Assembly].GetEntryAssembly.GetName.Name
        Catch ex As Exception
        End Try

        PopulateLabels()

    End Sub

    Private Sub SetFormRegion()
        Dim DP As New Drawing2D.GraphicsPath
        DP.AddRectangle(New Rectangle(0, 0, Width, Height))
        DP.AddRectangle(New Rectangle(0, 0, 24, 16))
        DP.AddRectangle(New Rectangle(0, 59, 24, Height))
        Me.Region = New Region(DP)
        ' Application.DoEvents()

    End Sub
    ''' <summary>
    ''' things to do when form is FIRST painted
    ''' </summary>
    Private Sub AboutBox_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
        If Not _mIsPainted Then
            _mIsPainted = True
            Application.DoEvents()
            Cursor.Current = System.Windows.Forms.Cursors.WaitCursor
            PopulateLabels()
            Cursor.Current = System.Windows.Forms.Cursors.Default
        End If
    End Sub



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)


Written By
Software Developer
United Kingdom United Kingdom
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions