forked from hackerzhou/GPATool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
UserConfigView.cs
176 lines (159 loc) · 5.79 KB
/
UserConfigView.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
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
using System;
using System.Collections.Generic;
using System.Threading;
using System.Windows.Forms;
using System.ComponentModel;
using DevComponents.DotNetBar;
using GPATool.Util;
namespace GPATool
{
public partial class UserConfigView : UserControl
{
private Thread fetchRSSThread = null;
private int savedStyleIndex;
public UserConfigView()
{
InitializeComponent();
}
public void StopAllThreads()
{
try
{
if (fetchRSSThread != null && fetchRSSThread.ThreadState != ThreadState.Stopped)
{
fetchRSSThread.Interrupt();
}
}
catch
{
}
}
private void UserConfigView_Load(object sender, EventArgs e)
{
XMLConfig.LoadConfig();
panel2.DataBindings.Add("Enabled", checkBox3, "Checked");
panel3.DataBindings.Add("Enabled", checkBox4, "Checked");
checkBox3.Checked = XMLConfig.useProxy;
checkBox4.Checked = XMLConfig.proxyUseAuth;
textBox3.Text = XMLConfig.proxyHost;
textBox4.Text = XMLConfig.proxyPort.ToString();
textBox6.Text = XMLConfig.proxyUsername;
textBox5.Text = XMLConfig.proxyPassword;
savedStyleIndex = comboBox2.SelectedIndex = XMLConfig.styleIndex;
fetchRSSThread = new Thread(new ThreadStart(updateRSSHandler));
fetchRSSThread.Start();
}
private delegate void UpdateRSSListViewDelegate(List<RSSSpider.RSSItem> list);
private void updateRSSListView(List<RSSSpider.RSSItem> list)
{
if (this.InvokeRequired)
{
UpdateRSSListViewDelegate cb = new UpdateRSSListViewDelegate(updateRSSListView);
this.Invoke(cb, list);
}
else
{
listView2.Items.Clear();
foreach (RSSSpider.RSSItem i in list)
{
ListViewItem listItem = new ListViewItem(new String[] { i.Name, i.UpdateDate });
listItem.Tag = i.Url;
listView2.Items.Add(listItem);
}
}
}
private void updateRSSHandler()
{
List<RSSSpider.RSSItem> list = RSSSpider.RSSUtil.GetRSSItemList("http://hackerzhou.me/feed");
updateRSSListView(list);
}
private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
{
if (savedStyleIndex != comboBox2.SelectedIndex)
{
button7_Click(sender, null);
}
}
private void button8_Click(object sender, EventArgs e)
{
XMLConfig.useProxy = checkBox3.Checked;
XMLConfig.proxyUseAuth = checkBox4.Checked;
XMLConfig.proxyHost = textBox3.Text;
int port = 8080;
int.TryParse(textBox4.Text, out port);
XMLConfig.proxyPort = port;
XMLConfig.proxyUsername = textBox6.Text;
XMLConfig.proxyPassword = textBox5.Text;
XMLConfig.WriteConfig();
}
private void button7_Click(object sender, EventArgs e)
{
String style = comboBox2.SelectedItem.ToString();
Form1 f = Form1.getInstance();
if (f == null)
{
return;
}
if ("Office2007Black".Equals(style))
{
f.ChangeStyle(eStyle.Office2007Black);
}
else if ("Office2007Blue".Equals(style))
{
f.ChangeStyle(eStyle.Office2007Blue);
}
else if ("Office2007Silver".Equals(style))
{
f.ChangeStyle(eStyle.Office2007Silver);
}
else if ("Office2007VistaGlass".Equals(style))
{
f.ChangeStyle(eStyle.Office2007VistaGlass);
}
else if ("Office2010Silver".Equals(style))
{
f.ChangeStyle(eStyle.Office2010Silver);
}
else if ("Windows7Blue".Equals(style))
{
f.ChangeStyle(eStyle.Windows7Blue);
}
if (e != null)
{
XMLConfig.styleIndex = comboBox2.SelectedIndex;
XMLConfig.WriteConfig();
}
}
private void linkLabel4_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
System.Diagnostics.Process.Start("http://bbs.fudan.sh.cn/bbs/qry?u=hackerzhou");
}
private void linkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
System.Diagnostics.Process.Start("http://hackerzhou.me");
}
private void linkLabel5_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
System.Diagnostics.Process.Start("http://code.google.com/p/hackerzhou/");
}
private void linkLabel3_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
System.Diagnostics.Process.Start("http://twitter.com/hackerzhou");
}
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
System.Diagnostics.Process.Start("mailto:[email protected]");
}
private void linkLabel6_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
System.Diagnostics.Process.Start("http://weibo.com/hackerzhou");
}
private void listView2_SelectedIndexChanged(object sender, EventArgs e)
{
if (listView2.SelectedItems.Count > 0)
{
System.Diagnostics.Process.Start(listView2.SelectedItems[0].Tag.ToString());
}
}
}
}