Beispiel #1
0
        public FlowDocument GetFlowDocument()
        {
            FlowDocument doc = (FlowDocument)Application.LoadComponent(
                new Uri("/Daytimer.DatabaseHelpers;component/Templates/AppointmentTemplate.xaml",
                        UriKind.Relative));

            string subject = _appointment.FormattedSubject;

            ((Paragraph)doc.FindName("Subject")).Inlines.Add(!string.IsNullOrEmpty(subject) ? subject : "(No Subject)");
            ((Paragraph)doc.FindName("Where")).Inlines.Add(_appointment.Location);
            ((Paragraph)doc.FindName("When")).Inlines.Add(GetWhen());
            ((Paragraph)doc.FindName("ShowAs")).Inlines.Add(GetShowAs());
            ((Paragraph)doc.FindName("Recurrence")).Inlines.Add(
                _appointment.IsRepeating ? _appointment.Recurrence.ToString().Capitalize()
                                : "None");

            Section details = (Section)doc.FindName("Details");

            FlowDocument detailsDoc = _appointment.DetailsDocument;

            if (detailsDoc != null)
            {
                BlockCollection blocks = detailsDoc.Copy().Blocks;

                while (blocks.Count > 0)
                {
                    details.Blocks.Add(blocks.FirstBlock);
                }
            }

            return(doc);
        }