[C#] 纯文本查看 复制代码
using Model;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Net;
using System.Text;
using System.Threading;
using System.Windows.Forms;
namespace QQHack
{
public partial class FrmMain : Form
{
public FrmMain() {
InitializeComponent();
}
/// <summary>
/// 图片
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnQx_Click(object sender, EventArgs e) {
try {
if (string.IsNullOrEmpty(txtQQ.Text)) {
MessageBox.Show("QQ号不可为空!");
return;
}
Button btn = (Button)sender;
imgShow.Load(string.Format(btn.Tag.ToString(), txtQQ.Text));
imgShow.SizeMode = PictureBoxSizeMode.CenterImage;
} catch (Exception ex) {
MessageBox.Show("QQ号格式错误或不存在!" + ex.Message);
}
}
/// <summary>
/// 页面
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnWeb_Click(object sender, EventArgs e) {
try {
if (string.IsNullOrEmpty(txtQQ.Text)) {
MessageBox.Show("QQ号不可为空!");
return;
}
Button btn = (Button)sender;
webShow.Navigate(string.Format(btn.Tag.ToString(), txtQQ.Text));
} catch (Exception ex) {
MessageBox.Show("QQ号格式错误或不存在!" + ex.Message);
}
}
/// <summary>
/// 获取头像
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button3_Click(object sender, EventArgs e) {
try {
if (string.IsNullOrEmpty(txtQQ.Text)) {
MessageBox.Show("QQ号不可为空!");
return;
}
Button btn = btnTx;
imgShow.Load(string.Format(btn.Tag.ToString(), txtQQ.Text, 640));
if (imgShow.Image.Size.Width <= 40) {
imgShow.Load(string.Format(btn.Tag.ToString(), txtQQ.Text, 240));
if (imgShow.Image.Size.Width <= 40) {
imgShow.Load(string.Format(btn.Tag.ToString(), txtQQ.Text, 100));
}
}
imgShow.SizeMode = PictureBoxSizeMode.Zoom;
} catch (Exception ex) {
MessageBox.Show("QQ号格式错误或不存在!" + ex.Message);
}
}
/// <summary>
/// 点击强制聊天
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void imgQQ_Click(object sender, EventArgs e) {
try {
if (!string.IsNullOrEmpty(txtQQ.Text)) {
Process.Start(string.Format(imgQQ.Tag.ToString(), txtQQ.Text));
}
} catch (Exception ex) {
MessageBox.Show("QQ号格式错误或不存在!" + ex.Message);
}
}
private void txtQQ_TextChanged(object sender, EventArgs e) {
try {
if (txtQQ.Text.Length >= 5) {
imgQQ.Load(string.Format(txtQQ.Tag.ToString(), txtQQ.Text));
btnTx.PerformClick();
}
} catch { }
}
private System.Net.WebClient webClient = null;
/// <summary>
/// 检测已登录QQ
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void FrmMain_Load(object sender, EventArgs e) {
ServicePointManager.DefaultConnectionLimit = 512;
webClient = new System.Net.WebClient();
QClientHelper.QClientKey[] qqs = QClientHelper.GetQClientKey();
if (qqs != null) {
Text = "获取QQ信息 - 当前操作用户:" + qqs[0].UName + " (" + qqs[0].UId + ")";
txtQQ.Text = qqs[0].UId;
} else {
webShow.Navigate(webShow.Tag.ToString());
}
//FrmZx frm = new FrmZx();
//frm.Show(this);
}
private void webShow_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) {
//登录Qzone
HtmlElement btnLogin = webShow.Document.GetElementById("loginbtn");
if (btnLogin != null) {
btnLogin.InvokeMember("click");
}
}
private void webShow_Navigated(object sender, WebBrowserNavigatedEventArgs e) {
if (webShow.Url == new Uri("http://ctc.qzs.qq.com/ac/qzone/login/succ.html")) {
webShow.DocumentText = "初始化成功,现可使用所有功能!";
button10.Visible = false;
}
}
/// <summary>
/// 最近访问记录
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button8_Click(object sender, EventArgs e) {
try {
if (string.IsNullOrEmpty(txtQQ.Text)) {
MessageBox.Show("QQ号不可为空!");
return;
}
Button btn = (Button)sender;
webClient.Encoding = Encoding.GetEncoding("utf-8");//设置编码
string html = webClient.DownloadString(string.Format(btn.Tag.ToString(), txtQQ.Text));
if (!string.IsNullOrEmpty(html)) {
//取数据
html = html.Replace("_Callback(", "").Replace(");", "");
Rootobject rt = (Rootobject)JavaScriptConvert.DeserializeObject(html, typeof(Rootobject));
string st = "";
st += "<b style='color: red;'>空间最近访问人数:" + rt.data.count + "</b><br /><hr />";
foreach (QQList item in rt.data.list) {
st += string.Format("<span style='color: blue;'>名称:{0}<br />", item.nick);
st += string.Format("QQ:{0}<br /></span>", item.uin);
DateTime ntime = GetNoralTime(item.time);
string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
string sday = Day[Convert.ToInt16(ntime.DayOfWeek)];
string ddstr = " ";
ddstr += (ntime.Day == DateTime.Now.Day && ntime.Month == DateTime.Now.Month) ? "今天" : "昨天";
st += string.Format("访问时间:{0}<br /></span>", ntime + " " + sday + ddstr);
st += string.Format("是否在线:<img alt=\"亮的QQ图标表示在线,灰色的表示不在线或者隐身状态\" title=\"亮的QQ图标表示在线,灰色的表示不在线或者隐身状态\" src='http://wpa.qq.com/pa?p=1:{0}:4'/><br />", item.uin);
st += string.Format("强制聊天:<a href='http://wpa.qq.com/msgrd?v=3&site=qq&menu=yes&uin={0}' target=\"_blank\">点击强制聊天</a><br />", item.uin);
st += string.Format("空间头像:<br/><img src='{0}' /><br />", item.face_url);
st += string.Format("QQ头像:<br/><img src='http://q.qlogo.cn/headimg_dl?bs=qq&dst_uin={0}&spec=100' /><br /><hr />", item.uin);
}
webShow.DocumentText = st;
}
} catch (Exception ex) {
MessageBox.Show("QQ号格式错误或不存在!" + ex.Message);
}
}
/// <summary>
/// 转换Unix时间戳
/// </summary>
/// <param name="now">Unix时间戳</param>
/// <returns>DateTime</returns>
private DateTime GetNoralTime(int now) {
int timeStamp = now;
DateTime dtStart = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1));
long lTime = long.Parse(timeStamp + "0000000");
TimeSpan toNow = new TimeSpan(lTime);
DateTime dtResult = dtStart.Add(toNow);
return dtResult;
}
/// <summary>
/// 个人资料1
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button7_Click(object sender, EventArgs e) {
try {
if (string.IsNullOrEmpty(txtQQ.Text)) {
MessageBox.Show("QQ号不可为空!");
return;
}
Button btn = (Button)sender;
webClient.Encoding = Encoding.GetEncoding("utf-8");//设置编码
string html = webClient.DownloadString(string.Format(btn.Tag.ToString(), txtQQ.Text));
//取数据
html = html.Replace("_Callback(", "").Replace(");", "").Replace(""", "\"").Replace("\n", "");
UserQQ qq = (UserQQ)JavaScriptConvert.DeserializeObject(html, typeof(UserQQ));
string st = "";
st += string.Format("QQ:{0}<br />", qq.uin);
st += string.Format("<hr />名称:{0}<br />", qq.nickname);
st += string.Format("<hr />真实姓名:{0}<br />", qq.realname);
st += string.Format("<hr />开通空间:{0}<br />", qq.qzone == 0 ? "已开通QQ空间" : "未开通QQ空间");
st += string.Format("<hr />空间积分:{0}<br />", qq.intimacyScore);
st += string.Format("<hr />是否在线:<img alt=\"亮的QQ图标表示在线,灰色的表示不在线或者隐身状态\" title=\"亮的QQ图标表示在线,灰色的表示不在线或者隐身状态\" src='http://wpa.qq.com/pa?p=1:{0}:4'/><br />", qq.uin);
st += string.Format("<hr />强制聊天:<a href='http://wpa.qq.com/msgrd?v=3&site=qq&menu=yes&uin={0}' target=\"_blank\">强制聊天</a><br />", qq.uin);
st += string.Format("<hr /><img src='{0}' /><br /><hr />", qq.avatarUrl);
webShow.DocumentText = st;
} catch (Exception ex) {
MessageBox.Show("QQ号格式错误或不存在!" + ex.Message);
}
}
/// <summary>
/// 登录
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button10_Click(object sender, EventArgs e) {
Button btn = (Button)sender;
webShow.Navigate(btn.Tag.ToString());
}
/// <summary>
/// 双击保存图片
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void imgShow_DoubleClick(object sender, EventArgs e) {
if(saveFile.ShowDialog() == System.Windows.Forms.DialogResult.OK){
imgShow.Image.Save(saveFile.FileName);
}
}
}
}