-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfrmAbout.cs
More file actions
199 lines (180 loc) · 8.52 KB
/
frmAbout.cs
File metadata and controls
199 lines (180 loc) · 8.52 KB
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace NotepadSharp
{
partial class frmAbout : Form
{
[DllImport("user32")]
private static extern bool AnimateWindow(IntPtr hwnd, int dwTime, int dwFlags);
//* 函数功能:该函数能在显示与隐藏窗口时能产生特殊的效果。有两种类型的动画效果:滚动动画和滑动动画。
//* 函数原型:BOOL AnimateWindow(HWND hWnd,DWORD dwTime,DWORD dwFlags);
//* hWnd:指定产生动画的窗口的句柄。
//* dwTime:指明动画持续的时间(以微秒计),完成一个动画的标准时间为200微秒。
//* dwFags:指定动画类型。这个参数可以是一个或多个下列标志的组合。
//* 返回值:如果函数成功,返回值为非零;如果函数失败,返回值为零。
//* 在下列情况下函数将失败:窗口使用了窗口边界;窗口已经可见仍要显示窗口;窗口已经隐藏仍要隐藏窗口。若想获得更多错误信息,请调用GetLastError函数。
//* 备注:可以将AW_HOR_POSITIVE或AW_HOR_NEGTVE与AW_VER_POSITVE或AW_VER_NEGATIVE组合来激活一个窗口。
//* 可能需要在该窗口的窗口过程和它的子窗口的窗口过程中处理WM_PRINT或WM_PRINTCLIENT消息。对话框,控制,及共用控制已处理WM_PRINTCLIENT消息,缺省窗口过程也已处理WM_PRINT消息。
//* 速查:WIDdOWS NT:5.0以上版本:Windows:98以上版本;Windows CE:不支持;头文件:Winuser.h;库文件:user32.lib。
////标志描述:
const int AW_SLIDE = 0x40000; //使用滑动类型。缺省则为滚动动画类型。当使用AW_CENTER标志时,这个标志就被忽略。
const int AW_ACTIVATE = 0x20000; //激活窗口。在使用了AW_HIDE标志后不要使用这个标志。
const int AW_BLEND = 0x80000; //使用淡出效果。只有当hWnd为顶层窗口的时候才可以使用此标志。
const int AW_HIDE = 0x10000; //隐藏窗口,缺省则显示窗口。(关闭窗口用)
const int AW_CENTER = 0x0010; //若使用了AW_HIDE标志,则使窗口向内重叠;若未使用AW_ACTIVATE标志,则使窗口向外扩展。
const int AW_HOR_POSITIVE = 0x0001; //自左向右显示窗口。该标志可以在滚动动画和滑动动画中使用。当使用AW_CENTER标志时,该标志将被忽略。
const int AW_VER_POSITIVE = 0x0004; //自顶向下显示窗口。该标志可以在滚动动画和滑动动画中使用。当使用AW_CENTER标志时,该标志将被忽略。
const int AW_HOR_NEGATIVE = 0x0002; //自右向左显示窗口。该标志可以在滚动动画和滑动动画中使用。当使用AW_CENTER标志时,该标志将被忽略。
const int AW_VER_NEGATIVE = 0x0008; //自下向上显示窗口。该标志可以在滚动动画和滑动动画中使用。当使用AW_CENTER标志时,该标志将被忽略。
private const int CS_DropSHADOW = 0x20000;
private const int GCL_STYLE = (-26);
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern int SetClassLong(IntPtr hwnd, int nIndex, int dwNewLong);
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern int GetClassLong(IntPtr hwnd, int nIndex);
public frmAbout()
{
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;
this.textBoxDescription.Text = AssemblyDescription;
}
#region 程序集特性访问器
public string AssemblyTitle
{
get
{
object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyTitleAttribute), false);
if (attributes.Length > 0)
{
AssemblyTitleAttribute titleAttribute = (AssemblyTitleAttribute)attributes[0];
if (titleAttribute.Title != "")
{
return titleAttribute.Title;
}
}
return System.IO.Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().CodeBase);
}
}
public string AssemblyVersion
{
get
{
return Assembly.GetExecutingAssembly().GetName().Version.ToString();
}
}
public string AssemblyDescription
{
get
{
object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false);
if (attributes.Length == 0)
{
return "";
}
return ((AssemblyDescriptionAttribute)attributes[0]).Description;
}
}
public string AssemblyProduct
{
get
{
object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyProductAttribute), false);
if (attributes.Length == 0)
{
return "";
}
return ((AssemblyProductAttribute)attributes[0]).Product;
}
}
public string AssemblyCopyright
{
get
{
object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false);
if (attributes.Length == 0)
{
return "";
}
return ((AssemblyCopyrightAttribute)attributes[0]).Copyright;
}
}
public string AssemblyCompany
{
get
{
object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCompanyAttribute), false);
if (attributes.Length == 0)
{
return "";
}
return ((AssemblyCompanyAttribute)attributes[0]).Company;
}
}
#endregion
private void frmAbout_Load(object sender, EventArgs e)
{
this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer, true);
SetClassLong(this.Handle, GCL_STYLE, GetClassLong(this.Handle, GCL_STYLE) | CS_DropSHADOW);
AnimateWindow(this.Handle, 500,AW_ACTIVATE | AW_CENTER);
}
private Point _oldLocation;
private Point _startPoint;
private bool _IsMouseDown;
/// <summary>
///
/// </summary>
/// <param name="e"></param>
protected override void OnMouseDown(MouseEventArgs e)
{
base.OnMouseDown(e);
_IsMouseDown = true;
_startPoint = Control.MousePosition;
_oldLocation = this.Location;
}
/// <summary>
///
/// </summary>
/// <param name="e"></param>
protected override void OnMouseMove(MouseEventArgs e)
{
base.OnMouseMove(e);
if (!_IsMouseDown) return;
Point p = Control.MousePosition;
this.Location = new Point(p.X - _startPoint.X + _oldLocation.X, p.Y - _startPoint.Y + _oldLocation.Y);
}
/// <summary>
///
/// </summary>
/// <param name="e"></param>
protected override void OnMouseUp(MouseEventArgs e)
{
base.OnMouseUp(e);
_IsMouseDown = false;
}
private void frmAbout_FormClosing(object sender, FormClosingEventArgs e)
{
AnimateWindow(this.Handle, 500, AW_HIDE | AW_CENTER);
}
private void okButton_Click(object sender, EventArgs e)
{
this.Close();
}
private void lnkToGithub_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
Process.Start("https://github.com/XHSofts/NotepadSharp");
}
}
}