예제 #1
0
        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();
                }
            }
        }
        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();
                }
            }
        }