AboutDistributionExplorer.cs 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Drawing;
  5. using System.Windows.Forms;
  6. using System.Reflection;
  7. namespace distribution_explorer
  8. {
  9. partial class AboutDistributionExplorer : Form
  10. {
  11. public AboutDistributionExplorer()
  12. {
  13. 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
  17. // - AssemblyInfo.cs
  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;
  24. }
  25. #region Assembly Attribute Accessors
  26. public string AssemblyTitle
  27. {
  28. get
  29. {
  30. // Get all Title attributes on this assembly
  31. object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyTitleAttribute), false);
  32. // If there is at least one Title attribute
  33. if (attributes.Length > 0)
  34. {
  35. // Select the first one
  36. AssemblyTitleAttribute titleAttribute = (AssemblyTitleAttribute)attributes[0];
  37. // If it is not an empty string, return it
  38. if (titleAttribute.Title != "")
  39. return titleAttribute.Title;
  40. }
  41. // If there was no Title attribute, or if the Title attribute was the empty string, return the .exe name
  42. return System.IO.Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().CodeBase);
  43. }
  44. }
  45. public string AssemblyVersion
  46. {
  47. get
  48. {
  49. return Assembly.GetExecutingAssembly().GetName().Version.ToString();
  50. }
  51. }
  52. public string AssemblyDescription
  53. {
  54. get
  55. {
  56. // Get all Description attributes on this assembly
  57. object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false);
  58. // If there aren't any Description attributes, return an empty string
  59. if (attributes.Length == 0)
  60. return "";
  61. // If there is a Description attribute, return its value
  62. return ((AssemblyDescriptionAttribute)attributes[0]).Description;
  63. }
  64. }
  65. public string AssemblyProduct
  66. {
  67. get
  68. {
  69. // Get all Product attributes on this assembly
  70. object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyProductAttribute), false);
  71. // If there aren't any Product attributes, return an empty string
  72. if (attributes.Length == 0)
  73. return "";
  74. // If there is a Product attribute, return its value
  75. return ((AssemblyProductAttribute)attributes[0]).Product;
  76. }
  77. }
  78. public string AssemblyCopyright
  79. {
  80. get
  81. {
  82. // Get all Copyright attributes on this assembly
  83. object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false);
  84. // If there aren't any Copyright attributes, return an empty string
  85. if (attributes.Length == 0)
  86. return "";
  87. // If there is a Copyright attribute, return its value
  88. return ((AssemblyCopyrightAttribute)attributes[0]).Copyright;
  89. }
  90. }
  91. public string AssemblyCompany
  92. {
  93. get
  94. {
  95. // Get all Company attributes on this assembly
  96. object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCompanyAttribute), false);
  97. // If there aren't any Company attributes, return an empty string
  98. if (attributes.Length == 0)
  99. return "";
  100. // If there is a Company attribute, return its value
  101. return ((AssemblyCompanyAttribute)attributes[0]).Company;
  102. }
  103. }
  104. #endregion
  105. }
  106. }