private void frmLogin_Load(object sender, EventArgs e) { //如果是DEBUG模式则显示调试按钮,切记编译时切换为Release #if DEBUG btnDebug.Visible = true; #endif try { Myhelp.getHtml("http://appimg2.qq.com/card/index_v3.html"); } catch (Exception) { MessageBox.Show("未连接网络或者其它什么原因,反正不关我的事\r再见!!!!!!!!!!!!!!!!!!!!", "出错辣!"); Environment.Exit(0); } webLoign.ScriptErrorsSuppressed = true; //屏蔽脚本错误 webLoign.IsWebBrowserContextMenuEnabled = false; //禁用右键菜单 webLoign.Navigate("http://xui.ptlogin2.qq.com/cgi-bin/xlogin?appid=1600000084&s_url=http://appimg2.qq.com/card/index_v3.html"); //跳转到登录页面 }//载入窗口载入登录网站
private void FrmEx_Load(object sender, EventArgs e) { #region 获取信息の块(每次登录都会重新获取) //待编辑 Mydata.Gtk = Myhelp.getGtk(Mydata.Cookies); //gtk Mydata.isChanging = false; Mydata.Iuin = Myhelp.getIuin(Mydata.Cookies); //登录者QQ string Iname = Myhelp.getIname(Myhelp.postHtml("http://card.show.qq.com/cgi-bin/card_user_mainpage?g_tk=" + Mydata.Gtk, "uin=" + Mydata.Iuin, Mydata.Cookies)); //Debug.WriteLine(Iname); tsmiUser.Text = Iname == "" ? Mydata.Iuin : Iname; //如果有ID就ID,没有就用QQ gBoxI.Text = Iname == "" ? Mydata.Iuin : Iname; //如果有ID就ID,没有就用QQ gBoxI.Text += ".卡箱 [点此刷新]"; #endregion gboxThemes.Location = new Point(-190, 27); ThreadStart myThreaddelegate = new ThreadStart(Load_Card); Thread tre = new Thread(myThreaddelegate) { IsBackground = true // 设置为后台线程,在主窗口退出时线程强制退出 }; tre.Start(); }//载入窗口时
}//卖卡 public static string Card_Fsid(string ThemeId) { return(Myhelp.postHtml("http://card.show.qq.com/cgi-bin/card_user_theme_list?g_tk=" + Gtk, "tid=" + ThemeId + " &uin=" + Iuin, Cookies)); }//获取卡友
}//买卡 public static void Card_Sell() { Myhelp.postHtml("http://card.show.qq.com/cgi-bin/card_market_npc_sell?g_tk=" + Gtk, "", Cookies); }//卖卡
}//该用户信息 public static string Card_Excg(string postdata) { return(Myhelp.postHtml("http://card.show.qq.com/cgi-bin/card_user_exchangecard?g_tk=" + Gtk, postdata, Cookies)); }//换卡
public static string Card_User(string UIN) { return(Myhelp.postHtml("http://card.show.qq.com/cgi-bin/card_user_mainpage?g_tk=" + Gtk, UIN, Cookies)); }//该用户信息
private void Card_Exchange() { string cardid = null, cardsit = null, isCof = null; //卡片ID,卡片位置,是否保险箱 string iChoseCards = null, uChoseCards = null; //我的卡片信息,卡友卡片信息 int temp = 0; //数量计数 foreach (ListViewItem item in lvIbox.CheckedItems) { cardid = ((Mydata.MyItem)item.Tag).Id.ToString(); //取出卡片ID cardsit = ((Mydata.MyItem)item.Tag).Sit.ToString(); //取出卡片位置 isCof = item.Group.Header.IndexOf("卡箱") > 0 ? "0" : "1"; //是否保险箱 temp++; //数量累计 string tempChoseCards = cardid + "_" + cardsit + "_" + isCof; if (temp > 1) { iChoseCards = iChoseCards + "|" + tempChoseCards; } else { iChoseCards = tempChoseCards; } //少于等于1则直接输出,大于则在中间加上| } temp = 0;//重置计数 foreach (ListViewItem item in lvUbox.CheckedItems) { cardid = ((Mydata.MyItem)item.Tag).Id.ToString(); cardsit = ((Mydata.MyItem)item.Tag).Sit.ToString(); string tempChoseCards = cardid + "_" + cardsit + "_0"; temp++; if (temp > 1) { uChoseCards = uChoseCards + "|" + tempChoseCards; } else { uChoseCards = tempChoseCards; } } string postData; //创建提交变量 postData = string.Format("uin={0}&frnd={1}&cmd=1&isFriend=1&src={2}&dst={3}", Mydata.Iuin, Mydata.Uuin, iChoseCards, uChoseCards); //frnd=对方QQ&cmd=1&isFriend=1&src=对方卡片信息&uin=我的QQ&dst=我的卡片信息 string EXchangeTemp = Mydata.Card_Excg(postData); //提交并取得返回值 if (EXchangeTemp.IndexOf("code=\"0\"") != -1) { //成功修改背景字体 tssState.Text = "交换成功 ~~~"; tssState.ForeColor = Color.Black; tssState.BackColor = Color.GreenYellow; I_boxInfo(); //刷新我的卡箱 U_boxInfo(); //刷新卡友卡箱 tssEXchange.Visible = false; tsslOkExchange.Visible = false; Console.Beep(800, 200);//成功提醒 } else { string switchStr = Myhelp.getMid(EXchangeTemp, "code=\"", "\" mess"); //取出失败ID,进行switch匹配 switch (switchStr) { case "0": break; case "-33061": tssState.Text = "交换失败,此卡已被换走!"; break; case "-33058": tssState.Text = "交换失败,有卡片被锁!"; break; default: tssState.Text = "交换失败,未知错误!"; break; } tssState.ForeColor = Color.Black; tssState.BackColor = Color.Red; //I_boxInfo();//刷新我的卡箱 U_boxInfo();//刷新卡友卡箱 tssEXchange.Visible = false; tsslOkExchange.Visible = false; Console.Beep(400, 200);//失败提醒 } }
private void Load_Card() { this.FormBorderStyle = FormBorderStyle.None; this.Size = new Size(327, 93); Rectangle rect = Screen.GetWorkingArea(this); //获取显示器的分辨率 this.Location = new Point(rect.Width / 2 - this.Width / 2, rect.Height / 2 - this.Height / 2); lblState.Location = new Point(0, 0); #region 卡片信息处理 string CARD_IFFO = Myhelp.getHtml("http://appimg2.qq.com/card/mk/card_info_v3.js"); //有网时 string CARD_MINI = Myhelp.postHtml("http://card.show.qq.com/cgi-bin/card_mini_get?g_tk=" + Mydata.Gtk, "uin=" + Mydata.Iuin, Mydata.Cookies); //已收集的套卡 Regex regStr = new Regex("id=\"(.*)\" num=\"(.*)\"", RegexOptions.IgnoreCase); //已收集套卡信息的正则 MatchCollection mats = regStr.Matches(CARD_MINI); regStr = new Regex(@"(\d{2,4}),'(.*|[\(].*[\)])',(\d),(\d{10}),.*\[(.*)\],(.),.*\d{10},(\d{1,10}),", RegexOptions.IgnoreCase); //套卡信息的正则 MatchCollection mat = regStr.Matches(CARD_IFFO); for (int i = 0; i < mat.Count; i++) { int id = Convert.ToInt32(mat[i].Groups[1].ToString()); //-------------------- string name = mat[i].Groups[2].ToString(); int diff = Convert.ToInt32(mat[i].Groups[3].ToString()); int time = Convert.ToInt32(mat[i].Groups[4].ToString()); // 各种的数据 string cards = mat[i].Groups[5].ToString(); int type = Convert.ToInt32(mat[i].Groups[6].ToString()); int offtime = Convert.ToInt32(mat[i].Groups[7].ToString());//---------------------- MyMethod mmd = delegate() { #region 加载套卡 必须优化,代码乱的要死 bool xxx = false; switch (type) { case 0: case 2: #region xxx = false; for (int x = 0; x < mats.Count; x++) { if (id == Convert.ToInt32(mats[x].Groups[1].ToString())) { xxx = true; break; } } if (xxx) { tvFX.Nodes[diff.ToString()].Nodes.Insert(0, name).Tag = id; //添加子节点的同时添加它的数据(ID) tvFX.Nodes[diff.ToString()].Nodes[0].BackColor = Color.FromArgb(128, 255, 128); } else { tvFX.Nodes[diff.ToString()].Nodes.Insert(0, name).Tag = id; //添加子节点的同时添加它的数据(ID) } #endregion break; case 1: case 5: #region xxx = false; for (int x = 0; x < mats.Count; x++) { if (id == Convert.ToInt32(mats[x].Groups[1].ToString())) { xxx = true; break; } } if (xxx) { tvXJ.Nodes[diff.ToString()].Nodes.Insert(0, name).Tag = id; //添加子节点的同时添加它的数据(ID) tvXJ.Nodes[diff.ToString()].Nodes[0].BackColor = Color.FromArgb(128, 255, 128); } else { tvXJ.Nodes[diff.ToString()].Nodes.Insert(0, name).Tag = id; //添加子节点的同时添加它的数据(ID) } #endregion break; case 9: #region xxx = false; for (int x = 0; x < mats.Count; x++) { if (id == Convert.ToInt32(mats[x].Groups[1].ToString())) { xxx = true; break; } } if (xxx) { tvSK.Nodes[diff.ToString()].Nodes.Insert(0, name).Tag = id; //添加子节点的同时添加它的数据(ID) tvSK.Nodes[diff.ToString()].Nodes[0].BackColor = Color.FromArgb(128, 255, 128); } else { tvSK.Nodes[diff.ToString()].Nodes.Insert(0, name).Tag = id; //添加子节点的同时添加它的数据(ID) } #endregion break; default: break; } #endregion }; Invoke(mmd); _themeDic.Add(id, new ThemeTemplet(id, name, diff, time, cards, type, offtime)); //将信息存入该字典中 //ds.Tables["Theme"].Rows.Add(new object[] { id, name }); } regStr = new Regex(@"\[(.*),(.*),'(.*)',(\d{2,4}),", RegexOptions.IgnoreCase);//卡片信息的正则 mat = regStr.Matches(CARD_IFFO); for (int i = 0; i < mat.Count; i++) { int id = Convert.ToInt32(mat[i].Groups[1].ToString()); int themeid = Convert.ToInt32(mat[i].Groups[2].ToString()); string name = mat[i].Groups[3].ToString(); int price = Convert.ToInt32(mat[i].Groups[4].ToString()); _cardDic.Add(id, new CardTemplet(id, themeid, name, price)); } tssState.BackColor = Color.FromArgb(128, 255, 128); tssState.Text = "卡片信息加载完毕!!!"; lblState.Visible = false; #endregion this.FormBorderStyle = FormBorderStyle.FixedSingle; this.Size = new Size(440, 408); cbTop.Left = 366; this.Location = new Point(rect.Width / 2 - this.Width / 2, rect.Height / 2 - this.Height / 2); lblHide.Enabled = true; btnTst.Enabled = true; Console.Beep(); Debug.WriteLine(groupBox1.Location.Y); }//获取和载入卡片