distexAboutBox.cs 4.6 KB

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