1 using System; 2 using System.ComponentModel; 3 using System.Drawing; 4 using System.Text; 5 using System.Windows.Forms; 6 using System.Reflection; // to get attributes from AssemblyInfo 7 8 namespace standardApplications 9 { 10 11 public partial class AboutForm : System.Windows.Forms.Form 12 { 13 14 public AboutForm() 15 { 16 InitializeComponent(); 17 } 18 19 20 private void AboutForm_Load(object sender, System.EventArgs e) 21 { 22 try 23 { 24 this.Icon = new Icon(this.GetType(), "application.ico"); 25 26 this.CenterToParent(); 27 28 this.Text = "About " + Application.ProductName + 29 " " + Program.VersionShort; 30 31 this.pictureBox1.Image = this.Icon.ToBitmap(); 32 33 this.BackColor = Program.Form1Backcolor; 34 35 this.label1.Text = Description() + 36 "\n\r\n\r" + "Version " + Application.ProductVersion + 37 "\n\r\n\r" + Company() + 38 "\n\r\n\r" + Copyright(); 39 40 } 41 catch (Exception ex) 42 { 43 ex.ToString(); // do nothing 44 } 45 46 } 47 48 49 50 private void buttonClose_Click(object sender, System.EventArgs e) 51 { 52 try 53 { 54 this.Close(); 55 } 56 catch (Exception ex) 57 { 58 throw new Exception(ex.Message); 59 } 60 } 61 62 63 64 // uses reflection to obtain the Description attribute from AssemblyInfo.cs 65 private string Description() 66 { 67 string stringMe = "AboutForm.Description: "; 68 try 69 { 70 AssemblyDescriptionAttribute myAttr = (AssemblyDescriptionAttribute) 71 AssemblyDescriptionAttribute.GetCustomAttribute 72 ( 73 System.Reflection.Assembly.GetExecutingAssembly(), 74 typeof(AssemblyDescriptionAttribute) 75 ); 76 return myAttr.Description; 77 } 78 catch (Exception ex) 79 { 80 throw new Exception(stringMe + ex.Message); 81 } 82 } 83 84 85 // uses reflection to obtain the Company attribute from AssemblyInfo.cs 86 private string Company() 87 { 88 string stringMe = "AboutForm.Company: "; 89 try 90 { 91 AssemblyCompanyAttribute myAttr = (AssemblyCompanyAttribute) 92 AssemblyCompanyAttribute.GetCustomAttribute 93 ( 94 System.Reflection.Assembly.GetExecutingAssembly(), 95 typeof(AssemblyCompanyAttribute) 96 ); 97 return myAttr.Company; 98 } 99 catch (Exception ex) 100 { 101 throw new Exception(stringMe + ex.Message); 102 } 103 } 104 105 106 // uses reflection to obtain the Copyright attribute from AssemblyInfo.cs 107 private string Copyright() 108 { 109 string stringMe = "AboutForm.Copyright: "; 110 try 111 { 112 AssemblyCopyrightAttribute myAttr = (AssemblyCopyrightAttribute) 113 AssemblyCopyrightAttribute.GetCustomAttribute 114 ( 115 System.Reflection.Assembly.GetExecutingAssembly(), 116 typeof(AssemblyCopyrightAttribute) 117 ); 118 return myAttr.Copyright; 119 } 120 catch (Exception ex) 121 { 122 throw new Exception(stringMe + ex.Message); 123 } 124 } 125 126 127 128 } // end class 129 } // end namespace