private void SyncHeader(Property prop) { try { Single goal = UserSettings.Current.GetGoal(prop); Amount total = Cache.GetPropertyTotal(date, prop); JournalViewHeaderVM header = GetHeader(prop); header.Value = total.ValueString(); if (Single.IsNaN(goal) || goal == 0) { header.SubHeader = ""; } else { var remaining = goal - total.ToSingle(); if (remaining < 0) { header.SubHeader = string.Format(AppResources.GoalOver, Floats.ToUIString(-remaining)); } else { header.SubHeader = string.Format(AppResources.GoalUnder, Floats.ToUIString(remaining)); } } } catch (Exception ex) { LittleWatson.ReportException(ex); } }
public string ToString(bool round) { if (IsZero) { return(""); } //if (value == 0) return None.nonStdUnit; if (IsStandardUnit) { return(stdUnit.ToString(value, round)); } var amt = nonStdUnit; if (!IsShapeDescription && !IsProperty && value > 1) { amt = Strings.GetPlural(amt); } if (round) { return(string.Format("{0} {1}", Floats.ToUIString(value), amt)); } else { return(string.Format("{0} {1}", Floats.ToStorageString(value), amt)); } }
public string ValueString() { if (value != 0) { return(Floats.ToUIString(value)); } return(string.Empty); }
public string ToString(Single value, bool round) { // TODO: perhaps this should implement Uncide CLDR rules for other cultures if (round) { if (value > 0 && value <= 1) { return(string.Format("{0} {1}", Floats.ToUIString(value), LocalizedText)); } return(string.Format("{0} {1}", Floats.ToUIString(value), LocalizedMulti)); } else { if (value > 0 && value <= 1) { return(string.Format("{0} {1}", Floats.ToStorageString(value), LocalizedText)); } return(string.Format("{0} {1}", Floats.ToStorageString(value), LocalizedMulti)); } }
private string MakeEmailReportHtml() { StringBuilder output = new StringBuilder(); string style = @" <style> body { font-family: 'Segoe UI Light', Tahoma, Geneva, Verdana, sans-serif; } h1 { font-size: xx-large; color: #248; } th { background-color: #36C; color: #FFFFFF; } td { text-align: right; width: 200px; } td.text { text-align: left; width: 800px; } tr { font-size: small; color: #666; } .period, .total, .total2 { font-size: medium; background-color: #EEE; color: #000; } .total { font-size: large; font-weight: bold; } .total2 { font-size: small; } .footer { font-size: smaller; } .note { font-size: xx-small; } </style> "; style = style.Replace('\t', ' ').Replace('\n', ' ').Replace('\r', ' '); while (style.Contains(" ")) { style = style.Replace(" ", " "); } output.Append(style); output.Append("<h1>"); output.Append(AppResources.ApplicationTitle); output.Append("</h1>"); output.Append("<h2>"); output.Append(date.ToLongDateString()); output.Append("</h2>"); output.Append("<table>"); // header row output.Append("<tr>"); output.Append("<th>"); output.Append("</th>"); foreach (var prop in UserSettings.Current.SelectedProperties) { output.Append("<th>"); output.Append(prop.FullText); output.Append("</th>"); } output.Append("</tr>"); foreach (var period in Periods) { output.Append("<tr class=\"period\">"); output.Append("<td class=\"text\">"); output.Append(period.Text); output.Append("</td>"); foreach (var prop in UserSettings.Current.SelectedProperties) { output.Append("<td>"); output.Append(Cache.GetPeriodPropertyValue(date, period.Period, prop).ValueString()); output.Append("</td>"); } output.Append("</tr>"); int i = 0; foreach (var line in period.Lines) { output.Append("<tr>"); output.Append("<td class=\"text\">"); output.Append(line.Text); output.Append("</td>"); if (line.entry != null) { foreach (var prop in UserSettings.Current.SelectedProperties) { output.Append("<td>"); output.Append(line.entry.GetPropertyValue(prop).ValueString()); output.Append("</td>"); } } output.Append("</tr>"); if (i++ > MAXLINESPERMEALINREPORT) { break; } } } output.Append("<tr class=\"total\">"); output.Append("<td class=\"text\">"); output.Append(AppResources.Total); output.Append("</td>"); foreach (var prop in UserSettings.Current.SelectedProperties) { output.Append("<td>"); output.Append(Cache.GetPropertyTotal(date, prop).ValueString()); output.Append("</td>"); } output.Append("</tr>"); output.Append("<tr class=\"total2\">"); output.Append("<td></td>"); foreach (var prop in UserSettings.Current.SelectedProperties) { output.Append("<td>"); Single goal = UserSettings.Current.GetGoal(prop); if (!Single.IsNaN(goal) && goal != 0) { string text; Amount total = Cache.GetPropertyTotal(date, prop); var remaining = goal - total.ToSingle(); if (remaining < 0) { text = string.Format(AppResources.GoalOver, Floats.ToUIString(-remaining)); } else { text = string.Format(AppResources.GoalUnder, Floats.ToUIString(remaining)); } output.Append(text); } output.Append("</td>"); } output.Append("</tr>"); output.Append("</table>"); output.Append("<p class=\"footer\">"); #if WINDOWS_PHONE var aaa = @"<a href=""http://www.windowsphone.com/s?appid=2f44a06e-3d7c-4e11-b74d-9135949a1889"">" + AppResources.AppTitle + "</a><br />"; #else var aaa = @"<a href=""https://play.google.com/store/apps/details?id=" + Navigate.navigationContext.ApplicationContext.PackageName + @""">" + AppResources.AppTitle + "</a><br />"; //var aaa = @"<a href=""https://play.google.com/store/apps/details?id=app.dailybits.foodjournal"">" + AppResources.AppTitle + "</a><br />"; #endif var bbb = @"<a href=""mailto:" + AppStats.email + @""">" + AppStats.email + "</a>"; if (!string.IsNullOrEmpty(AppResources.EmailReport_Footer1a)) { output.Append(AppResources.EmailReport_Footer1a.Replace("AAA", aaa)); output.Append("<br />"); output.Append(AppResources.EmailReport_Footer1b.Replace("BBB", bbb)); } else { output.Append(AppResources.EmailReport_Footer1.Replace("AAA", aaa).Replace("BBB", bbb)); } output.Append("</p>"); output.Append("<p class=\"note\">"); output.Append(AppResources.EmailReport_Footer2); output.Append("</p>"); return(output.ToString()); }