private void ActiveGame_EnteredGuess(object sender, EnteredGuessEventArgs e) { lblSonuc.SetText(e.Guess, e.GuessResults, ActiveGame.TotalGuessCount); if (ActiveGame.SayiTahminData.GecmisiGoster) { StringBuilder ResultsText = new StringBuilder(); rtbHistory.mRichTextBox.Select(rtbHistory.Text.Length, 0); ToRtf toRtf = new ToRtf(); if (CWMode) { string equaltfmt = "<font color=limegreen>{0}</font>"; string equalondiffertfmt = "<font color=orangered>{0}</font>"; foreach (var compareResult in e.GuessResults.TargetTextResults) { char gchar = compareResult.CharValue; switch (compareResult.CompareResults) { case NumberCompareResultEnum.NotEquals: default: ResultsText.Append(gchar); break; case NumberCompareResultEnum.Equals: ResultsText.AppendFormat(equaltfmt, gchar); break; case NumberCompareResultEnum.EqualsOnDiffer: ResultsText.AppendFormat(equalondiffertfmt, gchar); break; } } toRtf.KaynakMetin = string.Format("{0}: <font size=10><b>{1}</b></font>(<font size=8>{2}</font>)", ActiveGame.TotalGuessCount, ResultsText, e.GuessResults); } else { toRtf.KaynakMetin = string.Format("{0}: <font size=10><b>{1}</b></font>(<font size=8>{2}</font>)", ActiveGame.TotalGuessCount, e.Guess, e.GuessResults); } rtbHistory.SelectedRtf = toRtf.HtmlToRtf(); rtbHistory.mRichTextBox.ScrollToCaret(); } }
private Task loadUserStatistics() { return(Task.Factory.StartNew <string>( () => { string fmttext = "<b>{0}</b>: {1}"; string fmttext_num = "<b>{0}</b>: {1:0.##}"; string fmttextex = "<b>{0}</b>"; StringBuilder SB = new StringBuilder(); SB.AppendFormat(fmttext, String.GetLangText("STS_ACT_PRF"), ActiveProfile.ProfileName); SB.AppendLine(); SB.AppendFormat(fmttext, String.GetLangText("STT_CREATE_DATE"), ActiveProfile.CreationDate); SB.AppendLine(); SB.AppendFormat(fmttext, String.GetLangText("STT_LAST_ACTIVITY"), ActiveProfile.LastactivityDate); SB.AppendLine(); IEnumerable <ProfileStatistic> allStatistics = ActiveProfile.Statistics.GetAllStats(true); int prevdepth = 0; IProfileStatistics nocontinue = null; foreach (var statistic in allStatistics) { if (statistic == null) { continue; } string gfmt = fmttext; int currentdepth = statistic.Depth; if (currentdepth < prevdepth) { for (int i = 0; i < prevdepth - currentdepth; i++) { SB.Append("</ol>"); } prevdepth = currentdepth; } if (nocontinue != null) { if (statistic.BaseStatistic != null && statistic.BaseStatistic == nocontinue) { //prevdepth = currentdepth; continue; } } if (statistic.SubStatsNullOrEmpty() && string.IsNullOrEmpty(statistic.ValueString)) { nocontinue = statistic; continue; } SB.AppendLine(); object svalue = ""; if (statistic.Value != null) { svalue = statistic.Value; } //if(statistic.Stats.StatsCount > 0) //{ // svalue =null; //} //else //{ // svalue = statistic.Value; //} if (currentdepth > 0) { SB.Append("<li>"); } //for (int i = 0; i < currentdepth; i++) //{ // SB.Append("--"); //} //if (currentdepth > 0) SB.Append(">"); if (statistic.Stats.StatsCount > 0 && (statistic.Value == null || statistic.ValueString == "" || statistic.ValueString == "***")) { SB.AppendFormat(fmttextex, String.GetLangTextOrDefault(statistic.GetFullName(), statistic.Name)); } else { if (svalue != null) { if (svalue.IsNumeric()) { gfmt = fmttext_num; } } SB.AppendFormat(gfmt, String.GetLangTextOrDefault(statistic.GetFullName(), statistic.Name), svalue); } if (currentdepth > 0) { SB.Append("</li>"); } prevdepth = currentdepth; if (statistic.Stats.StatsCount > 0) { SB.Append("<ol>"); } } return SB.ToString(); }).ContinueWith((t) => { string lastresults = t.Result; ToRtf toRtf = new ToRtf(); toRtf.KaynakMetin = lastresults; this.Invoke((MethodInvoker) delegate { rtbStats.Rtf = toRtf.HtmlToRtf(); }); //toRtf.HtmlToRtf(); }); })); }