private async Task refreshReportList() { reportItems.Clear(); reports.Clear(); StorageFolder unsentReportFolder = await ApplicationData.Current.LocalFolder.CreateFolderAsync("Unsent_Reports", CreationCollisionOption.OpenIfExists); reportFiles = await unsentReportFolder.GetFilesAsync(); for (int i = 0; i < reportFiles.Count; i++) { //Read file, split itno info bits. StorageFile currFile = reportFiles.ElementAt(i); string fileContent; using (StreamReader s = new StreamReader(await currFile.OpenStreamForReadAsync())) { fileContent = await s.ReadToEndAsync(); s.Dispose(); } Debug.WriteLine(fileContent + "\n"); //Report currReport = new Report(fileContent); Report currReport = await Report.GenerateFromString(fileContent); //string[] reportComponents = fileContent.Split(new String[]{":~:"},StringSplitOptions.None); //create preview //image block preview Image previewImage = new Image(); previewImage.Source = new BitmapImage(new Uri(currReport.getImage().Path)); previewImage.HorizontalAlignment = HorizontalAlignment.Left; previewImage.Stretch = Stretch.UniformToFill; previewImage.Margin = new Thickness(5, 5, 5, 5); //List View Item (outer wrapper) ListViewItem currFileItem = new ListViewItem(); currFileItem.Name = currFile.Name; currFileItem.Background = new SolidColorBrush(itemBackground); currFileItem.Content = previewImage; currFileItem.Height = 100; currFileItem.Margin = new Thickness(0, 5, 0, 5); currFileItem.Tapped += currFileItem_Tapped; reports.Add(currReport); reportItems.Add(currFileItem); } UnsentReportList.ItemsSource = reportItems; }
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(); } } }