FrmAboutAny.cs
6.42 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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Management;
using GeneralLib;
using System.Reflection;
using System.IO;
namespace SunVoteARSPPT
{
public partial class FrmAboutAny : Form
{
public FrmAboutAny()
{
InitializeComponent();
string bitInfo = "_32bit";//默认32位
string proInfo = Assembly.GetExecutingAssembly().GetName().ProcessorArchitecture.ToString();
if (proInfo.IndexOf("64") >= 0)
{
bitInfo = "_64bit";
}
else if (proInfo == "MSIL")
{
if (GetOSBit() == 64)
{
bool retVal = false;
IsWow64Process(Process.GetCurrentProcess().Handle, out retVal);
if (!retVal)
bitInfo = "_64bit";
}
}
//加载OEM信息
AppInfo info = new AppInfo();
if (!Directory.Exists(GlobalInfo.OEMInfoDir))
Directory.CreateDirectory(GlobalInfo.OEMInfoDir);
string path = GlobalInfo.OEMInfoFile;
if (File.Exists(path))
{
info = MyXmlSerializer.DisSerializerFromFile<AppInfo>(path);
}
//自动创建
if (info == null)
{
info = new AppInfo();
}
if ((info.ListInfoItem == null) || (info.ListInfoItem.Count < 1))
{
info.ListInfoItem = new List<InfoItem>();
info.ListInfoItem.Add(new InfoItem() { Name = "Support Tel:", Value = "+86-18908457700" });
info.ListInfoItem.Add(new InfoItem() { Name = "Website:", Value = "http://www.psunsky.com.cn/", Type = 1 });
info.ListInfoItem.Add(new InfoItem() { Name = "Mailbox:", Value = "support@sunvote.com.cn", Type = 2 });
}
MyXmlSerializer.SerializerToFile(info, path);
//加载Logo图标
string pathLogo = GlobalInfo.OEMInfoDir + info.AppLogo;
if (File.Exists(pathLogo))
picLogo.Image = Image.FromFile(pathLogo);
//显示App Name软件名称
lblSysSoftName.Text = info.AppName;
//版本信息+自定义行数
pnlParam.RowCount = 1 + info.ListInfoItem.Count;
pnlParam.Height = pnlParam.RowCount * 25;
this.Height = pnlParam.Bottom + 60;
for (int i = 0; i < pnlParam.RowStyles.Count; i++)
pnlParam.RowStyles[i] = new RowStyle(SizeType.Percent, 100);
for (int i = pnlParam.RowStyles.Count; i < pnlParam.RowCount; i++)
pnlParam.RowStyles.Add(new RowStyle(SizeType.Percent, 100));
//版本信息
lblVer.Text = "Version:";
////bitInfo += GlobalInfo.VerInfo;//Alpha/Beta
lblVerNoInfo.Text = "V " + Assembly.GetExecutingAssembly().GetName().Version.ToString() + bitInfo;
//其他信息
for (int i = 0; i < info.ListInfoItem.Count; i++)
{
int row = i + 1;
Label lab = new Label();
pnlParam.Controls.Add(lab, 0, row);
lab.Margin = new Padding(3, 3, 3, 3);
lab.AutoSize = true;
lab.Dock = DockStyle.Fill;
lab.TextAlign = ContentAlignment.MiddleRight;
lab.Text = info.ListInfoItem[i].Name;//属性名称
lab.Visible = true;
Label lab2 = new Label();
pnlParam.Controls.Add(lab2, 1, row);
lab2.Margin = new Padding(3, 3, 3, 3);
lab2.AutoSize = true;
lab2.Dock = DockStyle.Fill;
lab2.TextAlign = ContentAlignment.MiddleLeft;
lab2.Text = info.ListInfoItem[i].Value;//属性内容
lab2.Tag = info.ListInfoItem[i].Type;//属性类型
if (info.ListInfoItem[i].Type > 0)
lab2.ForeColor = Color.Blue;
lab2.Visible = true;
lab2.Click += Lab2_Click;
}
}
private void FrmAboutAny_Load(object sender, EventArgs e)
{
}
private void Lab2_Click(object sender, EventArgs e)
{
Label lab = sender as Label;
int proType = ConvertOper.Convert(lab.Tag + "").ToInt;
if (proType > 0)
OpenLink(lab.Text, proType == 2);
}
public static int GetOSBit()
{
try
{
//杨斌 2015-03-17
int bit = 32;
if (Environment.Is64BitOperatingSystem)
bit = 64;
return bit;
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
return 32;
}
}
[DllImport("kernel32.dll")]
public static extern bool IsWow64Process([In] IntPtr hProcess, [Out] out bool lpSystemInfo);
private void FrmAboutUs_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Escape)//杨斌 2012-03-13
this.Close();
}
void OpenLink(string link, bool isMail = false)
{
if (isMail)
Process.Start("mailto:" + link);
else
Process.Start(link);
}
}
public class AppInfo
{
public string AppName = "ARS PPT";
public string AppLogo = "Logo.png";
public List<InfoItem> ListInfoItem = new List<InfoItem>();
}
/// <summary>
/// OEM信息,包括:编译工程名称(System.ini的SoftInfo),关于xml指定,关于Logo图片xml指定
/// 帮助关联文件夹
/// ARS和ToolKit名称,ARS和ToolKit快捷方式图标,默认中性图标
/// 特殊定制键盘型号名称和图片
/// </summary>
public class InfoItem
{
/// <summary>
/// 类型:0=普通文本,1=链接,2=邮箱
/// </summary>
public int Type = 0;
/// <summary>
/// 属性名称
/// </summary>
public string Name = "";
/// <summary>
/// 属性值
/// </summary>
public string Value = "";
}
}