-
Notifications
You must be signed in to change notification settings - Fork 130
/
About.cs
126 lines (114 loc) · 4.38 KB
/
About.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
//======================================================================
//Copyright (C) 2009 ARTM
//All rights reserved
//Filename :About
//Created by Miao at 01/12/2009 15:20:10
//Description :关于
//======================================================================
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Reflection;
namespace H31DHTMgr
{
public partial class About : Form
{
public About()
{
InitializeComponent();
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;
}
#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.DialogResult = DialogResult.OK;
}
}
}