/// <summary>获取验证码图片信息</summary> /// <returns>验证码图片信息</returns> public VerifyCodeImageInfo GetVerifyCodeImageInfo() { var vcii = new VerifyCodeImageInfo(); vcii.Text = this.GetVerifyCode(5); vcii.ImageWidth = WebGet.GetInt("w", 200); vcii.ImageHeight = WebGet.GetInt("h", 80); var tc = WebGet.GetString("tc"); if (tc.IsNullOrEmpty_()) { vcii.TextColor = Color.Empty; vcii.RandomTextColor = true; } else { vcii.TextColor = ColorTranslator.FromHtml(tc); vcii.RandomTextColor = WebGet.GetString("r").ToBool_(); } var bc = WebGet.GetString("bc"); vcii.BackgroundColor = bc.IsNullOrEmpty_() ? Color.White : ColorTranslator.FromHtml(bc); vcii.ImageFormat = ImageFormat.Png; this.CreateVerifyCodeImage(vcii); return(vcii); }
private void _ShowId() { string url = this._GetCode(InformerCode.BaseUrl); if (string.IsNullOrWhiteSpace(url)) { return; } try { this.PBConrolInformer.Image.Dispose(); this.PBConrolInformer.Image = (Image)WebGet.GetImage(url, this._clform._iLog); } catch (Exception) { this.PBConrolInformer.Image = (Image)Properties.Resources.InformerLoadingError; return; } this._Show(); }
private void bgNotifyWorker_DoWork(object sender, DoWorkEventArgs e) { try { if (this.bgNotifyWorker.CancellationPending) { e.Cancel = true; this.bgNotifyWorker.ReportProgress(0); return; } if ( (Properties.Settings.Default.USRUrl.Count < 3) || (string.IsNullOrWhiteSpace(Properties.Settings.Default.USRUrl[1])) ) { throw new ArgumentException( string.Format( Properties.Resources.fmtError, "URL " + Properties.Resources.txtSetupData, Properties.Resources.txtIncomplete ) ); } string jout, url = string.Format( Properties.Settings.Default.URLNotifySetup, Properties.Settings.Default.USRCoCServer, Properties.Settings.Default.USRUrl[1], new Random(DateTime.Now.Millisecond).Next(0, Int32.MaxValue) ); DateTime dtnow; CoCEnum.EventNotify type; bool isChangeMembers = false; int crw, cnp, cnt = 10; this._oldNotifyItems = crw = this.FLVNotify.Items.Count; this.bgNotifyWorker.ReportProgress(5); jout = WebGet.GetJsonString(url, this._iLog); if (string.IsNullOrWhiteSpace(jout)) { this.bgNotifyWorker.ReportProgress(0); throw new ArgumentException( string.Format( Properties.Resources.fmtError, "Json " + Properties.Resources.txtRequest, Properties.Resources.txtIsEmpty ) ); } this.bgNotifyWorker.ReportProgress(cnt); DataTable dt = jout.JsonToDataTable <stClient.ClanNotifyClient>(); if (dt.Rows.Count < 1) { this.bgNotifyWorker.ReportProgress(0); throw new ArgumentException( string.Format( Properties.Resources.fmtError, "DataTable", Properties.Resources.txtIsEmpty ) ); } cnp = (int)(90 / dt.Rows.Count); cnp = ((cnp == 0) ? 1 : cnp); dtnow = DateTime.Now; string grpDate = dtnow.ToString("HH:mm dd-MM", CultureInfo.InvariantCulture); flatThreadSafe.Run(this, (Action)(() => this.TSCBGroup.Items.Add(grpDate))); ListViewGroup grp = new FlatListViewGroup( this.FLVNotify, new string[] { grpDate, string.Format( Properties.Resources.fmtListViewGroup, grpDate, dt.Rows.Count ) }, HorizontalAlignment.Left ).ListViewGroup(); foreach (DataRow dr in dt.Rows) { string ids, fmt1, fmt2; DataRow drn = this._dtnotify.NewRow(); drn.ItemArray = dr.ItemArray.Clone() as object[]; drn["dtin"] = dtnow; this._dtnotify.Rows.Add(drn); this.bgNotifyWorker.ReportProgress(cnt += cnp); try { ids = Convert.ToString(drn["id"], CultureInfo.InvariantCulture); if ( (string.IsNullOrWhiteSpace(ids)) || (!Enum.TryParse <CoCEnum.EventNotify>(ids, out type)) || // Check a valid event id (!(bool)Properties.Settings.Default[ids]) ) { throw new ArgumentException(); } fmt1 = stClient.Properties.ResourceNotify.ResourceManager.GetString("fmt1" + ids); fmt2 = stClient.Properties.ResourceNotify.ResourceManager.GetString("fmt2" + ids); if ( (string.IsNullOrWhiteSpace(fmt1)) || (string.IsNullOrWhiteSpace(fmt2)) ) { throw new ArgumentException(); } } catch (Exception) { continue; } switch (type) { case CoCEnum.EventNotify.MemberNew: case CoCEnum.EventNotify.MemberExit: case CoCEnum.EventNotify.ClanChangeMembers: { isChangeMembers = true; break; } } new FlatListViewItem( this.FLVNotify, grp, new string[] { "", grpDate, string.Format( fmt1, (string)drn["name"] as string, (string)drn["vold"] as string, (string)drn["vnew"] as string, (string)drn["vres"] as string, (string)drn["vs"] as string, (string)drn["vcalc"] as string, (string)drn["tag"] as string ), string.Format( fmt2, (string)drn["name"] as string, (string)drn["vold"] as string, (string)drn["vnew"] as string, (string)drn["vres"] as string, (string)drn["vs"] as string, (string)drn["vcalc"] as string, (string)drn["tag"] as string ), (string)drn["tag"] as string }, (string)drn["id"] as string, crw++ ); } if ( (this.TSTBNotifyFind.AutoCompleteCustomSource.Count == 0) || (isChangeMembers) ) { this.AutoCompleteNotifySelect(this.TSTBNotifyFind); } this.bgNotifyWorker.ReportProgress(90); if (crw > this._oldNotifyItems) { flatThreadSafe.Run(this, (Action)(() => this.FLVNotify.Items[this._oldNotifyItems].Selected = true)); } // Image Informer if (this._CheckSetupInformer()) { url = string.Format( Properties.Settings.Default.URLServerInformer, Properties.Settings.Default.USRCoCServer, Properties.Settings.Default.USRUrl[2], Properties.Settings.Default.USRInformerId, Properties.Settings.Default.USRCoCTag, new Random(DateTime.Now.Millisecond).Next(0, Int32.MaxValue) ); if (this.ImageInformer != null) { this.ImageInformer.Dispose(); this.ImageInformer = null; } try { this.ImageInformer = (Image)WebGet.GetImage(url, this._iLog); } catch (Exception ex) { this.ImageInformer = (Image)Properties.Resources.InformerLoadingError; throw ex; } finally { this.bgNotifyWorker.ReportProgress(100); } } } catch (Exception ex) { this._winMessageError(ex.Message); } finally { this.bgNotifyWorker.ReportProgress(0); } }
private void AutoCompleteNotifySelect(ToolStripTextBox tstb) { if (Properties.Settings.Default.USRUrl.Count == 0) { return; } try { string jout, url = string.Format( Properties.Settings.Default.URLMemberSetup, Properties.Settings.Default.USRCoCServer, Properties.Settings.Default.USRUrl[0], new Random(DateTime.Now.Millisecond).Next(0, Int32.MaxValue) ); jout = WebGet.GetJsonString(url, this._iLog); if (string.IsNullOrWhiteSpace(jout)) { this.bgNotifyWorker.ReportProgress(0); throw new ArgumentException( string.Format( Properties.Resources.fmtError, "Json " + Properties.Resources.txtRequest, Properties.Resources.txtIsEmpty ) ); } if (this._dtclan != null) { flatThreadSafe.Run(this, (Action)(() => this._dtclan.Clear())); } this._dtclan = jout.JsonToDataTable <stClient.ClanMemberClient>(); if (this._dtclan.Rows.Count < 1) { this.bgNotifyWorker.ReportProgress(0); throw new ArgumentException( string.Format( Properties.Resources.fmtError, "DataTable", Properties.Resources.txtIsEmpty ) ); } List <string> autolst = new List <string>(); foreach (DataRow dr in this._dtclan.Rows) { string nik; try { nik = Convert.ToString(dr["nik"], CultureInfo.InvariantCulture); if (string.IsNullOrWhiteSpace(nik)) { throw new ArgumentNullException(); } } catch (Exception) { continue; } autolst.Add(nik); } flatThreadSafe.Run(this, (Action)(() => tstb.AutoCompleteCustomSource.Clear())); flatThreadSafe.Run(this, (Action)(() => tstb.AutoCompleteCustomSource.AddRange(autolst.ToArray()))); } catch (Exception ex) { this._winMessageError(ex.Message); } }
public override HtmlNode abstractNode(string link) { var docBisc = WebGet.Load(link); return(docBisc.DocumentNode.SelectSingleNode("//table[@class ='MsoNormalTable']")); }
private void CheckGameTag_Click(object sender, EventArgs e) { if (!this._isGameTagChanged) { return; } this._isGameTagChanged = false; try { string jout, url, tag = this.FTBGameTag1.Text; this.FTBCoCServer1.Text = url = this._URLNormalize(this.FTBCoCServer1.Text); if (string.IsNullOrWhiteSpace(url)) { throw new ArgumentException( string.Format( Properties.Resources.fmtError, "URL", Properties.Resources.txtIsEmpty ) ); } if (string.IsNullOrWhiteSpace(tag)) { throw new ArgumentException( string.Format( Properties.Resources.fmtError, "tag/server " + Properties.Resources.txtRequest, Properties.Resources.txtIsEmpty ) ); } if (tag.StartsWith("#")) { this.FTBGameTag1.Text = tag = tag.Substring(1, (tag.Length - 1)); } url = string.Format( Properties.Settings.Default.URLUserSetup, url, tag ); jout = WebGet.GetJsonString(url, this._iLog); if (string.IsNullOrWhiteSpace(jout)) { throw new ArgumentException( string.Format( Properties.Resources.fmtError, "Json " + Properties.Resources.txtRequest, Properties.Resources.txtIsEmpty ) ); } DataTable dt = jout.JsonToDataTable <stClient.ClanMemberClient>(); if (dt.Rows.Count < 1) { throw new ArgumentException( string.Format( Properties.Resources.fmtError, "DataTable", Properties.Resources.txtIsEmpty ) ); } if ( (!this._CheckDataRow(dt.Rows[0], 18, "tag", "nik")) || // TODO: later, count is 19 (!tag.Equals((string)dt.Rows[0]["tag"])) ) { throw new ArgumentException( string.Format( Properties.Resources.fmtError, "client " + Properties.Resources.txtSetupData, Properties.Resources.txtIncorrect ) ); } new FlatListViewItem( this.FLVSetup, new string[] { "IRCNick", (string)(string)dt.Rows[0]["nik"].ToString() } ); new FlatListViewItem( this.FLVSetup, new string[] { "UserGameTag", (string)(string)dt.Rows[0]["tag"].ToString() } ); if (this.FCBNikAuto.Checked) { this.FTBIrcNick1.Text = Regex.Replace((string)dt.Rows[0]["nik"].ToString(), @"[^\u0020-\u007E]", string.Empty); } } catch (Exception ex) { this._SetErrorFlatTextBox( this.FTBGameTag1, string.Format( Properties.Resources.fmtCoCServer, Properties.Resources.txtIncorrectUserIdTag, "" ) ); this._winMessageError(ex.Message); } }
private void CheckCoCServer_Click(object sender, EventArgs e) { try { if (this._dtsetup != null) { this._dtsetup.Clear(); this._dtsetup = null; } this.FLVSetup.Clear(); this.errorProviderSetup.Clear(); string jout, url; this.FTBCoCServer1.Text = url = this._URLNormalize(this.FTBCoCServer1.Text); if (string.IsNullOrWhiteSpace(url)) { throw new ArgumentException( string.Format( Properties.Resources.fmtError, "URL", Properties.Resources.txtIsEmpty ) ); } url = string.Format( Properties.Settings.Default.URLServerSetup, url, new Random(DateTime.Now.Millisecond).Next(0, Int32.MaxValue) ); jout = WebGet.GetJsonString(url, this._iLog); if (string.IsNullOrWhiteSpace(jout)) { throw new ArgumentException( string.Format( Properties.Resources.fmtError, "Json " + Properties.Resources.txtRequest, Properties.Resources.txtIsEmpty ) ); } this._dtsetup = jout.JsonToDataTable <stClient.ServerSetup>(); if (this._dtsetup.Rows.Count < 1) { throw new ArgumentException( string.Format( Properties.Resources.fmtError, "DataTable", Properties.Resources.txtIsEmpty ) ); } if ( (!this._CheckDataRow(this._dtsetup.Rows[0], 10, "ServerVersion", "ServerMagic")) || (!((string)this._dtsetup.Rows[0]["ServerVersion"]).ToMD5().Equals((string)this._dtsetup.Rows[0]["ServerMagic"])) ) { throw new ArgumentException( string.Format( Properties.Resources.fmtError, Properties.Resources.txtSetupData, Properties.Resources.txtIncorrect ) ); } this.FLVSetup.Columns.Add("", 150, HorizontalAlignment.Left); this.FLVSetup.Columns.Add("", (this.FLVSetup.Width - 150), HorizontalAlignment.Left); for (int i = 0; i < this._dtsetup.Columns.Count; i++) { new FlatListViewItem( this.FLVSetup, new string[] { (string)this._dtsetup.Columns[i].ColumnName, (string)this._dtsetup.Rows[0][this._dtsetup.Columns[i].ColumnName].ToString() } ); } this._winStatusBar( string.Format( Properties.Resources.fmtServerFound, (string)this._dtsetup.Rows[0]["ServerVersion"] ) ); this._CheckTimerNotify(); } catch (Exception ex) { this._SetErrorFlatTextBox( this.FTBCoCServer1, string.Format( Properties.Resources.fmtCoCServer, Properties.Resources.txtIncorrectServerAddr, "" ) ); this._winMessageError(ex.Message); this._CheckTimerNotify(); } }