AboutForm.cs 3.3 KB

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