AboutBox1.cs 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. using System.Reflection;
  2. namespace EdgeVoyager
  3. {
  4. partial class AboutBox1 : Form
  5. {
  6. public AboutBox1()
  7. {
  8. InitializeComponent();
  9. this.Text = String.Format("关于 {0}", AssemblyTitle);
  10. this.labelProductName.Text = AssemblyProduct;
  11. this.labelVersion.Text = String.Format("版本 {0}", AssemblyVersion);
  12. this.labelCopyright.Text = AssemblyCopyright;
  13. this.labelCompanyName.Text = AssemblyCompany;
  14. this.textBoxDescription.Text = AssemblyDescription;
  15. }
  16. #region 程序集特性访问器
  17. public string AssemblyTitle
  18. {
  19. get
  20. {
  21. object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyTitleAttribute), false);
  22. if (attributes.Length > 0)
  23. {
  24. AssemblyTitleAttribute titleAttribute = (AssemblyTitleAttribute)attributes[0];
  25. if (titleAttribute.Title != "")
  26. {
  27. return titleAttribute.Title;
  28. }
  29. }
  30. return System.IO.Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().CodeBase);
  31. }
  32. }
  33. public string AssemblyVersion
  34. {
  35. get
  36. {
  37. return Assembly.GetExecutingAssembly().GetName().Version.ToString();
  38. }
  39. }
  40. public string AssemblyDescription
  41. {
  42. get
  43. {
  44. object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false);
  45. if (attributes.Length == 0)
  46. {
  47. return "";
  48. }
  49. return ((AssemblyDescriptionAttribute)attributes[0]).Description;
  50. }
  51. }
  52. public string AssemblyProduct
  53. {
  54. get
  55. {
  56. object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyProductAttribute), false);
  57. if (attributes.Length == 0)
  58. {
  59. return "";
  60. }
  61. return ((AssemblyProductAttribute)attributes[0]).Product;
  62. }
  63. }
  64. public string AssemblyCopyright
  65. {
  66. get
  67. {
  68. object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false);
  69. if (attributes.Length == 0)
  70. {
  71. return "";
  72. }
  73. return ((AssemblyCopyrightAttribute)attributes[0]).Copyright;
  74. }
  75. }
  76. public string AssemblyCompany
  77. {
  78. get
  79. {
  80. object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCompanyAttribute), false);
  81. if (attributes.Length == 0)
  82. {
  83. return "";
  84. }
  85. return ((AssemblyCompanyAttribute)attributes[0]).Company;
  86. }
  87. }
  88. #endregion
  89. }
  90. }