2 using System
.Collections
.Generic
;
3 using System
.ComponentModel
;
5 using System
.Windows
.Forms
;
6 using System
.Reflection
;
9 partial class AboutBox
: Form
{
12 InitializeComponent();
14 // Initialize the AboutBox to display the product information from the assembly information.
15 // Change assembly information settings for your application through either:
16 // - Project->Properties->Application->Assembly Information
18 this.Text
= String
.Format("About {0}", AssemblyTitle
);
19 this.labelProductName
.Text
= AssemblyProduct
;
20 this.labelVersion
.Text
= String
.Format("Version {0}", AssemblyVersion
);
21 this.labelCopyright
.Text
= AssemblyCopyright
;
22 this.labelCompanyName
.Text
= AssemblyCompany
;
23 this.textBoxDescription
.Text
= AssemblyDescription
;
26 #region Assembly Attribute Accessors
28 public string AssemblyTitle
32 // Get all Title attributes on this assembly
33 object[] attributes
= Assembly
.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyTitleAttribute
), false);
34 // If there is at least one Title attribute
35 if ( attributes
.Length
> 0 ) {
36 // Select the first one
37 AssemblyTitleAttribute titleAttribute
= (AssemblyTitleAttribute
)attributes
[0];
38 // If it is not an empty string, return it
39 if ( titleAttribute
.Title
!= "" )
40 return titleAttribute
.Title
;
42 // If there was no Title attribute, or if the Title attribute was the empty string, return the .exe name
43 return System
.IO
.Path
.GetFileNameWithoutExtension(Assembly
.GetExecutingAssembly().CodeBase
);
47 public string AssemblyVersion
51 return Assembly
.GetExecutingAssembly().GetName().Version
.ToString();
55 public string AssemblyDescription
59 // Get all Description attributes on this assembly
60 object[] attributes
= Assembly
.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyDescriptionAttribute
), false);
61 // If there aren't any Description attributes, return an empty string
62 if ( attributes
.Length
== 0 )
64 // If there is a Description attribute, return its value
65 return ((AssemblyDescriptionAttribute
)attributes
[0]).Description
;
69 public string AssemblyProduct
73 // Get all Product attributes on this assembly
74 object[] attributes
= Assembly
.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyProductAttribute
), false);
75 // If there aren't any Product attributes, return an empty string
76 if ( attributes
.Length
== 0 )
78 // If there is a Product attribute, return its value
79 return ((AssemblyProductAttribute
)attributes
[0]).Product
;
83 public string AssemblyCopyright
87 // Get all Copyright attributes on this assembly
88 object[] attributes
= Assembly
.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCopyrightAttribute
), false);
89 // If there aren't any Copyright attributes, return an empty string
90 if ( attributes
.Length
== 0 )
92 // If there is a Copyright attribute, return its value
93 return ((AssemblyCopyrightAttribute
)attributes
[0]).Copyright
;
97 public string AssemblyCompany
101 // Get all Company attributes on this assembly
102 object[] attributes
= Assembly
.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCompanyAttribute
), false);
103 // If there aren't any Company attributes, return an empty string
104 if ( attributes
.Length
== 0 )
106 // If there is a Company attribute, return its value
107 return ((AssemblyCompanyAttribute
)attributes
[0]).Company
;