using System;
using System.Drawing;
using System.Reflection;
using System.Windows.Forms;
namespace GoContactSyncMod
{
internal partial class AboutBox : Form
{
public AboutBox()
{
/* Cannot set Font in designer as there is automatic sorting and Font will be set after AutoScaleDimensions
* This will prevent application to work correctly with high DPI systems. */
Font = new Font("Verdana", 8.25F, FontStyle.Regular, GraphicsUnit.Point, 0);
InitializeComponent();
Text = $"About {AssemblyTitle}";
labelProductName.Text = AssemblyProduct;
labelVersion.Text = $"Version {AssemblyVersion}";
labelCopyright.Text = AssemblyCopyright;
labelCompanyName.Text = AssemblyCompany;
textBoxDescription.Text = AssemblyDescription;
}
#region Assembly Attribute Accessors
public static string AssemblyTitle
{
get
{
var attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyTitleAttribute), false);
if (attributes.Length > 0)
{
var titleAttribute = (AssemblyTitleAttribute)attributes[0];
if (!string.IsNullOrEmpty(titleAttribute.Title))
{
return titleAttribute.Title;
}
}
return System.IO.Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().CodeBase);
}
}
public static string AssemblyVersion => Assembly.GetExecutingAssembly().GetName().Version.ToString();
public static string AssemblyDescription
{
get
{
var attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false);
return attributes.Length == 0 ? "" : ((AssemblyDescriptionAttribute)attributes[0]).Description;
}
}
public static string AssemblyProduct
{
get
{
var attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyProductAttribute), false);
return attributes.Length == 0 ? "" : ((AssemblyProductAttribute)attributes[0]).Product;
}
}
public static string AssemblyCopyright
{
get
{
var attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false);
return attributes.Length == 0 ? "" : ((AssemblyCopyrightAttribute)attributes[0]).Copyright;
}
}
public static string AssemblyCompany
{
get
{
var attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCompanyAttribute), false);
return attributes.Length == 0 ? "" : ((AssemblyCompanyAttribute)attributes[0]).Company;
}
}
#endregion
private void OkButton_Click(object sender, EventArgs e)
{
Close();
}
}
}