private async Task DisplayReportContent() { string fileContent; using (StreamReader s = new StreamReader(await currentReportFile.OpenStreamForReadAsync())) { fileContent = await s.ReadToEndAsync(); s.Dispose(); } //Report currReport = new Report(fileContent); currentReport = await Report.GenerateFromString(fileContent); PageTitle.Text = currentReport.getReportName(); imagePreview.Source = new BitmapImage(new Uri(currentReport.getImage().Path)); GeolocationToolTip.FontSize = 15; GeolocationToolTip.Text = "Latitude: " + currentReport.getLatitude() + "\n\nLongitude: " + currentReport.getLongitude(); if (!currentReport.isTagsReady()) { TagsToolTip.FontSize = 20; TagsToolTip.Text = "No tags"; } else { // display as much selected tags String t = ""; int NoOfTags = currentReport.getTags().Count; if (NoOfTags == 0) { TagsToolTip.FontSize = 20; TagsToolTip.Text = "No tags"; currentReport.setTagsNotReady(); } else { int TagCount = 0; int TagLimit = 8; int LineCount = 0; int LineLimit = 3; foreach (String element in currentReport.getTags()) { // if we've displayed 6 tags if (TagCount >= TagLimit) { break; } // if we've got two tags on a line if (!(LineCount < LineLimit)) { t += "\n"; LineCount = 0; } // append tag t += "#" + element + ", "; LineCount++; TagCount++; } // remove extra comma t = t.Substring(0, t.Length - 2); // if user selected more than 6 tags, add a ... if (NoOfTags > TagLimit) { t += "..."; } // display tags TagsToolTip.FontSize = 15; TagsToolTip.Text = t; } } // display description if (!currentReport.isDescriptionReady()) { DescriptionToolTip.FontSize = 20; DescriptionToolTip.Text = "No description"; } else { String desc = currentReport.getDescription(); if (desc.Length == 0) { DescriptionToolTip.FontSize = 20; DescriptionToolTip.Text = "No description"; currentReport.setDescriptionNotReady(); } else { // need to parse out trailing whitespace DescriptionToolTip.FontSize = 15; DescriptionToolTip.Text = desc.Trim(); } } }
public void SetDescriptionTest() { Report r = new Report(); r.setDescription("A Description"); Assert.AreEqual(r.isDescriptionReady(), true); }
private async Task DisplayReportContent() { string fileContent; using (StreamReader s = new StreamReader(await currentReportFile.OpenStreamForReadAsync())) { fileContent = await s.ReadToEndAsync(); s.Dispose(); } //Report currReport = new Report(fileContent); currentReport = await Report.GenerateFromString(fileContent); PageTitle.Text = currentReport.getReportName(); imagePreview.Source = new BitmapImage(new Uri(currentReport.getImage().Path)); GeolocationToolTip.FontSize = 15; GeolocationToolTip.Text = "Latitude: " + currentReport.getLatitude() + "\n\nLongitude: " + currentReport.getLongitude(); if (!currentReport.isTagsReady()) { TagsToolTip.FontSize = 20; TagsToolTip.Text = "No tags"; } else { // display as much selected tags String t = ""; int NoOfTags = currentReport.getTags().Count; if (NoOfTags == 0) { TagsToolTip.FontSize = 20; TagsToolTip.Text = "No tags"; currentReport.setTagsNotReady(); } else { int TagCount = 0; int TagLimit = 8; int LineCount = 0; int LineLimit = 3; foreach (String element in currentReport.getTags()) { // if we've displayed 6 tags if (TagCount >= TagLimit) { break; } // if we've got two tags on a line if (!(LineCount < LineLimit)) { t += "\n"; LineCount = 0; } // append tag t += "#" + element + ", "; LineCount++; TagCount++; } // remove extra comma t = t.Substring(0, t.Length - 2); // if user selected more than 6 tags, add a ... if (NoOfTags > TagLimit) { t += "..."; } // display tags TagsToolTip.FontSize = 15; TagsToolTip.Text = t; } } // display description if (!currentReport.isDescriptionReady()) { DescriptionToolTip.FontSize = 20; DescriptionToolTip.Text = "No description"; } else { String desc = currentReport.getDescription(); if (desc.Length == 0) { DescriptionToolTip.FontSize = 20; DescriptionToolTip.Text = "No description"; currentReport.setDescriptionNotReady(); } else { // need to parse out trailing whitespace DescriptionToolTip.FontSize = 15; DescriptionToolTip.Text = desc.Trim(); } } }
/** * Updates the Current Pollution Report by checking if certain fields have been filled in. * If they are not, their section within the page remains as the pre-programmed message. * For Tags and Description sections, the option of removing the entered information is possible. * Hence, we need this update. */ public void UpdatePollutionReport() { // display image if (report.getImage() == null) { ImageToolTip.Text = "Take a photo"; } else { ImageToolTip.Text = ""; imagePreview.Source = new BitmapImage(new Uri(report.getImage().Path)); } // display geolocation if (!report.isGeolocationReady()) { if (report.getImage() == null) { GeolocationToolTip.FontSize = 20; GeolocationToolTip.Text = "Awaiting photo"; } else { GeolocationToolTip.FontSize = 20; GeolocationToolTip.Text = "Finding coordinates..."; // if we've got an image, start async method that // sends request to report class every 10s to see if // geolocation is ready to be displayed on UI checkGeolocation(); } } else { GeolocationToolTip.FontSize = 15; GeolocationToolTip.Text = "Latitude: " + report.getLatitude() + "\n\nLongitude: " + report.getLongitude(); } // display tags if (!report.isTagsReady()) { TagsToolTip.FontSize = 20; TagsToolTip.Text = "Select tags"; } else { // display as much selected tags String t = ""; int NoOfTags = report.getTags().Count; if (NoOfTags == 0) { TagsToolTip.FontSize = 20; TagsToolTip.Text = "Select tags"; report.setTagsNotReady(); } else { int TagCount = 0; int TagLimit = 6; int LineCount = 0; int LineLimit = 2; foreach (String element in report.getTags()) { // if we've displayed 6 tags if (TagCount >= TagLimit) { break; } // if we've got two tags on a line if (!(LineCount < LineLimit)) { t += "\n"; LineCount = 0; } // append tag t += "#" + element + ", "; LineCount++; TagCount++; } // remove extra comma t = t.Substring(0, t.Length - 2); Debug.WriteLine(t); // if user selected more than 6 tags, add a ... if (NoOfTags > 6) { t += "..."; } // display tags TagsToolTip.FontSize = 15; TagsToolTip.Text = t; } } // display description if (!report.isDescriptionReady()) { DescriptionToolTip.FontSize = 20; DescriptionToolTip.Text = "Add description"; } else { String desc = report.getDescription(); if (desc.Length == 0) { DescriptionToolTip.FontSize = 20; DescriptionToolTip.Text = "Add description"; report.setDescriptionNotReady(); } else { // need to parse out trailing whitespace DescriptionToolTip.FontSize = 15; DescriptionToolTip.Text = desc.Trim(); } } // if report is complete, we need to compact the grids and display submit button if (report.isReportReady()) { if (UIReadyToSend == false) { UIReadyToSend = true; Debug.WriteLine("Report is now ready to send"); animateReadyToSend(); } } else { if (UIReadyToSend == true) { UIReadyToSend = false; Debug.WriteLine("Report is now not ready to send"); animateNotReadyToSend(); } } }