?? aboutbox1.cs
字號:
?using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using System.Reflection;
namespace Notepad
{
partial class AboutBox1 : Form
{
public AboutBox1()
{
InitializeComponent();
// 初始化 AboutBox 以顯示程序集信息中包含的產品信息。
// 也可以通過以下方法更改應用程序的程序集信息設置:
// - 項目->屬性->應用程序->程序集信息
// - AssemblyInfo.cs
this.Text = String.Format("關于 {0}", AssemblyTitle);
this.labelProductName.Text = AssemblyProduct;
this.labelVersion.Text = String.Format("版本 {0}", AssemblyVersion);
this.labelCopyright.Text = AssemblyCopyright;
this.labelCompanyName.Text = AssemblyCompany;
this.textBoxDescription.Text = AssemblyDescription;
}
#region 程序集屬性訪問器
public string AssemblyTitle
{
get
{
// 獲取此程序集上的所有 Title 屬性
object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyTitleAttribute), false);
// 如果至少有一個 Title 屬性
if (attributes.Length > 0)
{
// 請選擇第一個屬性
AssemblyTitleAttribute titleAttribute = (AssemblyTitleAttribute)attributes[0];
// 如果該屬性為非空字符串,則將其返回
if (titleAttribute.Title != "")
return titleAttribute.Title;
}
// 如果沒有 Title 屬性,或者 Title 屬性為一個空字符串,則返回 .exe 的名稱
return System.IO.Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().CodeBase);
}
}
public string AssemblyVersion
{
get
{
return Assembly.GetExecutingAssembly().GetName().Version.ToString();
}
}
public string AssemblyDescription
{
get
{
// 獲取此程序集的所有 Description 屬性
object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false);
// 如果 Description 屬性不存在,則返回一個空字符串
if (attributes.Length == 0)
return "";
// 如果有 Description 屬性,則返回該屬性的值
return ((AssemblyDescriptionAttribute)attributes[0]).Description;
}
}
public string AssemblyProduct
{
get
{
// 獲取此程序集上的所有 Product 屬性
object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyProductAttribute), false);
// 如果 Product 屬性不存在,則返回一個空字符串
if (attributes.Length == 0)
return "";
// 如果有 Product 屬性,則返回該屬性的值
return ((AssemblyProductAttribute)attributes[0]).Product;
}
}
public string AssemblyCopyright
{
get
{
// 獲取此程序集上的所有 Copyright 屬性
object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false);
// 如果 Copyright 屬性不存在,則返回一個空字符串
if (attributes.Length == 0)
return "";
// 如果有 Copyright 屬性,則返回該屬性的值
return ((AssemblyCopyrightAttribute)attributes[0]).Copyright;
}
}
public string AssemblyCompany
{
get
{
// 獲取此程序集上的所有 Company 屬性
object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCompanyAttribute), false);
// 如果 Company 屬性不存在,則返回一個空字符串
if (attributes.Length == 0)
return "";
// 如果有 Company 屬性,則返回該屬性的值
return ((AssemblyCompanyAttribute)attributes[0]).Company;
}
}
#endregion
private void okButton_Click(object sender, EventArgs e)
{
this.Close();
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -