DistexSplash.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Text;
  7. using System.Windows.Forms;
  8. using System.Reflection;
  9. namespace distribution_explorer
  10. { /// namespace distribution_explorer
  11. public partial class distexSplash : Form
  12. { /// Splash
  13. public distexSplash()
  14. {
  15. InitializeComponent();
  16. this.labelApplicationTitle.Text = AssemblyTitle;
  17. this.labelApplicationDescription.Text = AssemblyDescription;
  18. this.labelApplicationCopyright.Text = AssemblyCopyright;
  19. this.labelApplicationVersion.Text = "Version " + AssemblyVersion;
  20. }
  21. #region Assembly Attribute Accessors
  22. /// get AssemblyTitle
  23. public string AssemblyTitle
  24. {
  25. get
  26. {
  27. // Get all Title attributes on this assembly
  28. object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyTitleAttribute), false);
  29. // If there is at least one Title attribute
  30. if (attributes.Length > 0)
  31. {
  32. // Select the first one
  33. AssemblyTitleAttribute titleAttribute = (AssemblyTitleAttribute)attributes[0];
  34. // If it is not an empty string, return it
  35. if (titleAttribute.Title != "")
  36. return titleAttribute.Title;
  37. }
  38. // If there was no Title attribute, or if the Title attribute was the empty string, return the .exe name
  39. return System.IO.Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().CodeBase);
  40. }
  41. }
  42. /// get AssemblyVersion
  43. public string AssemblyVersion
  44. {
  45. get
  46. {
  47. return Assembly.GetExecutingAssembly().GetName().Version.ToString();
  48. }
  49. }
  50. //public string AssemblyGuid
  51. //{ // error CS0117: 'System.Reflection.AssemblyName' does not contain a definition for 'Guid'
  52. // get
  53. // {
  54. // return Assembly.GetExecutingAssembly().GetName().Guid.ToString();
  55. // }
  56. //}
  57. /// get AssemblyDescription
  58. public string AssemblyDescription
  59. {
  60. get
  61. {
  62. // Get all Description attributes on this assembly
  63. object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false);
  64. // If there aren't any Description attributes, return an empty string
  65. if (attributes.Length == 0)
  66. return "";
  67. // If there is a Description attribute, return its value
  68. return ((AssemblyDescriptionAttribute)attributes[0]).Description;
  69. }
  70. }
  71. /// get AssemblyProduct
  72. public string AssemblyProduct
  73. {
  74. get
  75. {
  76. // Get all Product attributes on this assembly
  77. object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyProductAttribute), false);
  78. // If there aren't any Product attributes, return an empty string
  79. if (attributes.Length == 0)
  80. return "";
  81. // If there is a Product attribute, return its value
  82. return ((AssemblyProductAttribute)attributes[0]).Product;
  83. }
  84. }
  85. /// get AssemblyCopyright
  86. public string AssemblyCopyright
  87. {
  88. get
  89. {
  90. // Get all Copyright attributes on this assembly
  91. object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false);
  92. // If there aren't any Copyright attributes, return an empty string
  93. if (attributes.Length == 0)
  94. return "";
  95. // If there is a Copyright attribute, return its value
  96. return ((AssemblyCopyrightAttribute)attributes[0]).Copyright;
  97. }
  98. }
  99. /// get AssemblyCompany
  100. public string AssemblyCompany
  101. {
  102. get
  103. {
  104. // Get all Company attributes on this assembly
  105. object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCompanyAttribute), false);
  106. // If there aren't any Company attributes, return an empty string
  107. if (attributes.Length == 0)
  108. return "";
  109. // If there is a Company attribute, return its value
  110. return ((AssemblyCompanyAttribute)attributes[0]).Company;
  111. }
  112. }
  113. #endregion
  114. private void labelApplicationVersion_Click(object sender, EventArgs e)
  115. {
  116. }
  117. }
  118. }