1
0

FrmAbout.cs 3.3 KB

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