// create and preview daily style
 private void day_Click(object sender, RoutedEventArgs e)
 {
     Utils.MakeDay(_printDoc);
     _printDoc.Save("day.c1d");
     // clear and re-load to be sure that all works when document is loaded from file
     _printDoc.Clear();
     _printDoc.Load("day.c1d");
     Preview();
 }
Exemplo n.º 2
0
        private void MakeDoc1(C1PrintDocument doc)
        {
            doc.Clear();

            RenderText rtxt = new RenderText(doc);

            rtxt.Text = "This test demonstrates multiple inheritance of styles in tables. " +
                        "In the table below, the font is redefined for row 4. " +
                        "Then, the text color is redefined for column 1. " +
                        "Finally, a cell group is defined containing cells in rows 4 to 6, cols 1 & 2, " +
                        "and background color is redefined for that cell group. " +
                        "\nThe cell at the intersection of row 4 and col 1 combines all 3 styles.\n\n";
            doc.Body.Children.Add(rtxt);

            doc.Style.Font = new Font("Arial", 12, FontStyle.Regular);

            const int ROWS = 12;
            const int COLS = 6;

            RenderTable rt = new RenderTable(doc);

            rt.Style.Padding.All = new Unit("4mm");
            for (int row = 0; row < ROWS; ++row)
            {
                for (int col = 0; col < COLS; ++col)
                {
                    RenderText celltext = new RenderText(doc);
                    celltext.Text = string.Format("Cell ({0},{1})", row, col);
                    rt.Cells[row, col].RenderObject = celltext;
                }
            }
            // add the table to the document
            doc.Body.Children.Add(rt);

            // set up table style
            rt.Style.GridLines.All  = new LineDef("2pt", Color.Black);
            rt.Style.GridLines.Horz = new LineDef("1pt", Color.Gray);
            rt.Style.GridLines.Vert = new LineDef("1pt", Color.Gray);

            // define a row style
            rt.Rows[4].Style.Font = new Font("Arial", 12, FontStyle.Bold | FontStyle.Italic);

            // define a column style
            rt.Cols[1].Style.TextColor = Color.DarkOrange;

            // define a cell group with a background color
            rt.UserCellGroups.Add(new UserCellGroup(new Rectangle(1, 4, 2, 3)));
            rt.UserCellGroups[0].Style.BackColor = Color.PaleGreen;
        }
        /// <summary>
        /// Loads style definition to the specified C1PrintDocument control.
        /// </summary>
        /// <param name="printDoc">The <see cref="PrintDocumentWrapper"/> object.</param>
        /// <returns>Returns true at successful loading; false - otherwise.</returns>
        public bool Load(C1PrintDocument printDoc)
        {
            if (String.IsNullOrEmpty(StyleSource))
            {
                return(false);
            }
            printDoc.Clear();

            // load document
            Stream sr = ResourceLoader.GetStream(StyleSource);

            if (sr != null)
            {
                printDoc.Load(sr, DocumentFormat);
                sr.Dispose();
            }
            else
            {
                printDoc.Load(StyleSource, DocumentFormat);
            }

            if (String.IsNullOrEmpty(StyleName))
            {
                // fill name and description from document
                StyleName = (string)printDoc.DocumentInfo.Title;
                if (String.IsNullOrEmpty(StyleName))
                {
                    StyleName = _owner.GetUniqueStyleName();
                }
            }
            if (String.IsNullOrEmpty(_description))
            {
                _description = (string)printDoc.DocumentInfo.Subject;
            }
            return(true);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Fills a C1MultiDocument or a C1PrintDocument passed to it with listings of
        /// all files in the specified directory and its subdirectories matching the specified mask.
        /// </summary>
        /// <param name="theDoc">A C1MultiDocument or a C1PrintDocument.</param>
        /// <param name="dir">Directory containing the files to list.</param>
        /// <param name="mask">The files mask (e.g. "*.cs").</param>
        /// <param name="pf">Progress form.</param>
        public void MakeMultiDocument(object theDoc, string dir, string mask, ProgressForm pf)
        {
            // Find out what kind of document we're creating:
            _mdoc = theDoc as C1MultiDocument;
            _sdoc = theDoc as C1PrintDocument;
            if (_mdoc == null && _sdoc == null)
            {
                throw new Exception("Unsupported document type.");
            }

            _dir  = Path.GetFullPath(dir);
            _mask = mask;

            // Set up the document:
            if (_mdoc != null)
            {
                _mdoc.Clear();
                _mdoc.DoEvents = true;
            }
            else
            {
                _sdoc.Clear();
                _sdoc.DoEvents = true;
                SetupDoc(_sdoc);
            }

            // Show initial progress:
            pf.SetProgress(string.Format("Reading {0}...", _dir), 0);

            // For progress indicator only - get the list of all subdirectories:
            // long allDirsCount = Directory.GetDirectories(_dir, "*", SearchOption.AllDirectories).LongLength;
            // long allDirsIdx = 0;

            // Create TOC render object that will list directories and files:
            RenderToc toc = new RenderToc();

            // Add a TOC directory entry in "directory added" event:
            DirAdded += (doc, dirRo, dirName, level) =>
            {
                C1Anchor aDir = new C1Anchor(string.Format("d{0}", dirName.GetHashCode()));
                dirRo.Anchors.Add(aDir);

                // Add a TOC item for the directory (full name for root dir, own name for subdirs):
                string        tocName = dirName == _dir ? dirName : Path.GetFileName(dirName);
                RenderTocItem rti     = toc.AddItem(tocName, new C1Hyperlink(new C1LinkTargetAnchor(aDir.Name)), level);
                // Bold directory TOC entries:
                rti.Style.FontBold = true;
                // duplicate TOC entry in OUTLINE:
                OutlineNode outlineNode = new OutlineNode(dirName, dirRo);
                doc.Outlines.Add(outlineNode); // in this mode, all directory nodes are top-level

                // update overall progress:
                pf.SetProgress(string.Format("Reading {0}...", dirName));
                if (pf.Cancelled)
                {
                    throw new Exception("Directory scan aborted.");
                }

                return(outlineNode);
            };

            // Add a TOC file entry in "file added" event:
            FileAdded += (doc, dirOutlineNode, fileRo, fileName, level) =>
            {
                C1Anchor aFile = new C1Anchor(string.Format("f{0}", fileName.GetHashCode()));
                fileRo.Anchors.Add(aFile);
                string tocItemName = Path.GetFileName(fileName);
                toc.AddItem(tocItemName, new C1Hyperlink(new C1LinkTargetAnchor(aFile.Name)), level);
                // duplicate TOC entry in OUTLINE:
                if (dirOutlineNode == null)
                {
                    doc.Outlines.Add(tocItemName, fileRo); // top-level entry
                }
                else
                {
                    dirOutlineNode.Children.Add(tocItemName, fileRo); // nested entry
                }
            };

            // Create the common index:
            RenderIndex index = new RenderIndex();
            // Init keywords:
            Dictionary <string, IndexEntry> indexEntries = new Dictionary <string, IndexEntry>();

            // For this sample, we will build an index of all KnownColor names:
            string[] colorNames = Enum.GetNames(typeof(KnownColor));
            foreach (string keyword in colorNames)
            {
                indexEntries.Add(keyword, new IndexEntry(keyword));
            }

            // Add an index entry for each key word in line:
            LineAdded += (lineRo, fileName, line, lineNo) =>
            {
                var      words = line.Split(s_delims, StringSplitOptions.RemoveEmptyEntries);
                C1Anchor a     = null;
                foreach (string word in words)
                {
                    if (indexEntries.ContainsKey(word))
                    {
                        if (a == null)
                        {
                            a = new C1Anchor(string.Format("k{0}{1}", fileName.GetHashCode(), lineNo));
                            lineRo.Anchors.Add(a);
                        }
                        indexEntries[word].Occurrences.Add(new IndexEntryOccurrence(new C1LinkTargetAnchor(a.Name)));
                    }
                }
            };


            // Add listings of files to the document:
            ListDir(_dir, 1);

            // insert TOC at the top:
            RenderText tocHeader = new RenderText("Table of Contents");

            tocHeader.Style.Spacing.Bottom = "3mm";
            tocHeader.Style.TextAlignHorz  = AlignHorzEnum.Center;
            tocHeader.Style.FontSize       = 12;
            tocHeader.Style.FontBold       = true;
            if (_mdoc != null)
            {
                C1PrintDocument docToc = new C1PrintDocument();
                docToc.Body.Children.Add(tocHeader);
                docToc.Body.Children.Add(toc);
                _mdoc.Items.Insert(0, docToc);
                docToc = null;
                GC.Collect();
                GC.WaitForPendingFinalizers();
            }
            else
            {
                toc.BreakAfter = BreakEnum.Page;
                _sdoc.Body.Children.Insert(0, toc);
                _sdoc.Body.Children.Insert(0, tocHeader);
            }

            // insert word index at the bottom:
            RenderText indexHeader = new RenderText("Index of Known Colors");

            indexHeader.Style.Spacing.Bottom = "3mm";
            indexHeader.Style.TextAlignHorz  = AlignHorzEnum.Center;
            indexHeader.Style.FontSize       = 12;
            indexHeader.Style.FontBold       = true;
            index.HeadingStyle.FontSize     += 1;
            index.HeadingStyle.FontBold      = true;
            index.HeadingStyle.Padding.All   = "2mm";
            // add index entries that have some occurrences:
            foreach (IndexEntry ie in indexEntries.Values)
            {
                if (ie.HasOccurrences)
                {
                    index.Entries.Add(ie);
                }
            }
            if (_mdoc != null)
            {
                C1PrintDocument docIndex = new C1PrintDocument();
                docIndex.Body.Children.Add(indexHeader);
                docIndex.Body.Children.Add(index);
                _mdoc.Items.Add(docIndex);
                docIndex = null;
                GC.Collect();
                GC.WaitForPendingFinalizers();
            }
            else
            {
                indexHeader.BreakBefore = BreakEnum.Page;
                _sdoc.Body.Children.Add(indexHeader);
                _sdoc.Body.Children.Add(index);
            }

            // we're done!
            pf.SetProgress(string.Format("Reading {0}...", _dir), 1);
        }
Exemplo n.º 5
0
        private void MakeDoc1(C1PrintDocument doc)
        {
            doc.Clear();

            RenderText rtxt = new RenderText();

            rtxt.Text = "This sample demonstrates horizontal (extended) pages, which allow to " +
                        "render wide objects (for example, tables with many columns) on separate pages that can " +
                        "be \"glued\" side to side.";
            // set the width of the text to 3 times the width of the page
            rtxt.Width = "page*3";
            // allow it to span horizontal pages:
            rtxt.SplitHorzBehavior = SplitBehaviorEnum.SplitIfNeeded;
            // add padding
            rtxt.Style.Padding.All    = "2mm";
            rtxt.Style.Padding.Bottom = "5mm";
            /// add text to the document
            doc.Body.Children.Add(rtxt);

            doc.Style.Font = new Font("Arial", 12, FontStyle.Regular);

            const int ROWS = 63;
            const int COLS = 8;

            // make the table
            RenderTable rt = new RenderTable();

            // for tables, "auto" width means that the width of the table
            // will be equal to the widths of all columns, so we MUST also
            // set the columns' widths.
            rt.Width = "auto";
            for (int col = 0; col < COLS; ++col)
            {
                rt.Cols[col].Width = "5cm";
            }

            // we want the last column on page to stretch to the right edge of the page,
            // so that there is no white space left before the margin
            rt.StretchColumns = StretchTableEnum.LastVectorOnPage;
            // for the rightmost column, we turn stretching off:
            rt.Cols[rt.Cols.Count - 1].Stretch = StretchColumnEnum.No;
            // tell the table that it can split horizontally,
            // otherwise the right part of the table will be clipped:
            rt.SplitHorzBehavior = SplitBehaviorEnum.SplitIfNeeded;


            // fill table with sample data
            for (int row = 0; row < ROWS; ++row)
            {
                for (int col = 0; col < COLS; ++col)
                {
                    rt.Cells[row, col].Text = string.Format("Cell ({0}, {1})", row, col);
                }
            }

            // add the table to the document
            doc.Body.Children.Add(rt);

            // set up table style
            rt.Style.GridLines.All  = new LineDef("2pt", Color.Black);
            rt.Style.GridLines.Horz = new LineDef("1pt", Color.Gray);
            rt.Style.GridLines.Vert = new LineDef("1pt", Color.Gray);

            // add some comments at the bottom
            rtxt      = new RenderText();
            rtxt.Text = "Note also that the preview supports such documents by showing " +
                        "the pages side by side rather than one below the other.";
            // set the width of the text to the width of the preceding sibling (i.e. the table):
            rtxt.Width = "prev.width";
            // allow it to span horizontal pages:
            rtxt.SplitHorzBehavior = SplitBehaviorEnum.SplitIfNeeded;
            // add padding
            rtxt.Style.Padding.All = "2mm";
            rtxt.Style.Padding.Top = "5mm";
            // add the text to the document
            doc.Body.Children.Add(rtxt);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Fills specified control with a Memo style.
        /// </summary>
        /// <param name="doc"></param>
        public static void MakeMemo(C1PrintDocument doc)
        {
            doc.Clear();

            doc.DocumentInfo.Title = "Memo style";
            doc.DocumentInfo.Subject = "Memo";

            AddNamespaces(doc);

            AddHeadersFooters(doc);
            doc.Tags["AppointmentsFont"].Value = new Font("Arial", 10);

            // add string tags (localizable)

            Tag newTag = new Tag("Subject", "Subject:", typeof(string));
            newTag.ShowInDialog = false;
            doc.Tags.Add(newTag);

            newTag = new Tag("Location", "Location:", typeof(string));
            newTag.ShowInDialog = false;
            doc.Tags.Add(newTag);
            newTag = new Tag("Start", "Start:", typeof(string));
            newTag.ShowInDialog = false;
            doc.Tags.Add(newTag);

            newTag = new Tag("End", "End:", typeof(string));
            newTag.ShowInDialog = false;
            doc.Tags.Add(newTag);

            newTag = new Tag("ShowTimeAs", "Show Time As:", typeof(string));
            newTag.ShowInDialog = false;
            doc.Tags.Add(newTag);

            newTag = new Tag("Recurrence", "Recurrence:", typeof(string));
            newTag.ShowInDialog = false;
            doc.Tags.Add(newTag);

            newTag = new Tag("None", "none", typeof(string));
            newTag.ShowInDialog = false;
            doc.Tags.Add(newTag);

            newTag = new Tag("Categories", "Categories:", typeof(string));
            newTag.ShowInDialog = false;
            doc.Tags.Add(newTag);

            newTag = new Tag("Resources", "Resources:", typeof(string));
            newTag.ShowInDialog = false;
            doc.Tags.Add(newTag);

            newTag = new Tag("Contacts", "Contacts:", typeof(string));
            newTag.ShowInDialog = false;
            doc.Tags.Add(newTag);

            newTag = new Tag("Importance", "Importance:", typeof(string));
            newTag.ShowInDialog = false;
            doc.Tags.Add(newTag);

            RenderArea ra = new RenderArea();
            ra.Width = "100%";
            ra.BreakBefore = BreakEnum.Page;
            ra.DataBinding.DataSource = new Expression("Document.Tags!Appointments.Value");
            ra.DataBinding.Sorting.Expressions.Add("Fields!Start.Value");
            ra.DataBinding.Sorting.Expressions.Add("Fields!Subject.Value");
            ra.Style.Borders.Top = LineDef.DefaultBold;
            ra.Stacking = StackingRulesEnum.InlineLeftToRight;
            ra.Style.Padding.Top = "1mm";
            ra.Style.Spacing.All = "1mm";

            RenderText rt = new RenderText();
            rt.FormatDataBindingInstanceScript = //VisibilityEnum
                "RenderObject.Visibility = IIf(Not String.IsNullOrEmpty(RenderObject.Parent.Original.DataBinding.Fields!Subject.Value), VisibilityEnum.Visible, VisibilityEnum.Collapse)";
            rt.Text = "[Document.Tags!Subject.Value]";
            rt.Width = "25%";
            rt.Style.FontBold = true;
            ra.Children.Add(rt);

            rt = new RenderText();
            rt.FormatDataBindingInstanceScript =
                "RenderObject.Visibility = IIf(Not String.IsNullOrEmpty(RenderObject.Parent.Original.DataBinding.Fields!Subject.Value), VisibilityEnum.Visible, VisibilityEnum.Collapse)";
            rt.Text = "[Fields!Subject.Value]";
            rt.Width = "75%";
            ra.Children.Add(rt);

            rt = new RenderText();
            rt.FormatDataBindingInstanceScript =
                "RenderObject.Visibility = IIf(Not String.IsNullOrEmpty(RenderObject.Parent.Original.DataBinding.Fields!Location.Value), VisibilityEnum.Visible, VisibilityEnum.Collapse)";
            rt.Text = "[Document.Tags!Location.Value]";
            rt.Width = "25%";
            rt.Style.FontBold = true;
            ra.Children.Add(rt);

            rt = new RenderText();
            rt.FormatDataBindingInstanceScript =
                "RenderObject.Visibility = IIf(Not String.IsNullOrEmpty(RenderObject.Parent.Original.DataBinding.Fields!Location.Value), VisibilityEnum.Visible, VisibilityEnum.Collapse)";
            rt.Text = "[Fields!Location.Value]";
            rt.Width = "75%";
            ra.Children.Add(rt);

            rt = new RenderText();
            rt.Text = "[Document.Tags!Start.Value]";
            rt.Width = "25%";
            rt.Style.Padding.Top = "2mm";
            rt.Style.FontBold = true;
            ra.Children.Add(rt);

            rt = new RenderText();
            rt.Text = "[String.Format(Document.Tags!CalendarInfo.Value.CultureInfo, \"{0:ddd} {1:g}\", Fields!Start.Value, Fields!Start.Value)]";
            rt.Width = "75%";
            rt.Style.Padding.Top = "2mm";
            ra.Children.Add(rt);

            rt = new RenderText();
            rt.Text = "[Document.Tags!End.Value]";
            rt.Width = "25%";
            rt.Style.FontBold = true;
            ra.Children.Add(rt);

            rt = new RenderText();
            rt.Text = "[String.Format(Document.Tags!CalendarInfo.Value.CultureInfo, \"{0:ddd} {1:g}\", Fields!End.Value, Fields!End.Value)]";
            rt.Width = "75%";
            ra.Children.Add(rt);

            rt = new RenderText();
            rt.Text = "[Document.Tags!ShowTimeAs.Value]";
            rt.Width = "25%";
            rt.Style.FontBold = true;
            ra.Children.Add(rt);

            rt = new RenderText();
            rt.Text = "[Fields!BusyStatus.Value.Text]";
            rt.Width = "75%";
            ra.Children.Add(rt);

            rt = new RenderText();
            rt.Text = "[Document.Tags!Recurrence.Value]";
            rt.Width = "25%";
            rt.Style.Padding.Top = "2mm";
            rt.Style.FontBold = true;
            ra.Children.Add(rt);

            rt = new RenderText();
            rt.FormatDataBindingInstanceScript =
                "Dim index as Integer = RenderObject.Parent.Original.DataBinding.RowNumber - 1 \r\n" +
                "Dim app As Appointment = Document.Tags!Appointments.Value(index)\r\n" +
                "Dim text As RenderText = RenderObject\r\n" +
                "If app.RecurrenceState <> RecurrenceStateEnum.NotRecurring Then\r\n" +
                "    text.Text = app.GetRecurrencePattern().Description\r\n" +
                "Else\r\n" +
                "    text.Text = Document.Tags!None.Value\r\n" +
                "End If";
            rt.Style.Padding.Top = "2mm";
            rt.Width = "75%";
            ra.Children.Add(rt);

            rt = new RenderText();
            rt.FormatDataBindingInstanceScript =
                "RenderObject.Visibility = IIf((Not (RenderObject.Parent.Original.DataBinding.Fields!Links.Value Is Nothing)) And RenderObject.Parent.Original.DataBinding.Fields!Links.Value.Count > 0, VisibilityEnum.Visible, VisibilityEnum.Collapse)";
            rt.Text = "[Document.Tags!Contacts.Value]";
            rt.Style.Padding.Top = "2mm";
            rt.Width = "25%";
            rt.Style.FontBold = true;
            ra.Children.Add(rt);

            rt = new RenderText();
            rt.FormatDataBindingInstanceScript =
                "RenderObject.Visibility = IIf((Not (RenderObject.Parent.Original.DataBinding.Fields!Links.Value Is Nothing)) And RenderObject.Parent.Original.DataBinding.Fields!Links.Value.Count > 0, VisibilityEnum.Visible, VisibilityEnum.Collapse)";
            rt.Text = "[Fields!Links.Value.ToString()]";
            rt.Style.Padding.Top = "2mm";
            rt.Width = "75%";
            ra.Children.Add(rt);

            rt = new RenderText();
            rt.FormatDataBindingInstanceScript =
                "RenderObject.Visibility = IIf((Not (RenderObject.Parent.Original.DataBinding.Fields!Categories.Value Is Nothing)) And RenderObject.Parent.Original.DataBinding.Fields!Categories.Value.Count > 0, VisibilityEnum.Visible, VisibilityEnum.Collapse)";
            rt.Text = "[Document.Tags!Categories.Value]";
            rt.Style.Padding.Top = "2mm";
            rt.Width = "25%";
            rt.Style.FontBold = true;
            ra.Children.Add(rt);

            rt = new RenderText();
            rt.FormatDataBindingInstanceScript =
                "RenderObject.Visibility = IIf((Not (RenderObject.Parent.Original.DataBinding.Fields!Categories.Value Is Nothing)) And RenderObject.Parent.Original.DataBinding.Fields!Categories.Value.Count > 0, VisibilityEnum.Visible, VisibilityEnum.Collapse)";
            rt.Text = "[Fields!Categories.Value.ToString()]";
            rt.Style.Padding.Top = "2mm";
            rt.Width = "75%";
            ra.Children.Add(rt);

            rt = new RenderText();
            rt.FormatDataBindingInstanceScript =
                "RenderObject.Visibility = IIf((Not (RenderObject.Parent.Original.DataBinding.Fields!Resources.Value Is Nothing)) And RenderObject.Parent.Original.DataBinding.Fields!Resources.Value.Count > 0, VisibilityEnum.Visible, VisibilityEnum.Collapse)";
            rt.Text = "[Document.Tags!Resources.Value]";
            rt.Width = "25%";
            rt.Style.Padding.Top = "2mm";
            rt.Style.FontBold = true;
            ra.Children.Add(rt);

            rt = new RenderText();
            rt.FormatDataBindingInstanceScript =
                "RenderObject.Visibility = IIf((Not (RenderObject.Parent.Original.DataBinding.Fields!Resources.Value Is Nothing)) And RenderObject.Parent.Original.DataBinding.Fields!Resources.Value.Count > 0, VisibilityEnum.Visible, VisibilityEnum.Collapse)";
            rt.Text = "[Fields!Resources.Value.ToString()]";
            rt.Style.Padding.Top = "2mm";
            rt.Width = "75%";
            ra.Children.Add(rt);

            rt = new RenderText();
            rt.FormatDataBindingInstanceScript =
                "RenderObject.Visibility = IIf(Not (RenderObject.Parent.Original.DataBinding.Fields!Importance.Value = 1), VisibilityEnum.Visible, VisibilityEnum.Collapse)";
            rt.Text = "[Document.Tags!Importance.Value]";
            rt.Style.Padding.Top = "2mm";
            rt.Width = "25%";
            rt.Style.FontBold = true;
            ra.Children.Add(rt);

            rt = new RenderText();
            rt.FormatDataBindingInstanceScript =
                "RenderObject.Visibility = IIf(Not (RenderObject.Parent.Original.DataBinding.Fields!Importance.Value = 1), VisibilityEnum.Visible, VisibilityEnum.Collapse)";
            rt.Style.Padding.Top = "2mm";
            rt.Text = "[Fields!Importance.Value.ToString()]";
            rt.Width = "75%";
            ra.Children.Add(rt);

            rt = new RenderText();
            rt.Text = "[Fields!Body.Value.ToString()]";
            rt.Style.Padding.Top = "3mm";
            rt.Style.Padding.Right = "2mm";
            rt.Width = "100%";
            ra.Children.Add(rt);

            doc.Body.Children.Add(ra);

            AddCommonTags(doc);

            newTag = new Tag("Appointments", null, typeof(IList<Appointment>));
            newTag.ShowInDialog = false;
            newTag.SerializeValue = false;
            doc.Tags.Add(newTag);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Fills specified control with a Month style.
        /// </summary>
        /// <param name="doc"></param>
        public static void MakeMonth(C1PrintDocument doc)
        {
            doc.Clear();

            doc.DocumentInfo.Title = "Monthly style";
            doc.DocumentInfo.Subject = "Month";
            AddNamespaces(doc);

            AddHeadersFooters(doc);
            doc.PageLayout.PageSettings.Landscape = true;
            doc.Tags["FooterRight"].Value = "[GeneratedDateTime]";
            doc.Tags["DateHeadingsFont"].Value = new Font("Segoe UI", 20, FontStyle.Bold);

            doc.DocumentStartingScript +=
                "Dim daysNumber As Long = 7.0 \r\n" +
                "If Document.Tags!WorkDaysOnly.Value Then\r\n" +
                "   daysNumber = Document.Tags!CalendarInfo.Value.WorkDays.Count \r\n" +
                "End If\r\n" +
                "Document.Tags!DayWidth.Value = New Unit((97.3/daysNumber - 0.005).ToString(\"#.###\", System.Globalization.CultureInfo.InvariantCulture) & \"%\") \r\n" +
                "Dim tasksNumber As Integer = 0 \r\n" +
                "If Document.Tags!IncludeTasks.Value Then\r\n" +
                "   tasksNumber = tasksNumber + 1 \r\n" +
                "End If\r\n" +
                "If Document.Tags!IncludeBlankNotes.Value Then\r\n" +
                "   tasksNumber = tasksNumber + 1 \r\n" +
                "End If\r\n" +
                "If Document.Tags!IncludeLinedNotes.Value Then\r\n" +
                "   tasksNumber = tasksNumber + 1 \r\n" +
                "End If\r\n" +
                "If tasksNumber = 1 Then\r\n" +
                "   Document.Tags!TaskHeight.Value = New Unit(\"100%\")\r\n" +
                "ElseIf tasksNumber = 2 Then\r\n" +
                "   Document.Tags!TaskHeight.Value = New Unit(\"50%\")\r\n" +
                "Else\r\n" +
                "   Document.Tags!TaskHeight.Value = New Unit(\"33.3%\")\r\n" +
                "End If\r\n" +
                "Dim startT As DateTime = Tags!StartDate.Value  \r\n" +
                "Dim endT As DateTime = Tags!EndDate.Value  \r\n" +
                "While startT.DayOfWeek <> Tags!CalendarInfo.Value.WeekStart \r\n" +
                "    startT = startT.AddDays(-1)\r\n" +
                "End While\r\n" +
                "Dim days As Long = DateDiff(DateInterval.Day, startT, endT )\r\n" +
                "endT = endT.AddDays(35 - (days Mod 35))\r\n" +
                "Dim months As New List(Of Date)\r\n" +
                "Dim s As DateTime = startT\r\n" +
                "While s < endT\r\n" +
                "	months.Add(s)\r\n" +
                "   s = s.AddDays(35)\r\n" +
                "End While\r\n" +
                "If Tags.IndexByName(\"Months\") = -1 Then\r\n" +
                "   Dim tagMonths As Tag\r\n" +
                "   tagMonths = New Tag(\"Months\", months)\r\n" +
                "   tagMonths.SerializeValue = False\r\n" +
                "   Tags.Add(tagMonths)\r\n" +
                "Else\r\n" +
                "   Tags!Months.Value = months\r\n" +
                "End If\r\n" +
                "\r\n" +
                "Dim dateAppointments As New DateAppointmentsCollection(startT, endT, Tags!Appointments.Value, Tags!CalendarInfo.Value, True, Not Tags!WorkDaysOnly.Value)\r\n" +
                "If Tags.IndexByName(\"DateAppointments\") = -1 Then\r\n" +
                "   Dim tagApps As Tag\r\n" +
                "   tagApps = New Tag(\"DateAppointments\", dateAppointments)\r\n" +
                "   tagApps.SerializeValue = False\r\n" +
                "   Tags.Add(tagApps)\r\n" +
                "Else\r\n" +
                "   Tags!DateAppointments.Value = dateAppointments\r\n" +
                "End If\r\n";

            // RenderArea representing the single page
            RenderArea raPage = new RenderArea();
            raPage.DataBinding.DataSource = new Expression("Document.Tags!Months.Value");
            raPage.DataBinding.Sorting.Expressions.Add("Fields!Date.Value");
            raPage.BreakBefore = BreakEnum.Page;
            raPage.Width = "100%";
            raPage.Height = "100%";
            raPage.Stacking = StackingRulesEnum.InlineLeftToRight;

            #region ** month header
            // month header
            RenderArea raMonthHeader = new RenderArea();
            raMonthHeader.Style.Borders.All = LineDef.Default;
            raMonthHeader.Width = "100%";
            raMonthHeader.Height = "28mm";
            raMonthHeader.Stacking = StackingRulesEnum.InlineLeftToRight;

            RenderText rt = new RenderText();
            rt.FormatDataBindingInstanceScript =
                "RenderObject.Style.Font = Document.Tags!DateHeadingsFont.Value\r\n" +
                "Dim rt As RenderText = RenderObject\r\n" +
                "Dim startDate As Date = RenderObject.Original.Parent.Parent.DataBinding.Fields!Date.Value\r\n" +
                "Dim endDate As Date = startDate.AddDays(34)\r\n" +
                "Dim txt As String = startDate.ToString(\"MMMM\", Document.Tags!CalendarInfo.Value.CultureInfo)\r\n" +
                "If startDate.Year <> endDate.Year Then\r\n" +
                "    txt = txt & \" \" & startDate.ToString(\"yyy\", Document.Tags!CalendarInfo.Value.CultureInfo)\r\n" +
                "End If\r\n" +
                "txt = txt & \" - \" & endDate.ToString(\"MMMM yyy\", Document.Tags!CalendarInfo.Value.CultureInfo)\r\n" +
                "rt.Text = txt\r\n" +
                "Document.Tags!WeekTabs.Value = New List(of Date)\r\n" +
                "Document.Tags!WeekTabs.Value.Add(startDate)\r\n" +
                "Document.Tags!WeekTabs.Value.Add(startDate.AddDays(7))\r\n" +
                "Document.Tags!WeekTabs.Value.Add(startDate.AddDays(14))\r\n" +
                "Document.Tags!WeekTabs.Value.Add(startDate.AddDays(21))\r\n" +
                "Document.Tags!WeekTabs.Value.Add(startDate.AddDays(28))\r\n" +
                "Document.Tags!MonthCalendars.Value = New List(of Date)\r\n" +
                "startDate = New Date(startDate.Year, startDate.Month, 1)\r\n" +
                "While startDate <= endDate\r\n" +
                "	Document.Tags!MonthCalendars.Value.Add(startDate)\r\n" +
                "	startDate = startDate.AddMonths(1)\r\n" +
                "End While";
            rt.Style.TextAlignVert = AlignVertEnum.Center;
            rt.Style.Spacing.Left = "2mm";
            rt.Height = "100%";
            rt.Width = "parent.Width - 102mm";

            raMonthHeader.Children.Add(rt);

            RenderArea monthCalendar = new RenderArea();
            monthCalendar.DataBinding.DataSource = new Expression("Document.Tags!MonthCalendars.Value");
            monthCalendar.Stacking = StackingRulesEnum.InlineLeftToRight;
            monthCalendar.Style.Spacing.Left = "1mm";
            monthCalendar.Style.Spacing.Right = "1mm";
            monthCalendar.Style.Spacing.Top = "0.5mm";
            monthCalendar.Width = "34mm";

            rt = new RenderText("[CDate(Fields!Date.Value).ToString(\"MMMM yyy\", Document.Tags!CalendarInfo.Value.CultureInfo)]");
            rt.FormatDataBindingInstanceScript =
                "Dim startDate As Date = RenderObject.Original.Parent.DataBinding.Fields!Date.Value\r\n" +
                "Dim endDate As Date = startDate.AddMonths(1).AddDays(-1)\r\n" +
                "While startDate.DayOfWeek <> Document.Tags!CalendarInfo.Value.WeekStart \r\n" +
                "    startDate = startDate.AddDays(-1)\r\n" +
                "End While\r\n" +
                "Document.Tags!WeekNumber.Value = New List(of Date)\r\n" +
                "While startDate <= endDate\r\n" +
                "	Document.Tags!WeekNumber.Value.Add(startDate)\r\n" +
                "	startDate = startDate.AddDays(7)\r\n" +
                "End While";
            rt.Style.TextAlignHorz = AlignHorzEnum.Center;
            rt.Style.Font = new Font("Segoe UI", 8);
            rt.Width = "100%";
            monthCalendar.Children.Add(rt);

            rt = new RenderText(" ");
            rt.Style.Font = new Font("Arial", 7f);
            rt.Style.WordWrap = false;
            rt.Width = "12.5%";
            monthCalendar.Children.Add(rt);

            rt = new RenderText("[Document.Tags!CalendarInfo.Value.CultureInfo.DateTimeFormat.GetShortestDayName(CDate(Fields!Date.Value).DayOfWeek)]");
            rt.DataBinding.DataSource = new Expression("New DateAppointmentsCollection(Document.Tags!WeekNumber.Value(0), Document.Tags!WeekNumber.Value(0).AddDays(6), Document.Tags!Appointments.Value, True)");
            rt.DataBinding.Sorting.Expressions.Add("Fields!Date.Value");
            rt.Style.Borders.Bottom = LineDef.Default;
            rt.Style.Font = new Font("Arial", 7f);
            rt.Style.TextAlignHorz = AlignHorzEnum.Center;
            rt.Style.WordWrap = false;
            rt.Width = "12.5%";
            monthCalendar.Children.Add(rt);

            RenderArea raWeek = new RenderArea();
            raWeek.DataBinding.DataSource = new Expression("Document.Tags!WeekNumber.Value");
            raWeek.Style.Font = new Font("Arial", 7f);
            raWeek.Width = "100%";
            raWeek.Stacking = StackingRulesEnum.InlineLeftToRight;

            rt = new RenderText("[Document.Tags!CalendarInfo.Value.CultureInfo.Calendar.GetWeekOfYear(CDate(Fields!Date.Value), System.Globalization.CalendarWeekRule.FirstDay, Document.Tags!CalendarInfo.Value.WeekStart)]");
            rt.Style.Borders.Right = LineDef.Default;
            rt.Style.TextAlignHorz = AlignHorzEnum.Right;
            rt.Style.WordWrap = false;
            rt.Width = "12.5%";
            raWeek.Children.Add(rt);

            rt = new RenderText("[CDate(Fields!Date.Value).ToString(\"%d\", Document.Tags!CalendarInfo.Value.CultureInfo)]");
            rt.DataBinding.DataSource = new Expression("New DateAppointmentsCollection(Parent.Fields!Date.Value, CDate(Parent.Fields!Date.Value).AddDays(6), Document.Tags!Appointments.Value, True)");
            rt.DataBinding.Sorting.Expressions.Add("Fields!Date.Value");
            rt.FormatDataBindingInstanceScript =
                "If RenderObject.Original.DataBinding.Fields!Date.Value.Month <> RenderObject.Original.Parent.Parent.DataBinding.Fields!Date.Value.Month Then\r\n" +
                "    RenderObject.Visibility = VisibilityEnum.Hidden\r\n" +
                "Else If RenderObject.Original.DataBinding.Fields!HasAppointments.Value Then\r\n" +
                "    RenderObject.Style.FontBold = true\r\n" +
                "End If";
            rt.Style.TextAlignHorz = AlignHorzEnum.Right;
            rt.Width = "12.5%";
            raWeek.Children.Add(rt);
            monthCalendar.Children.Add(raWeek);

            raMonthHeader.Children.Add(monthCalendar);

            raPage.Children.Add(raMonthHeader);
            #endregion

            #region ** month
            // month
            RenderArea raMonth = new RenderArea();
            raMonth.FormatDataBindingInstanceScript =
                "If Not (Document.Tags!IncludeTasks.Value Or Document.Tags!IncludeBlankNotes.Value Or Document.Tags!IncludeLinedNotes.Value) Then\r\n" +
                "    RenderObject.Width = \"100%\" \r\n" +
                "End If";
            raMonth.Style.Spacing.Top = "0.5mm";
            raMonth.Style.Borders.Top = LineDef.Default;
            raMonth.Style.Borders.Left = LineDef.Default;
            raMonth.Style.Borders.Bottom = LineDef.Default;
            raMonth.Width = "80%";
            raMonth.Height = "parent.Height - 28mm";
            raMonth.Stacking = StackingRulesEnum.InlineLeftToRight;

            rt = new RenderText(" ");
            rt.Style.WordWrap = false;
            rt.Height = "4%";
            rt.Style.TextAngle = 90;
            rt.Width = "2.7%";
            raMonth.Children.Add(rt);

            rt = new RenderText("[CDate(Fields!Date.Value).ToString(\"dddd\", Document.Tags!CalendarInfo.Value.CultureInfo)]");
            rt.DataBinding.DataSource = new Expression("Document.Tags!DateAppointments.Value(Parent.Fields!Date.Value, CDate(Parent.Fields!Date.Value).AddDays(6))");
            rt.DataBinding.Sorting.Expressions.Add("Fields!Date.Value");
            rt.FormatDataBindingInstanceScript =
                "RenderObject.Width = Document.Tags!DayWidth.Value";
            rt.Style.Borders.Bottom = LineDef.Default;
            rt.Style.Borders.Right = LineDef.Default;
            rt.Style.TextAlignHorz = AlignHorzEnum.Center;
            rt.Style.WordWrap = false;
            rt.Height = "4%";
            raMonth.Children.Add(rt);

            RenderArea raWeekTab = new RenderArea();
            raWeekTab.DataBinding.DataSource = new Expression("Document.Tags!WeekTabs.Value");
            raWeekTab.Height = "19.2%";
            raWeekTab.Width = "100%";
            raWeekTab.Stacking = StackingRulesEnum.InlineLeftToRight;

            rt = new RenderText();
            rt.FormatDataBindingInstanceScript =
                "Dim txt As RenderText = RenderObject\r\n" +
                "Dim start As Date = RenderObject.Parent.Original.DataBinding.Fields!Date.Value\r\n" +
                "Dim endT As Date = start.AddDays(6)\r\n" +
                "If start.Month = endT.Month Then \r\n" +
                "	txt.Text = start.ToString(\"%d\", Document.Tags!CalendarInfo.Value.CultureInfo) & \" - \" & endT.ToString(\"d.MM\", Document.Tags!CalendarInfo.Value.CultureInfo)\r\n" +
                "Else\r\n" +
                "	txt.Text = start.ToString(\"d.MM\", Document.Tags!CalendarInfo.Value.CultureInfo) & \" - \" & endT.ToString(\"d.MM\", Document.Tags!CalendarInfo.Value.CultureInfo)\r\n" +
                "End If";
            rt.Style.Borders.Right = LineDef.Default;
            rt.Style.FontBold = true;
            rt.Style.TextAngle = 90;
            rt.Style.TextAlignHorz = AlignHorzEnum.Center;
            rt.Style.WordWrap = false;
            rt.Height = "100%";
            rt.Width = "2.7%";
            raWeekTab.Children.Add(rt);

            // RenderArea representing the single day
            RenderArea raDay = new RenderArea();
            raDay.DataBinding.DataSource = new Expression("Document.Tags!DateAppointments.Value(Parent.Fields!Date.Value, CDate(Parent.Fields!Date.Value).AddDays(6))");
            raDay.DataBinding.Sorting.Expressions.Add("Fields!Date.Value");
            raDay.Style.Borders.Right = LineDef.Default;
            raDay.Style.Borders.Bottom = LineDef.Default;
            raDay.FormatDataBindingInstanceScript =
                "RenderObject.Width = Document.Tags!DayWidth.Value";
            raDay.Height = "100%";

            // day header
            rt = new RenderText("[IIF(Fields!Date.Value.Day = 1 Or CDate(Fields!Date.Value) = CDate(Document.Tags!WeekTabs.Value(0).Date), String.Format(Document.Tags!CalendarInfo.Value.CultureInfo, \"{0:m}\", Fields!Date.Value) ,Fields!Date.Value.Day)]");
            rt.Style.Borders.Bottom = LineDef.Default;
            rt.Style.Padding.Left = "1mm";
            rt.Style.FontBold = true;
            rt.Style.BackColor = Colors.White;
            rt.Style.TextAlignHorz = AlignHorzEnum.Left;
            rt.Style.WordWrap = false;

            raDay.Children.Add(rt);

            RenderText status = new RenderText(" ");
            status.FormatDataBindingInstanceScript =
                "If IsNothing(RenderObject.Original.DataBinding.Parent.Fields!BusyStatus.Value) Then\r\n" +
                "    RenderObject.Visibility = VisibilityEnum.Collapse\r\n" +
                "Else \r\n" +
                "    RenderObject.Style.Brush = RenderObject.Original.DataBinding.Parent.Fields!BusyStatus.Value.Brush.Brush \r\n" +
                "End If";
            status.Width = "100%";
            status.Height = "1.5mm";
            raDay.Children.Add(status);

            RenderArea appointments = new RenderArea();
            appointments.Height = "parent.Height - Y - 2.5mm";

            // RenderArea representing the single appointment
            RenderArea raApp = new RenderArea();
            raApp.Style.Spacing.All = "0.2mm";
            raApp.FormatDataBindingInstanceScript =
                "If RenderObject.Original.DataBinding.Fields!AllDayEvent.Value Then\r\n" +
                "    RenderObject.Style.Borders.All = LineDef.Default\r\n" +
                "End If\r\n" +
                "If Not IsNothing(RenderObject.Original.DataBinding.Fields!Label.Value) Then\r\n" +
                "    RenderObject.Style.Brush = CType(RenderObject.Original.DataBinding.Fields!Label.Value, Label).Brush.Brush\r\n" +
                "End If";
            raApp.Stacking = StackingRulesEnum.InlineLeftToRight;
            raApp.Height = "14pt";

            // Set the text's data source to the data source of the containing  RenderArea - this indicates that the render object is bound to the current group in the specified object:
            raApp.DataBinding.DataSource = new Expression("Parent.Fields!Appointments.Value");
            raApp.DataBinding.Sorting.Expressions.Add("Fields!Start.Value");
            raApp.DataBinding.Sorting.Expressions.Add("Fields!Subject.Value");

            rt = new RenderText();
            rt.Style.WordWrap = false;
            rt.Text = "[IIf(DateDiff(DateInterval.Second, CDate(DataBinding.Parent.Fields!Date.Value), CDate(Fields!Start.Value)) < 0, \"> \", String.Empty) & " +
                "IIf(Fields!AllDayEvent.Value, \"\", String.Format(Document.Tags!CalendarInfo.Value.CultureInfo, \"{0:t}\", " +
                "IIf(DateDiff(DateInterval.Second, CDate(DataBinding.Parent.Fields!Date.Value), CDate(Fields!Start.Value)) < 0, DataBinding.Parent.Fields!Date.Value, Fields!Start.Value)))] [Fields!Subject.Value]";
            rt.Width = "Auto";
            raApp.Children.Add(rt);

            rt = new RenderText();
            rt.FormatDataBindingInstanceScript =
                "RenderObject.Visibility = IIf(Not String.IsNullOrEmpty(RenderObject.Original.DataBinding.Parent.Fields!Location.Value), VisibilityEnum.Visible, VisibilityEnum.Collapse)";
            rt.Text = "[\" (\" & Fields!Location.Value & \")\"]";
            rt.Style.WordWrap = false;
            rt.Width = "Auto";
            raApp.Children.Add(rt);

            appointments.Children.Add(raApp);
            raDay.Children.Add(appointments);

            RenderArea overflowArea = new RenderArea();
            overflowArea.Name = "overflow";
            RenderText arrow = new RenderText(new string((char)0x36, 1), new Font("Webdings", 10));
            arrow.Style.Padding.Top = "-1.5mm";
            arrow.X = "parent.Width - 4mm";
            overflowArea.Children.Add(arrow);
            overflowArea.ZOrder = 100;
            overflowArea.Height = "2.5mm";
            overflowArea.FragmentResolvedScript =
                "if (C1PrintDocument.FormatVersion.AssemblyVersion.MinorRevision <> 100) Then\r\n" +
                "  Dim fragment As RenderFragment = RenderFragment.Parent.Children(2)\r\n" +
                "  If (fragment.HasChildren) Then\r\n" +
                "    If (RenderFragment.Parent.BoundsOnPage.Contains(fragment.Children(fragment.Children.Count - 1).BoundsOnPage)) Then\r\n" +
                "      RenderFragment.RenderObject.Visibility = VisibilityEnum.Hidden\r\n" +
                "    else\r\n" +
                "      RenderFragment.RenderObject.Visibility = VisibilityEnum.Visible\r\n" +
                "    end if\r\n" +
                "  else\r\n" +
                "    RenderFragment.RenderObject.Visibility = VisibilityEnum.Hidden\r\n" +
                "  end if\r\n" +
                "else\r\n" +
                "  RenderFragment.RenderObject.Visibility = VisibilityEnum.Hidden\r\n" +
                "end if";
            raDay.Children.Add(overflowArea);

            raWeekTab.Children.Add(raDay);
            raMonth.Children.Add(raWeekTab);

            raPage.Children.Add(raMonth);
            #endregion

            #region ** tasks
            // tasks
            RenderArea include = new RenderArea();
            include.FormatDataBindingInstanceScript =
                "If Document.Tags!IncludeTasks.Value Or Document.Tags!IncludeBlankNotes.Value Or Document.Tags!IncludeLinedNotes.Value Then\r\n" +
                "    RenderObject.Visibility = VisibilityEnum.Visible \r\n" +
                "Else\r\n" +
                "    RenderObject.Visibility = VisibilityEnum.Collapse \r\n" +
                "End If";
            include.Width = "20%";
            include.Height = "parent.Height - 28mm";

            RenderArea raTasks = new RenderArea();
            raTasks.FormatDataBindingInstanceScript =
                "If Not Document.Tags!IncludeTasks.Value Then\r\n" +
                "    RenderObject.Visibility = VisibilityEnum.Collapse \r\n" +
                "End If\r\n" +
                "RenderObject.Height = Document.Tags!TaskHeight.Value";
            raTasks.Style.Borders.All = LineDef.Default;
            raTasks.Style.Spacing.Top = "0.5mm";
            raTasks.Style.Spacing.Left = "0.5mm";
            raTasks.Width = "100%";

            rt = new RenderText();
            rt.Text = "Tasks";
            rt.Style.Padding.Left = "2mm";
            rt.Style.Borders.Bottom = LineDef.Default;
            raTasks.Children.Add(rt);
            include.Children.Add(raTasks);

            RenderArea raNotes = new RenderArea();
            raNotes.FormatDataBindingInstanceScript =
                "If Not Document.Tags!IncludeBlankNotes.Value Then\r\n" +
                "    RenderObject.Visibility = VisibilityEnum.Collapse \r\n" +
                "End If\r\n" +
                "RenderObject.Height = Document.Tags!TaskHeight.Value";
            raNotes.Style.Borders.All = LineDef.Default;
            raNotes.Style.Spacing.Top = "0.5mm";
            raNotes.Style.Spacing.Left = "0.5mm";
            raNotes.Width = "100%";

            rt = new RenderText();
            rt.Text = "Notes";
            rt.Style.Padding.Left = "2mm";
            rt.Style.Borders.Bottom = LineDef.Default;
            raNotes.Children.Add(rt);
            include.Children.Add(raNotes);

            raNotes = new RenderArea();
            raNotes.FormatDataBindingInstanceScript =
                "If Not Document.Tags!IncludeLinedNotes.Value Then\r\n" +
                "    RenderObject.Visibility = VisibilityEnum.Collapse \r\n" +
                "End If\r\n" +
                "RenderObject.Height = Document.Tags!TaskHeight.Value";
            raNotes.Style.Borders.All = LineDef.Default;
            raNotes.Style.Spacing.Top = "0.5mm";
            raNotes.Style.Spacing.Left = "0.5mm";
            raNotes.Width = "100%";

            rt = new RenderText();
            rt.Text = "Notes";
            rt.Style.Padding.Left = "2mm";
            rt.Style.Borders.Bottom = LineDef.Default;
            raNotes.Children.Add(rt);

            RenderTable lines = new RenderTable();
            lines.Rows.Insert(0, 1);
            lines.Rows[0].Height = "0.5cm";
            TableVectorGroup gr = lines.RowGroups[0, 1];
            gr.Header = TableHeaderEnum.None;
            List<int> lst = new List<int>(60);
            for (int i = 0; i < 60; i++)
            {
                lst.Add(i);
            }
            gr.DataBinding.DataSource = lst;
            lines.Style.GridLines.Horz = LineDef.Default;
            lines.RowSizingMode = TableSizingModeEnum.Fixed;

            raNotes.Children.Add(lines);

            include.Children.Add(raNotes);

            raPage.Children.Add(include);
            #endregion

            doc.Body.Children.Add(raPage);

            AddCommonTags(doc);

            Tag newTag = new Tag("Appointments", null, typeof(IList<Appointment>));
            newTag.ShowInDialog = false;
            newTag.SerializeValue = false;
            doc.Tags.Add(newTag);
            newTag = new Tag("WeekTabs", null, typeof(List<DateTime>));
            newTag.ShowInDialog = false;
            newTag.SerializeValue = false;
            doc.Tags.Add(newTag);
            newTag = new Tag("WeekNumber", null, typeof(List<DateTime>));
            newTag.ShowInDialog = false;
            newTag.SerializeValue = false;
            doc.Tags.Add(newTag);
            newTag = new Tag("MonthCalendars", null, typeof(List<DateTime>));
            newTag.ShowInDialog = false;
            newTag.SerializeValue = false;
            doc.Tags.Add(newTag);
            newTag = new Tag("StartDate", DateTime.Today, typeof(DateTime));
            newTag.InputParams = new TagDateTimeInputParams();
            doc.Tags.Add(newTag);
            newTag = new Tag("EndDate", DateTime.Today.AddDays(1), typeof(DateTime));
            newTag.InputParams = new TagDateTimeInputParams();
            doc.Tags.Add(newTag);
            newTag = new Tag("HidePrivateAppointments", false, typeof(bool));
            newTag.ShowInDialog = false;
            doc.Tags.Add(newTag);
            newTag = new Tag("TaskHeight", new Unit("33.3%"), typeof(Unit));
            newTag.ShowInDialog = false;
            doc.Tags.Add(newTag);
            newTag = new Tag("DayWidth", new Unit("13.9%"), typeof(Unit));
            newTag.ShowInDialog = false;
            doc.Tags.Add(newTag);

            newTag = new Tag("IncludeTasks", false, typeof(bool));
            newTag.ShowInDialog = true;
            newTag.InputParams = new TagBoolInputParams();
            newTag.Description = "Include Tasks";
            doc.Tags.Add(newTag);
            newTag = new Tag("IncludeBlankNotes", false, typeof(bool));
            newTag.ShowInDialog = true;
            newTag.InputParams = new TagBoolInputParams();
            newTag.Description = "Include Notes (blank)";
            doc.Tags.Add(newTag);
            newTag = new Tag("IncludeLinedNotes", false, typeof(bool));
            newTag.ShowInDialog = true;
            newTag.InputParams = new TagBoolInputParams();
            newTag.Description = "Include Notes (lined)";
            doc.Tags.Add(newTag);
            newTag = new Tag("WorkDaysOnly", false, typeof(bool));
            newTag.ShowInDialog = true;
            newTag.InputParams = new TagBoolInputParams();
            newTag.Description = "Only Print Workdays";
            doc.Tags.Add(newTag);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Fills specified control with a Day style.
        /// </summary>
        /// <param name="doc"></param>
        public static void MakeDay(C1PrintDocument doc)
        {
            doc.Clear();

            doc.DocumentInfo.Title = "Daily style";
            doc.DocumentInfo.Subject = "Day";
            AddNamespaces(doc);

            AddHeadersFooters(doc);
            doc.Tags["FooterRight"].Value = "[GeneratedDateTime]";
            doc.Tags["DateHeadingsFont"].Value = new Font("Segoe UI", 24, FontStyle.Bold);

            doc.DocumentStartingScript +=
                "Dim tasksNumber As Integer = 0 \r\n" +
                "If Document.Tags!IncludeTasks.Value Then\r\n" +
                "   tasksNumber = tasksNumber + 1 \r\n" +
                "End If\r\n" +
                "If Document.Tags!IncludeBlankNotes.Value Then\r\n" +
                "   tasksNumber = tasksNumber + 1 \r\n" +
                "End If\r\n" +
                "If Document.Tags!IncludeLinedNotes.Value Then\r\n" +
                "   tasksNumber = tasksNumber + 1 \r\n" +
                "End If\r\n" +
                "If tasksNumber = 1 Then\r\n" +
                "   Document.Tags!TaskHeight.Value = New Unit(\"100%\")\r\n" +
                "ElseIf tasksNumber = 2 Then\r\n" +
                "   Document.Tags!TaskHeight.Value = New Unit(\"50%\")\r\n" +
                "Else\r\n" +
                "   Document.Tags!TaskHeight.Value = New Unit(\"33.3%\")\r\n" +
                "End If\r\n" +
                "Dim dateAppointments As New DateAppointmentsCollection(Tags!StartDate.Value, Tags!EndDate.Value, Tags!Appointments.Value, Tags!CalendarInfo.Value, True, True)\r\n" +
                "If Tags.IndexByName(\"DateAppointments\") = -1 Then\r\n" +
                "   Dim tagApps As Tag\r\n" +
                "   tagApps = New Tag(\"DateAppointments\", dateAppointments)\r\n" +
                "   tagApps.SerializeValue = False\r\n" +
                "   Tags.Add(tagApps)\r\n" +
                "Else\r\n" +
                "   Tags!DateAppointments.Value = dateAppointments\r\n" +
                "End If\r\n" +
                "Dim startT As Date = Tags!StartTime.Value  \r\n" +
                "Dim endT As Date = Tags!EndTime.Value  \r\n" +
                "If startT > endT Then\r\n" +
                "   Tags!StartTime.Value = endT \r\n" +
                "   Tags!EndTime.Value = startT \r\n" +
                "End If";

            // RenderArea representing the single page
            RenderArea raPage = new RenderArea();
            raPage.DataBinding.DataSource = new Expression("Document.Tags!DateAppointments.Value");
            raPage.DataBinding.Sorting.Expressions.Add("Fields!Date.Value");
            raPage.BreakBefore = BreakEnum.Page;
            raPage.Width = "100%";
            raPage.Height = "100%";
            raPage.Stacking = StackingRulesEnum.InlineLeftToRight;

            #region ** day header
            // day header
            RenderArea raDayHeader = new RenderArea();
            raDayHeader.Style.Borders.All = LineDef.Default;
            raDayHeader.Width = "100%";
            raDayHeader.Height = "28mm";
            raDayHeader.Stacking = StackingRulesEnum.InlineLeftToRight;

            RenderText rt = new RenderText("[CDate(Fields!Date.Value).ToString(\"D\", Document.Tags!CalendarInfo.Value.CultureInfo)]");
            rt.FormatDataBindingInstanceScript =
                "RenderObject.Style.Font = Document.Tags!DateHeadingsFont.Value\r\n" +
                "Dim startDate As Date = RenderObject.Original.Parent.Parent.DataBinding.Fields!Date.Value\r\n" +
                "Document.Tags!StartTime.Value = startDate.Add(Document.Tags!StartTime.Value.TimeOfDay)\r\n" +
                "Document.Tags!EndTime.Value = startDate.Add(Document.Tags!EndTime.Value.TimeOfDay)\r\n" +
                "Document.Tags!MonthCalendar.Value = New Date(startDate.Year, startDate.Month, 1) \r\n" +
                "startDate = Document.Tags!StartTime.Value\r\n" +
                "Document.Tags!DayHours.Value = New Dictionary(of Date, Date)\r\n" +
                "While startDate < Document.Tags!EndTime.Value\r\n" +
                "	Document.Tags!DayHours.Value.Add(startDate, startDate)\r\n" +
                "	startDate = startDate.AddMinutes(30)\r\n" +
                "End While";
            rt.Style.TextAlignVert = AlignVertEnum.Center;
            rt.Style.Spacing.Left = "2mm";
            rt.Height = "100%";
            rt.Width = "parent.Width - 38mm";

            raDayHeader.Children.Add(rt);

            RenderArea monthCalendar = new RenderArea();
            monthCalendar.Stacking = StackingRulesEnum.InlineLeftToRight;
            monthCalendar.Style.Spacing.Left = "1mm";
            monthCalendar.Style.Spacing.Right = "3mm";
            monthCalendar.Style.Spacing.Top = "0.5mm";
            monthCalendar.Width = "36mm";

            rt = new RenderText("[CDate(Document.Tags!MonthCalendar.Value).ToString(\"MMMM yyy\", Document.Tags!CalendarInfo.Value.CultureInfo)]");
            rt.FormatDataBindingInstanceScript =
                "Dim startDate As Date = Document.Tags!MonthCalendar.Value\r\n" +
                "Dim endDate As Date = startDate.AddMonths(1).AddDays(-1)\r\n" +
                "While startDate.DayOfWeek <> Document.Tags!CalendarInfo.Value.WeekStart \r\n" +
                "    startDate = startDate.AddDays(-1)\r\n" +
                "End While\r\n" +
                "Document.Tags!WeekNumber.Value = New List(of Date)\r\n" +
                "While startDate <= endDate\r\n" +
                "	Document.Tags!WeekNumber.Value.Add(startDate)\r\n" +
                "	startDate = startDate.AddDays(7)\r\n" +
                "End While";
            rt.Style.TextAlignHorz = AlignHorzEnum.Center;
            rt.Style.Font = new Font("Segoe UI", 8);
            rt.Width = "100%";
            monthCalendar.Children.Add(rt);

            rt = new RenderText(" ");
            rt.Style.Font = new Font("Arial", 7f);
            rt.Style.WordWrap = false;
            rt.Width = "12.5%";
            monthCalendar.Children.Add(rt);

            rt = new RenderText("[Document.Tags!CalendarInfo.Value.CultureInfo.DateTimeFormat.GetShortestDayName(CDate(Fields!Date.Value).DayOfWeek)]");
            rt.DataBinding.DataSource = new Expression("New DateAppointmentsCollection(Document.Tags!WeekNumber.Value(0), Document.Tags!WeekNumber.Value(0).AddDays(6), Document.Tags!Appointments.Value, True)");
            rt.DataBinding.Sorting.Expressions.Add("Fields!Date.Value");
            rt.Style.Borders.Bottom = LineDef.Default;
            rt.Style.Font = new Font("Arial", 7f);
            rt.Style.TextAlignHorz = AlignHorzEnum.Center;
            rt.Style.WordWrap = false;
            rt.Width = "12.5%";
            monthCalendar.Children.Add(rt);

            RenderArea raWeek = new RenderArea();
            raWeek.DataBinding.DataSource = new Expression("Document.Tags!WeekNumber.Value");
            raWeek.Style.Font = new Font("Arial", 7f);
            raWeek.Width = "100%";
            raWeek.Stacking = StackingRulesEnum.InlineLeftToRight;

            rt = new RenderText("[Document.Tags!CalendarInfo.Value.CultureInfo.Calendar.GetWeekOfYear(CDate(Fields!Date.Value), System.Globalization.CalendarWeekRule.FirstDay, Document.Tags!CalendarInfo.Value.WeekStart)]");
            rt.Style.Borders.Right = LineDef.Default;
            rt.Style.TextAlignHorz = AlignHorzEnum.Right;
            rt.Style.WordWrap = false;
            rt.Width = "12.5%";
            raWeek.Children.Add(rt);

            rt = new RenderText("[CDate(Fields!Date.Value).ToString(\"%d\", Document.Tags!CalendarInfo.Value.CultureInfo)]");
            rt.DataBinding.DataSource = new Expression("New DateAppointmentsCollection(Parent.Fields!Date.Value, CDate(Parent.Fields!Date.Value).AddDays(6), Document.Tags!Appointments.Value, True)");
            rt.DataBinding.Sorting.Expressions.Add("Fields!Date.Value");
            rt.FormatDataBindingInstanceScript =
                "If RenderObject.Original.DataBinding.Fields!Date.Value.Month <> Document.Tags!MonthCalendar.Value.Month Then\r\n" +
                "    RenderObject.Visibility = VisibilityEnum.Hidden\r\n" +
                "Else If RenderObject.Original.DataBinding.Fields!HasAppointments.Value Then\r\n" +
                "    RenderObject.Style.FontBold = true\r\n" +
                "End If";
            rt.Style.TextAlignHorz = AlignHorzEnum.Right;
            rt.Width = "12.5%";
            raWeek.Children.Add(rt);
            monthCalendar.Children.Add(raWeek);

            raDayHeader.Children.Add(monthCalendar);

            raPage.Children.Add(raDayHeader);
            #endregion

            #region ** day
            // day
            RenderArea raDayBody = new RenderArea();
            raDayBody.FormatDataBindingInstanceScript =
                "If Not (Document.Tags!IncludeTasks.Value Or Document.Tags!IncludeBlankNotes.Value Or Document.Tags!IncludeLinedNotes.Value) Then\r\n" +
                "    RenderObject.Width = \"100%\" \r\n" +
                "End If";
            raDayBody.Style.Spacing.Top = "0.5mm";
            raDayBody.Style.Borders.All = LineDef.Default;
            raDayBody.Width = "75%";
            raDayBody.Height = "parent.Height - 28mm";
            raDayBody.Stacking = StackingRulesEnum.BlockTopToBottom;

            #region ** all-day events
            // RenderArea representing the single day
            RenderArea raDay = new RenderArea();
            raDay.DataBinding.DataSource = new Expression("Document.Tags!DateAppointments.Value(Parent.Fields!Date.Value, CDate(Parent.Fields!Date.Value))");
            raDay.DataBinding.Sorting.Expressions.Add("Fields!Date.Value");
            raDay.Stacking = StackingRulesEnum.InlineLeftToRight;
            raDay.Height = "Auto";

            RenderText status = new RenderText(" ");
            status.FormatDataBindingInstanceScript =
                "If IsNothing(RenderObject.Original.DataBinding.Parent.Fields!BusyStatus.Value) Then\r\n" +
                "    RenderObject.Visibility = VisibilityEnum.Collapse\r\n" +
                "Else \r\n" +
                "    RenderObject.Style.Brush = RenderObject.Original.DataBinding.Parent.Fields!BusyStatus.Value.Brush.Brush \r\n" +
                "End If";
            status.Width = "100%";
            status.Height = "1.5mm";
            raDay.Children.Add(status);

            // RenderArea representing the single appointment
            RenderArea raApp = new RenderArea();
            raApp.Style.Spacing.All = "0.5mm";
            raApp.Style.Spacing.Left = "1.25cm";
            raApp.FormatDataBindingInstanceScript =
                "If RenderObject.Original.DataBinding.Fields!AllDayEvent.Value Then\r\n" +
                "    RenderObject.Style.Borders.All = LineDef.Default\r\n" +
                "ElseIf DateDiff(DateInterval.Second, CDate(Document.Tags!StartTime.Value), CDate(RenderObject.Original.DataBinding.Fields!Start.Value)) >= 0 Then\r\n" +
                "    RenderObject.Visibility = VisibilityEnum.Collapse\r\n" +
                "End If\r\n" +
                "If Not IsNothing(RenderObject.Original.DataBinding.Fields!Label.Value) Then\r\n" +
                "    RenderObject.Style.Brush = CType(RenderObject.Original.DataBinding.Fields!Label.Value, Label).Brush.Brush\r\n" +
                "End If";
            raApp.Stacking = StackingRulesEnum.InlineLeftToRight;
            // Set the text's data source to the data source of the containing  RenderArea - this indicates that the render object is bound to the current group in the specified object:
            raApp.DataBinding.DataSource = new Expression("Parent.Fields!Appointments.Value");
            raApp.DataBinding.Sorting.Expressions.Add("Fields!Start.Value");
            raApp.DataBinding.Sorting.Expressions.Add("Fields!Subject.Value");

            rt = new RenderText();
            rt.Text = "[IIf(DateDiff(DateInterval.Second, CDate(DataBinding.Parent.Fields!Date.Value), CDate(Fields!Start.Value)) < 0, \"> \", String.Empty) & " +
                "IIf(Fields!AllDayEvent.Value, \"\", String.Format(Document.Tags!CalendarInfo.Value.CultureInfo, \"{0:t} {1:t}\", " +
                "IIf(DateDiff(DateInterval.Second, CDate(DataBinding.Parent.Fields!Date.Value), CDate(Fields!Start.Value)) < 0, DataBinding.Parent.Fields!Date.Value, Fields!Start.Value), " +
                "IIf(DateDiff(DateInterval.Second, CDate(DataBinding.Parent.Fields!Date.Value.AddDays(1)), CDate(Fields!End.Value)) > 0, DataBinding.Parent.Fields!Date.Value.AddDays(1), Fields!End.Value)))]";
            rt.Width = "Auto";
            raApp.Children.Add(rt);

            rt = new RenderText();
            rt.Text = " [Fields!Subject.Value] ";
            rt.Width = "Auto";
            raApp.Children.Add(rt);

            rt = new RenderText();
            rt.FormatDataBindingInstanceScript =
                "RenderObject.Visibility = IIf(Not String.IsNullOrEmpty(RenderObject.Original.DataBinding.Parent.Fields!Location.Value), VisibilityEnum.Visible, VisibilityEnum.Collapse)";
            rt.Text = "[\" (\" & Fields!Location.Value & \")\"]";
            rt.Width = "Auto";
            raApp.Children.Add(rt);

            raDay.Children.Add(raApp);

            raDayBody.Children.Add(raDay);
            #endregion

            #region ** slots
            raDay = new RenderArea();
            raDay.DataBinding.DataSource = new Expression("Document.Tags!DateAppointments.Value(Parent.Fields!Date.Value, CDate(Parent.Fields!Date.Value))");
            raDay.DataBinding.Sorting.Expressions.Add("Fields!Date.Value");
            raDay.Stacking = StackingRulesEnum.InlineLeftToRight;
            raDay.Height = "parent - prev.height - next.height";

            RenderArea raTimeSlot = new RenderArea();
            raTimeSlot.FormatDataBindingInstanceScript =
                "RenderObject.Height = New Unit((100/CLng(Document.Tags!DayHours.Value.Count) - 0.005).ToString(\"#.###\", System.Globalization.CultureInfo.InvariantCulture) & \"%\")";
            raTimeSlot.DataBinding.DataSource = new Expression("Document.Tags!DayHours.Value");
            raTimeSlot.Width = "100%";
            raTimeSlot.Height = "0.5cm";
            raTimeSlot.Stacking = StackingRulesEnum.InlineLeftToRight;

            RenderParagraph rp = new RenderParagraph();
            rp.FormatDataBindingInstanceScript =
                "Document.Tags!SlotAppointments.Value = Document.Tags!DateAppointments.Value.GetIntervalAppointments(RenderObject.Original.DataBinding.Parent.Fields!Key.Value, RenderObject.Original.DataBinding.PArent.Fields!Key.Value.AddMinutes(30), False)\r\n" +
                "RenderObject.Visibility = IIf(RenderObject.Original.DataBinding.Parent.Fields!Key.Value.Minute = 0, VisibilityEnum.Visible, VisibilityEnum.Hidden)\r\n" +
                "Dim headerFont As Font = Document.Tags!DateHeadingsFont.Value\r\n" +
                "RenderObject.Style.Font = New Font(headerFont.FontFamily, headerFont.Size * 2 / 3)";
            rp.Width = "1.65cm";
            rp.Style.TextAlignHorz = AlignHorzEnum.Right;
            rp.Style.Borders.Top = LineDef.Default;
            rp.Style.Padding.Right = "1mm";
            rp.Height = "100%";
            ParagraphText pt = new ParagraphText("[IIf(String.IsNullOrEmpty(Document.Tags!CalendarInfo.Value.CultureInfo.DateTimeFormat.AMDesignator), CDate(Fields!Key.Value).ToString(\"%H\"), CDate(Fields!Key.Value).ToString(\"%h\"))]");
            pt.Style.FontBold = true;
            pt.Style.Padding.Right = "1mm";
            rp.Content.Add(pt);
            rp.Content.Add(new ParagraphText("[IIf(String.IsNullOrEmpty(Document.Tags!CalendarInfo.Value.CultureInfo.DateTimeFormat.AMDesignator), \"00\", CDate(Fields!Key.Value).ToString(\"tt\", Document.Tags!CalendarInfo.Value.CultureInfo).ToLower())]", TextPositionEnum.Superscript));
            raTimeSlot.Children.Add(rp);

            RenderArea slot = new RenderArea();
            slot.Width = "parent.width - prev.width - prev.left";
            slot.Height = "100%";
            slot.Style.Borders.Top = LineDef.Default;
            slot.Style.Borders.Left = LineDef.Default;
            slot.Stacking = StackingRulesEnum.InlineLeftToRight;

            // RenderArea representing the single appointment
            raApp = new RenderArea();
            // Set the text's data source to the data source of the containing  RenderArea - this indicates that the render object is bound to the current group in the specified object:
            raApp.DataBinding.DataSource = new Expression("Document.Tags!SlotAppointments.Value");
            raApp.DataBinding.Sorting.Expressions.Add("Fields!Start.Value");
            raApp.DataBinding.Sorting.Expressions.Add("Fields!Subject.Value");
            raApp.Style.Spacing.All = "0.5mm";
            raApp.FormatDataBindingInstanceScript =
                "RenderObject.Width = New Unit((100/CLng(Document.Tags!SlotAppointments.Value.Count) - 0.005).ToString(\"#.###\", System.Globalization.CultureInfo.InvariantCulture) & \"%\")\r\n" +
                "If Not IsNothing(RenderObject.Original.DataBinding.Fields!Label.Value) Then\r\n" +
                "    RenderObject.Style.Brush = CType(RenderObject.Original.DataBinding.Fields!Label.Value, Label).Brush.Brush\r\n" +
                "End If";
            raApp.Width = "10%";
            raApp.Height = "100%";
            raApp.Stacking = StackingRulesEnum.InlineLeftToRight;

            rt = new RenderText();
            rt.Text = "[String.Format(Document.Tags!CalendarInfo.Value.CultureInfo, \"{0:t}-{1:t}\", Fields!Start.Value, Fields!End.Value).ToLower()]";
            rt.Width = "Auto";
            raApp.Children.Add(rt);

            rt = new RenderText();
            rt.Text = " [Fields!Subject.Value] ";
            rt.Width = "Auto";
            raApp.Children.Add(rt);

            rt = new RenderText();
            rt.FormatDataBindingInstanceScript =
                "RenderObject.Visibility = IIf(Not String.IsNullOrEmpty(RenderObject.Original.DataBinding.Parent.Fields!Location.Value), VisibilityEnum.Visible, VisibilityEnum.Collapse)";
            rt.Text = "[\" (\" & Fields!Location.Value & \")\"]";
            rt.Width = "Auto";
            raApp.Children.Add(rt);

            slot.Children.Add(raApp);

            raTimeSlot.Children.Add(slot);

            raDay.Children.Add(raTimeSlot);
            raDayBody.Children.Add(raDay);
            #endregion

            #region ** late appointments
            raDay = new RenderArea();
            raDay.DataBinding.DataSource = new Expression("Document.Tags!DateAppointments.Value(Parent.Fields!Date.Value, CDate(Parent.Fields!Date.Value))");
            raDay.DataBinding.Sorting.Expressions.Add("Fields!Date.Value");
            raDay.Style.Borders.Top = LineDef.Default;
            raDay.Stacking = StackingRulesEnum.InlineLeftToRight;
            raDay.Height = "Auto";

            // RenderArea representing the single appointment
            raApp = new RenderArea();
            raApp.Style.Spacing.All = "0.5mm";
            raApp.Style.Spacing.Left = "1.25cm";
            raApp.FormatDataBindingInstanceScript =
                "If DateDiff(DateInterval.Second, CDate(Document.Tags!EndTime.Value), CDate(RenderObject.Original.DataBinding.Fields!Start.Value)) >= 0 Then\r\n" +
                "    RenderObject.Visibility = VisibilityEnum.Visible\r\n" +
                "Else\r\n" +
                "    RenderObject.Visibility = VisibilityEnum.Collapse\r\n" +
                "End If\r\n" +
                "If Not IsNothing(RenderObject.Original.DataBinding.Fields!Label.Value) Then\r\n" +
                "    RenderObject.Style.Brush = CType(RenderObject.Original.DataBinding.Fields!Label.Value, Label).Brush.Brush\r\n" +
                "End If";
            raApp.Stacking = StackingRulesEnum.InlineLeftToRight;
            // Set the text's data source to the data source of the containing  RenderArea - this indicates that the render object is bound to the current group in the specified object:
            raApp.DataBinding.DataSource = new Expression("Parent.Fields!Appointments.Value");
            raApp.DataBinding.Sorting.Expressions.Add("Fields!Start.Value");
            raApp.DataBinding.Sorting.Expressions.Add("Fields!Subject.Value");

            rt = new RenderText();
            rt.Text = "[IIf(DateDiff(DateInterval.Second, CDate(DataBinding.Parent.Fields!Date.Value), CDate(Fields!Start.Value)) < 0, \"> \", String.Empty) & " +
                "IIf(Fields!AllDayEvent.Value, \"\", String.Format(Document.Tags!CalendarInfo.Value.CultureInfo, \"{0:t} {1:t}\", " +
                "IIf(DateDiff(DateInterval.Second, CDate(DataBinding.Parent.Fields!Date.Value), CDate(Fields!Start.Value)) < 0, DataBinding.Parent.Fields!Date.Value, Fields!Start.Value), " +
                "IIf(DateDiff(DateInterval.Second, CDate(DataBinding.Parent.Fields!Date.Value.AddDays(1)), CDate(Fields!End.Value)) > 0, DataBinding.Parent.Fields!Date.Value.AddDays(1), Fields!End.Value)))]";
            rt.Width = "Auto";
            raApp.Children.Add(rt);

            rt = new RenderText();
            rt.Text = " [Fields!Subject.Value] ";
            rt.Width = "Auto";
            raApp.Children.Add(rt);

            rt = new RenderText();
            rt.FormatDataBindingInstanceScript =
                "RenderObject.Visibility = IIf(Not String.IsNullOrEmpty(RenderObject.Original.DataBinding.Parent.Fields!Location.Value), VisibilityEnum.Visible, VisibilityEnum.Collapse)";
            rt.Text = "[\" (\" & Fields!Location.Value & \")\"]";
            rt.Width = "Auto";
            raApp.Children.Add(rt);

            raDay.Children.Add(raApp);

            raDayBody.Children.Add(raDay);
            #endregion

            raPage.Children.Add(raDayBody);
            #endregion

            #region ** tasks
            // tasks
            RenderArea include = new RenderArea();
            include.FormatDataBindingInstanceScript =
                "If Document.Tags!IncludeTasks.Value Or Document.Tags!IncludeBlankNotes.Value Or Document.Tags!IncludeLinedNotes.Value Then\r\n" +
                "    RenderObject.Visibility = VisibilityEnum.Visible \r\n" +
                "Else\r\n" +
                "    RenderObject.Visibility = VisibilityEnum.Collapse \r\n" +
                "End If";
            include.Width = "25%";
            include.Height = "parent.Height - 28mm";

            RenderArea raTasks = new RenderArea();
            raTasks.FormatDataBindingInstanceScript =
                "If Not Document.Tags!IncludeTasks.Value Then\r\n" +
                "    RenderObject.Visibility = VisibilityEnum.Collapse \r\n" +
                "End If\r\n" +
                "RenderObject.Height = Document.Tags!TaskHeight.Value";
            raTasks.Style.Borders.All = LineDef.Default;
            raTasks.Style.Spacing.Top = "0.5mm";
            raTasks.Style.Spacing.Left = "0.5mm";
            raTasks.Width = "100%";

            rt = new RenderText();
            rt.Text = "Tasks";
            rt.Style.Padding.Left = "2mm";
            rt.Style.Borders.Bottom = LineDef.Default;
            raTasks.Children.Add(rt);
            include.Children.Add(raTasks);

            RenderArea raNotes = new RenderArea();
            raNotes.FormatDataBindingInstanceScript =
                "If Not Document.Tags!IncludeBlankNotes.Value Then\r\n" +
                "    RenderObject.Visibility = VisibilityEnum.Collapse \r\n" +
                "End If\r\n" +
                "RenderObject.Height = Document.Tags!TaskHeight.Value";
            raNotes.Style.Borders.All = LineDef.Default;
            raNotes.Style.Spacing.Top = "0.5mm";
            raNotes.Style.Spacing.Left = "0.5mm";
            raNotes.Width = "100%";

            rt = new RenderText();
            rt.Text = "Notes";
            rt.Style.Padding.Left = "2mm";
            rt.Style.Borders.Bottom = LineDef.Default;
            raNotes.Children.Add(rt);
            include.Children.Add(raNotes);

            raNotes = new RenderArea();
            raNotes.FormatDataBindingInstanceScript =
                "If Not Document.Tags!IncludeLinedNotes.Value Then\r\n" +
                "    RenderObject.Visibility = VisibilityEnum.Collapse \r\n" +
                "End If\r\n" +
                "RenderObject.Height = Document.Tags!TaskHeight.Value";
            raNotes.Style.Borders.All = LineDef.Default;
            raNotes.Style.Spacing.Top = "0.5mm";
            raNotes.Style.Spacing.Left = "0.5mm";
            raNotes.Width = "100%";

            rt = new RenderText();
            rt.Text = "Notes";
            rt.Style.Padding.Left = "2mm";
            rt.Style.Borders.Bottom = LineDef.Default;
            raNotes.Children.Add(rt);

            RenderTable lines = new RenderTable();
            lines.Rows.Insert(0, 1);
            lines.Rows[0].Height = "0.5cm";
            TableVectorGroup gr = lines.RowGroups[0, 1];
            gr.Header = TableHeaderEnum.None;
            List<int> lst = new List<int>(60);
            for (int i = 0; i < 60; i++)
            {
                lst.Add(i);
            }
            gr.DataBinding.DataSource = lst;
            lines.Style.GridLines.Horz = LineDef.Default;
            lines.RowSizingMode = TableSizingModeEnum.Fixed;

            raNotes.Children.Add(lines);

            include.Children.Add(raNotes);

            raPage.Children.Add(include);
            #endregion

            doc.Body.Children.Add(raPage);

            AddCommonTags(doc);

            Tag newTag = new Tag("Appointments", null, typeof(IList<Appointment>));
            newTag.ShowInDialog = false;
            newTag.SerializeValue = false;
            doc.Tags.Add(newTag);
            newTag = new Tag("WeekNumber", null, typeof(List<DateTime>));
            newTag.SerializeValue = false;
            newTag.ShowInDialog = false;
            doc.Tags.Add(newTag);
            newTag = new Tag("DayHours", null, typeof(Dictionary<DateTime, DateTime>));
            newTag.SerializeValue = false;
            newTag.ShowInDialog = false;
            doc.Tags.Add(newTag);
            newTag = new Tag("MonthCalendar", null, typeof(DateTime));
            newTag.ShowInDialog = false;
            doc.Tags.Add(newTag);
            newTag = new Tag("StartDate", DateTime.Today, typeof(DateTime));
            newTag.InputParams = new TagDateTimeInputParams();
            doc.Tags.Add(newTag);
            newTag = new Tag("EndDate", DateTime.Today.AddDays(1), typeof(DateTime));
            newTag.InputParams = new TagDateTimeInputParams();
            doc.Tags.Add(newTag);

            newTag = new Tag("StartTime", DateTime.Today.AddHours(7), typeof(DateTime));
            newTag.InputParams = new TagDateTimeInputParams();
            ((TagDateTimeInputParams)newTag.InputParams).Format = DateTimePickerFormat.Time;
            doc.Tags.Add(newTag);
            newTag = new Tag("EndTime", DateTime.Today.AddHours(19), typeof(DateTime));
            newTag.InputParams = new TagDateTimeInputParams();
            ((TagDateTimeInputParams)newTag.InputParams).Format = DateTimePickerFormat.Time;
            doc.Tags.Add(newTag);

            newTag = new Tag("HidePrivateAppointments", false, typeof(bool));
            newTag.ShowInDialog = false;
            doc.Tags.Add(newTag);
            newTag = new Tag("TaskHeight", new Unit("33.3%"), typeof(Unit));
            newTag.ShowInDialog = false;
            doc.Tags.Add(newTag);
            newTag = new Tag("SlotAppointments", null, typeof(List<Appointment>));
            newTag.SerializeValue = false;
            newTag.ShowInDialog = false;
            doc.Tags.Add(newTag);

            newTag = new Tag("IncludeTasks", false, typeof(bool));
            newTag.ShowInDialog = true;
            newTag.InputParams = new TagBoolInputParams();
            newTag.Description = "Include Tasks";
            doc.Tags.Add(newTag);
            newTag = new Tag("IncludeBlankNotes", false, typeof(bool));
            newTag.ShowInDialog = true;
            newTag.InputParams = new TagBoolInputParams();
            newTag.Description = "Include Notes (blank)";
            doc.Tags.Add(newTag);
            newTag = new Tag("IncludeLinedNotes", false, typeof(bool));
            newTag.ShowInDialog = true;
            newTag.InputParams = new TagBoolInputParams();
            newTag.Description = "Include Notes (lined)";
            doc.Tags.Add(newTag);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Fills specified control with a Details style.
        /// </summary>
        /// <param name="doc"></param>
        public static void MakeDetails(C1PrintDocument doc)
        {
            doc.Clear();

            doc.DocumentInfo.Title = "Details style";
            doc.DocumentInfo.Subject = "Details";
            AddNamespaces(doc);

            AddHeadersFooters(doc);
            doc.Tags["FooterRight"].Value = "[GeneratedDateTime]";

            doc.DocumentStartingScript +=
                "If Tags!InsertPageBreaks.Value And Tags!PageBreak.Value <> \"Day\" Then \r\n" +
                "	If Tags.IndexByName(\"LastDate\") = -1 Then\r\n" +
                "	    Dim tag As Tag\r\n" +
                "       tag = New Tag(\"LastDate\", Tags!StartDate.Value.Date)\r\n" +
                "       Tags.Add(tag)\r\n" +
                "   Else\r\n" +
                "       Tags!LastDate.Value = Tags!StartDate.Value.Date\r\n" +
                "   End If\r\n" +
                "End If\r\n" +
                "Dim dateAppointments As New DateAppointmentsCollection(Tags!StartDate.Value, Tags!EndDate.Value, Tags!Appointments.Value, false)\r\n" +
                "If Tags.IndexByName(\"DateAppointments\") = -1 Then\r\n" +
                "   Dim tagApps As Tag\r\n" +
                "   tagApps = New Tag(\"DateAppointments\", dateAppointments)\r\n" +
                "   tagApps.SerializeValue = False\r\n" +
                "   Tags.Add(tagApps)\r\n" +
                "Else\r\n" +
                "   Tags!DateAppointments.Value = dateAppointments\r\n" +
                "End If";

            // RenderArea representing the single day
            RenderArea ra1 = new RenderArea();
            ra1.DataBinding.DataSource = new Expression("Document.Tags!DateAppointments.Value");
            ra1.DataBinding.Sorting.Expressions.Add("Fields!Date.Value");
            ra1.FormatDataBindingInstanceScript =
                "If Tags!InsertPageBreaks.Value Then\r\n" +
                "	 Dim newDate as DateTime\r\n" +
                "	 newDate = RenderObject.Original.DataBinding.Fields!Date.Value\r\n" +
                "    Select Case Tags!PageBreak.Value\r\n" +
                "		Case \"Week\"\r\n" +
                "			Dim tmp as DateTime\r\n" +
                "			tmp = Tags!LastDate.Value.Date.AddDays(1)\r\n" +
                "			While tmp <= newDate\r\n" +
                "				If tmp.DayOfWeek = Tags!CalendarInfo.Value.WeekStart Then\r\n" +
                "					RenderObject.BreakBefore = BreakEnum.Page\r\n" +
                "					Exit While\r\n" +
                "				End If\r\n" +
                "				tmp = tmp.AddDays(1)\r\n" +
                "			End While\r\n" +
                "		Case \"Month\"\r\n" +
                "			If Tags!LastDate.Value.Month <> newDate.Month Then\r\n" +
                "				RenderObject.BreakBefore = BreakEnum.Page\r\n" +
                "			End If\r\n" +
                "		Case Else\r\n" +
                "			RenderObject.BreakBefore = BreakEnum.Page\r\n" +
                "    End Select\r\n" +
                "    Tags!LastDate.Value = newDate\r\n" +
                "End If";

            ra1.Style.Spacing.All = "1mm";

            // day header
            RenderText rt = new RenderText("[String.Format(Document.Tags!CalendarInfo.Value.CultureInfo, \"{0:D}\", Fields!Date.Value)]");
            rt.FormatDataBindingInstanceScript =
                "RenderObject.Style.Font = Document.Tags!DateHeadingsFont.Value";
            rt.Style.Borders.All = LineDef.Default;
            rt.Style.Padding.All = "2mm";
            rt.Style.BackColor = Colors.LightGray;

            ra1.Children.Add(rt);

            // RenderArea tepresenting the single appointment
            RenderArea raApp = new RenderArea();
            raApp.Style.Spacing.All = "2mm";
            raApp.Stacking = StackingRulesEnum.InlineLeftToRight;

            // Set the text's data source to the data source of the containing  RenderArea - this indicates that the render object is bound to the current group in the specified object:
            raApp.DataBinding.DataSource = new Expression("Parent.Fields!Appointments.Value");
            raApp.DataBinding.Sorting.Expressions.Add("Fields!Start.Value");
            raApp.DataBinding.Sorting.Expressions.Add("Fields!Subject.Value");

            rt = new RenderText();
            rt.Text = "[IIf(Fields!AllDayEvent.Value, \"All Day\", String.Format(Document.Tags!CalendarInfo.Value.CultureInfo, \"{0:t} - {1:t}\", " +
                "IIf(DateDiff(DateInterval.Second, CDate(DataBinding.Parent.Fields!Date.Value), CDate(Fields!Start.Value)) < 0, DataBinding.Parent.Fields!Date.Value, Fields!Start.Value), " +
                "IIf(DateDiff(DateInterval.Second, CDate(DataBinding.Parent.Fields!Date.Value.AddDays(1)), CDate(Fields!End.Value)) > 0, DataBinding.Parent.Fields!Date.Value.AddDays(1), Fields!End.Value)))]";
            rt.Width = "25%";
            rt.Style.FontBold = true;
            raApp.Children.Add(rt);

            RenderArea appDetails = new RenderArea();
            appDetails.Width = "75%";
            appDetails.Stacking = StackingRulesEnum.InlineLeftToRight;

            RenderText rt1 = new RenderText();
            rt1.Text = "[Fields!Subject.Value] ";
            rt1.Style.FontBold = true;
            rt1.Width = "Auto";
            appDetails.Children.Add(rt1);

            rt1 = new RenderText();
            rt1.FormatDataBindingInstanceScript =
                "RenderObject.Visibility = IIf(Not String.IsNullOrEmpty(RenderObject.Original.DataBinding.Parent.Fields!Location.Value), VisibilityEnum.Visible, VisibilityEnum.Collapse)";
            rt1.Text = "[\"-- \" & Fields!Location.Value]";
            rt1.Style.FontBold = true;
            rt1.Width = "Auto";
            appDetails.Children.Add(rt1);

            rt1 = new RenderText();
            rt1.FormatDataBindingInstanceScript =
                "RenderObject.Visibility = IIf(Not String.IsNullOrEmpty(RenderObject.Original.DataBinding.Parent.Fields!Body.Value), VisibilityEnum.Visible, VisibilityEnum.Collapse) \r\n" +
                "RenderObject.BreakBefore = IIf(Not String.IsNullOrEmpty(RenderObject.Original.DataBinding.Parent.Fields!Subject.Value & RenderObject.Original.DataBinding.Parent.Fields!Location.Value), BreakEnum.Line, BreakEnum.None)";
            rt1.Text = "[Fields!Body.Value]";
            appDetails.Children.Add(rt1);

            rt1 = new RenderText();
            rt1.FormatDataBindingInstanceScript =
                "RenderObject.Visibility = IIf(DateDiff(DateInterval.Second, CDate(RenderObject.Original.DataBinding.Parent.Parent.Fields!Date.Value), CDate(RenderObject.Original.DataBinding.Parent.Fields!Start.Value)) < 0, VisibilityEnum.Visible, VisibilityEnum.Collapse)";
            rt1.Text = "[\"Please See Above\"]";
            rt1.Style.FontBold = true;
            rt1.BreakBefore = BreakEnum.Line;
            appDetails.Children.Add(rt1);

            raApp.Children.Add(appDetails);

            ra1.Children.Add(raApp);
            doc.Body.Children.Add(ra1);

            AddCommonTags(doc);

            Tag newTag = new Tag("Appointments", null, typeof(IList<Appointment>));
            newTag.ShowInDialog = false;
            newTag.SerializeValue = false;
            doc.Tags.Add(newTag);
            newTag = new Tag("StartDate", DateTime.Today, typeof(DateTime));
            newTag.InputParams = new TagDateTimeInputParams();
            doc.Tags.Add(newTag);
            newTag = new Tag("EndDate", DateTime.Today.AddDays(1), typeof(DateTime));
            newTag.InputParams = new TagDateTimeInputParams();
            doc.Tags.Add(newTag);
            newTag = new Tag("InsertPageBreaks", false, typeof(Boolean));
            newTag.Description = "Start a new page each";
            doc.Tags.Add(newTag);
            newTag = new Tag("PageBreak", "Day", typeof(string));
            newTag.Description = "";
            newTag.InputParams = new TagListInputParams(TagListInputParamsTypeEnum.ComboBox, new TagListInputParamsItem("Day", "Day"), new TagListInputParamsItem("Week", "Week"), new TagListInputParamsItem("Month", "Month"));
            doc.Tags.Add(newTag);
            newTag = new Tag("HidePrivateAppointments", false, typeof(bool));
            newTag.ShowInDialog = false;
            doc.Tags.Add(newTag);
        }
Exemplo n.º 10
0
        private void MakeDoc1(C1PrintDocument doc)
        {
            doc.Clear();
            doc.PageLayout.PageSettings.PaperKind = System.Drawing.Printing.PaperKind.A4;
            if (System.Threading.Thread.CurrentThread.CurrentUICulture.Name != "en-US")
            {
                doc.PageLayout.PageFooter = new RenderText("第[PageNo]页, 共[PageCount]页");
            }
            else
            {
                doc.PageLayout.PageFooter = new RenderText("Page [PageNo] of [PageCount]");
            }
            doc.PageLayout.PageFooter.Style.TextAlignHorz = AlignHorzEnum.Right;
            doc.PageLayout.PageFooter.Style.TextAlignVert = AlignVertEnum.Top;
            doc.PageLayout.PageFooter.Height = "1cm";


            RenderTable renderTable = new RenderTable();

            renderTable.Style.GridLines.All   = LineDef.Default;
            renderTable.Style.TextAlignHorz   = AlignHorzEnum.Center;
            renderTable.Style.TextAlignVert   = AlignVertEnum.Bottom;
            renderTable.Style.Font            = new Font("宋体", 9);
            renderTable.CellStyle.Padding.All = "1mm";
            renderTable.Width             = Unit.Auto;
            renderTable.Style.FlowAlign   = FlowAlignEnum.Center;
            renderTable.RepeatBordersHorz = false;
            PrintTable(renderTable);
            if (printTableWidth > 190)
            {
                doc.PageLayout.PageSettings.Landscape    = true;
                doc.PageLayout.PageSettings.TopMargin    = new Unit(10, UnitTypeEnum.Mm);
                doc.PageLayout.PageSettings.BottomMargin = new Unit(5, UnitTypeEnum.Mm);
                doc.PageLayout.PageSettings.LeftMargin   = new Unit(5, UnitTypeEnum.Mm);
                doc.PageLayout.PageSettings.RightMargin  = new Unit(5, UnitTypeEnum.Mm);
            }
            else
            {
                doc.PageLayout.PageSettings.Landscape    = false;
                doc.PageLayout.PageSettings.TopMargin    = new Unit(10, UnitTypeEnum.Mm);
                doc.PageLayout.PageSettings.BottomMargin = new Unit(5, UnitTypeEnum.Mm);
                doc.PageLayout.PageSettings.LeftMargin   = new Unit(5, UnitTypeEnum.Mm);
                doc.PageLayout.PageSettings.RightMargin  = new Unit(5, UnitTypeEnum.Mm);
            }
            setCaption(renderTable);

            //表头
            RenderText title = new RenderText(GlobalCofigData.PrintConfig.SheetTitle);   //(Settings.Default.tablePageHeat);

            title.Style.Font          = new Font("宋体", 14);
            title.Style.TextAlignHorz = AlignHorzEnum.Center;
            title.Style.Padding.All   = "5mm";
            doc.Body.Children.Add(title);


            RenderText  printTestDate = GetPrintTestData();
            RenderTable tableNote     = GetPrintNote();

            doc.Body.Children.Add(printTestDate);
            doc.Body.Children.Add(renderTable);
            doc.Body.Children.Add(tableNote);
        }
Exemplo n.º 11
0
        private void MakeDoc1(C1PrintDocument doc)
        {
            doc.Clear();

            Random rnd = new Random((int)DateTime.Now.Ticks);

            int n;
            // make a table
            RenderTable rt1 = new RenderTable();

            // set up some styles on the table
            //
            // Note: all style attributes are divided into ambient and non-ambient.
            // Ambient attributes affect the data itself, whereas non-ambient attributes
            // are those affecting the decorations. Examples of ambient are:
            // Font, TextColor, text alignment. Examples of non-ambient are:
            // Borders, Padding, Spacing.
            // Ambient attributes are propagated via the objects containment,
            // so that e.g. setting the Font on the table will affect text in cells.
            // Non-ambient attributes are inherited via the styles hierarchy. In tables,
            // to set a non-ambient on all cells, table.CellStyle should be used. Ambient
            // attributes can be set via table.Style:
            rt1.Style.GridLines.All   = LineDef.Default;
            rt1.Style.TextAlignHorz   = AlignHorzEnum.Right;
            rt1.Style.Font            = new Font("Courier New", 12);
            rt1.Style.TextColor       = Color.Green;
            rt1.CellStyle.Padding.All = "1mm";

            // fill the table with more or less random data
            int nrows = rnd.Next(100, 500);
            int ncols = rnd.Next(2, 4);

            for (int row = 0; row < nrows; ++row)
            {
                for (int col = 0; col < ncols; ++col)
                {
                    n = rnd.Next();
                    rt1.Cells[row, col].Text  = n.ToString();
                    rt1.Cells[nrows, col].Tag = rt1.Cells[nrows, col].Tag == null ? n :
                                                n + (long)rt1.Cells[nrows, col].Tag;
                }
            }

            // table headers and footers are implemented as row groups.

            // The header:
            // insert 2 rows for the header at the top:
            rt1.Rows.Insert(0, 2);
            // mark the top row as a table header (not repeated),
            // set it up appropriately:
            rt1.RowGroups[0, 1].Header          = TableHeaderEnum.None;
            rt1.RowGroups[0, 1].Style.BackColor = Color.GreenYellow;
            rt1.Cells[0, 0].SpanCols            = rt1.Cols.Count;
            rt1.Cells[0, 0].Text =
                "This table is filled with random data. It also has a table header (this text), " +
                "running headers with column captions, running footers duplicating the running headers, " +
                "and a footer which prints the column totals.";
            rt1.Cells[0, 0].Style.TextAlignHorz = AlignHorzEnum.Center;
            rt1.Cells[0, 0].Style.Font          = new Font("Courier New", 14, FontStyle.Bold);
            // mark the 2nd row as a page header (i.e. repeated on each page).
            rt1.RowGroups[1, 1].Header          = TableHeaderEnum.All;
            rt1.RowGroups[1, 1].Style.TextColor = Color.Honeydew;
            rt1.RowGroups[1, 1].Style.BackColor = Color.DarkKhaki;
            for (int col = 0; col < ncols; ++col)
            {
                rt1.Cells[1, col].Text = string.Format("Column {0}", col);
            }

            // The footer:
            // We used the last row for totals. We push it down
            // (to be printed at the very bottom of the table), and add
            // a "running footer" in front, with column headers to be
            // printed on each page:
            n = rt1.Rows.Count - 1;
            rt1.Rows.Insert(n, 1);
            // Orphan control:
            // this line makes sure that at least 3 lines are printed before the
            // footer on the same page.
            rt1.RowGroups[n, 1].MinVectorsBefore = 3;
            rt1.RowGroups[n, 1].Footer           = TableFooterEnum.All;
            rt1.RowGroups[n, 1].Style.TextColor  = rt1.RowGroups[1, 1].Style.TextColor;
            rt1.RowGroups[n, 1].Style.BackColor  = rt1.RowGroups[1, 1].Style.BackColor;
            for (int col = 0; col < ncols; ++col)
            {
                rt1.Cells[n, col].Text = rt1.Cells[1, col].Text;
            }

            // the final footer with totals and a line saying "the end":
            n = rt1.Rows.Count - 1;
            rt1.RowGroups[n, 2].Footer          = TableFooterEnum.None;
            rt1.RowGroups[n, 2].Style.BackColor = Color.SandyBrown;
            for (int col = 0; col < ncols; ++col)
            {
                rt1.Cells[n, col].Text = ((long)rt1.Cells[n, col].Tag).ToString();
            }
            rt1.Cells[n + 1, 0].SpanCols            = rt1.Cols.Count;
            rt1.Cells[n + 1, 0].Text                = "The end.";
            rt1.Cells[n + 1, 0].Style.TextAlignHorz = AlignHorzEnum.Center;

            doc.Body.Children.Add(rt1);
        }
Exemplo n.º 12
0
        private void MakeDoc2(C1PrintDocument doc)
        {
            doc.Clear();
            doc.PageLayout.PageSettings.PaperKind = System.Drawing.Printing.PaperKind.A4;
            if (System.Threading.Thread.CurrentThread.CurrentUICulture.Name != "en-US")
            {
                doc.PageLayout.PageFooter = new RenderText("第[PageNo]页, 共[PageCount]页");
            }
            else
            {
                doc.PageLayout.PageFooter = new RenderText("Page [PageNo] of [PageCount]");
            }
            doc.PageLayout.PageSettings.Landscape         = false;
            doc.PageLayout.PageSettings.TopMargin         = new Unit(10, UnitTypeEnum.Mm);
            doc.PageLayout.PageSettings.BottomMargin      = new Unit(5, UnitTypeEnum.Mm);
            doc.PageLayout.PageSettings.LeftMargin        = new Unit(30, UnitTypeEnum.Mm);
            doc.PageLayout.PageSettings.RightMargin       = new Unit(30, UnitTypeEnum.Mm);
            doc.PageLayout.PageFooter.Style.TextAlignHorz = AlignHorzEnum.Right;
            doc.PageLayout.PageFooter.Style.TextAlignVert = AlignVertEnum.Top;
            doc.PageLayout.PageFooter.Height = "1cm";


            //计算爆炸概率
            int recordCount = DataOperate.printData.Rows.Count;

            for (int i = 0; i < recordCount; i++)
            {
            }


            RenderTable renderTable = new RenderTable();

            renderTable.Style.GridLines.All              = LineDef.Default;
            renderTable.Style.TextAlignHorz              = AlignHorzEnum.Center;
            renderTable.Style.TextAlignVert              = AlignVertEnum.Bottom;
            renderTable.Style.Font                       = new Font("宋体", 9);
            renderTable.CellStyle.Padding.All            = "1mm";
            renderTable.CellStyle.ImageAlign.StretchHorz = false;
            renderTable.CellStyle.ImageAlign.StretchVert = false;
            renderTable.Style.FlowAlign                  = FlowAlignEnum.Center;
            renderTable.RepeatBordersHorz                = false;
            PrintTable2(renderTable, 0);


            //表头
            RenderText title = new RenderText(GlobalCofigData.PrintConfig.ReportTitle);   //(Settings.Default.tablePageHeat);

            title.Style.Font           = new Font("宋体", 14);
            title.Style.TextAlignHorz  = AlignHorzEnum.Center;
            title.Style.Padding.Top    = "10mm";
            title.Style.Padding.Bottom = "2mm";
            doc.Body.Children.Add(title);

            printTableWidth = 210 - (int)doc.PageLayout.PageSettings.LeftMargin.Value - (int)doc.PageLayout.PageSettings.RightMargin.Value;
            RenderText  printTestDate = GetPrintTestData();
            RenderTable tableNote     = GetPrintNote();

            //   if (i != recordCount - 1) tableNote.BreakAfter = BreakEnum.Page;

            doc.Body.Children.Add(printTestDate);
            doc.Body.Children.Add(renderTable);
            doc.Body.Children.Add(tableNote);

            //RenderText blank = new RenderText(" ");//(Settings.Default.tablePageHeat);
            //blank.Style.Padding.All = "10mm";
            //doc.Body.Children.Add(blank);
        }
Exemplo n.º 13
0
        /*private RenderObject CreateItem(string caption, Style style)
         * {
         *  RenderArea result = new RenderArea();
         *  result.Style.Padding.All = "1mm";
         *
         *  RenderText rt = new RenderText();
         *  rt.Text = caption;
         *  rt.Style.AmbientParent = style;
         *  result.Children.Add(rt);
         *
         *  RenderInputText rit = new RenderInputText();
         *  rit.Style.AmbientParent = style;
         *  rit.Width = "parent.width";
         *  result.Children.Add(rit);
         *
         *  return result;
         * }*/

        private void GenerateDoc(C1PrintDocument doc)
        {
            doc.Clear();
            RenderTable       ph      = new RenderTable(doc);
            RenderInputButton rbPrior = new RenderInputButton(doc, "<<");

            rbPrior.InputActions.Add(
                UserActionEnum.Click,
                new ActionHandlerLink(new C1LinkTargetPage(PageJumpTypeEnum.Previous)));
            RenderInputButton rbNext = new RenderInputButton(doc, ">>");

            rbNext.X = "parent.Width - width";
            rbNext.InputActions.Add(
                UserActionEnum.Click,
                new ActionHandlerLink(new C1LinkTargetPage(PageJumpTypeEnum.Next)));
            ph.Cells[0, 0].Area.Children.Add(rbPrior);
            ph.Cells[0, 1].Area.Children.Add(rbNext);
            ph.Style.Borders.Bottom = new LineDef("1pt", Color.Black);
            ph.Style.Spacing.Bottom = "5mm";

            doc.PageLayout.PageHeader = ph;

            doc.PageLayout.PageFooter = new RenderText(doc, "Page [PageNo] of [PageCount]", AlignHorzEnum.Right);

            // create styles
            _captionStyle                = doc.Style.Children.Add();
            _captionStyle.Font           = new Font("Tahoma", 16, FontStyle.Bold);
            _captionStyle.BackColor      = Color.FromArgb(208, 237, 253);
            _captionStyle.Spacing.Bottom = "5mm";

            _fieldCaptionStyle      = doc.Style.Children.Add();
            _fieldCaptionStyle.Font = new Font("Tahoma", 13);

            _requiredCharStyle           = doc.Style.Children.Add();
            _requiredCharStyle.Parents   = _fieldCaptionStyle;
            _requiredCharStyle.TextColor = Color.Red;

            _passwordInfoStyle              = doc.Style.Children.Add();
            _passwordInfoStyle.Parents      = _fieldCaptionStyle;
            _passwordInfoStyle.TextPosition = TextPositionEnum.Subscript;

            _textFieldStyle      = doc.Style.Children.Add();
            _textFieldStyle.Font = new Font("Tahoma", 12, FontStyle.Bold);

            // Personal information
            doc.Body.Children.Add(new RenderText(doc, "Personal information", _captionStyle, _captionStyle));
            // create RenderTable containing the form's fields
            RenderTable rt = new RenderTable(doc);

            rt.CellStyle.Padding.All    = "0.5mm";
            rt.Cells[0, 0].RenderObject = CreateFieldCaption(doc, "First name:", true, false);
            rt.Cells[1, 0].RenderObject = CreateTextField(doc, "FirstName", Color.Black, false);

            rt.Cells[0, 1].RenderObject = CreateFieldCaption(doc, "Last name:", true, false);
            rt.Cells[1, 1].RenderObject = CreateTextField(doc, "LastName", Color.Black, false);

            rt.Cells[2, 0].RenderObject = CreateFieldCaption(doc, "Email Address:", true, false);
            rt.Cells[3, 0].RenderObject = CreateTextField(doc, "EmailAddress", Color.Blue, false);

            rt.Cells[2, 1].RenderObject = CreateFieldCaption(doc, "Retype Email Address:", true, false);
            rt.Cells[3, 1].RenderObject = CreateTextField(doc, "RetypeEmailAddress", Color.Blue, false);

            rt.Cells[4, 0].RenderObject = CreateFieldCaption(doc, "Password:"******"Password", Color.Black, true);

            rt.Cells[4, 1].RenderObject = CreateFieldCaption(doc, "Retype Password:"******"RetypePassword", Color.Black, true);

            rt.Cells[6, 0].RenderObject = CreateFieldCaption(doc, "City:", false, false);
            rt.Cells[7, 0].RenderObject = CreateTextField(doc, "City", Color.Black, false);

            rt.Cells[6, 1].RenderObject = CreateFieldCaption(doc, "State:", false, false);
            rt.Cells[7, 1].RenderObject = CreateTextField(doc, "State", Color.Black, false);

            // add the "Select" button
            RenderArea        ra = new RenderArea(doc);
            RenderInputButton rb = new RenderInputButton(doc, "Select...");

            rb.Name = "Select";
            rb.X    = "parent.Width - width";
            ra.Children.Add(rb);
            rt.Cells[8, 1].RenderObject = ra;

            // Work status field
            rt.Cells[9, 0].RenderObject = CreateFieldCaption(doc, "Work status:", true, false);
            rt.Cells[9, 0].SpanCols     = 2;

            rt.Cells[10, 0].RenderObject = new RenderInputRadioButton(doc, "StatusCitizen", "I am a citizen");
            ((RenderInputRadioButton)rt.Cells[10, 0].RenderObject).Checked = true;
            rt.Cells[10, 1].RenderObject = new RenderInputRadioButton(doc, "StatusAny", "I am authorized to work for any employer");
            rt.Cells[11, 0].RenderObject = new RenderInputRadioButton(doc, "StatusCurrent", "I am authorized to work for my current employer");
            rt.Cells[11, 1].RenderObject = new RenderInputRadioButton(doc, "StatusSeeking", "I am seeking authorization");
            rt.Style.Spacing.Bottom      = "5mm";
            doc.Body.Children.Add(rt);

            //
            doc.Body.Children.Add(new RenderText(doc, "Interests", _captionStyle, _captionStyle));

            rt = new RenderTable(doc);
            rt.Cells[0, 0].RenderObject = new RenderInputCheckBox(doc, "Accounting");
            rt.Cells[0, 1].RenderObject = new RenderInputCheckBox(doc, "General Business");
            rt.Cells[0, 2].RenderObject = new RenderInputCheckBox(doc, "Pharmaceutical");
            rt.Cells[1, 0].RenderObject = new RenderInputCheckBox(doc, "Admin & Clerical");
            rt.Cells[1, 1].RenderObject = new RenderInputCheckBox(doc, "General Labor");
            rt.Cells[1, 2].RenderObject = new RenderInputCheckBox(doc, "Professional Services");
            rt.Cells[2, 0].RenderObject = new RenderInputCheckBox(doc, "Automotive");
            rt.Cells[2, 1].RenderObject = new RenderInputCheckBox(doc, "Government");
            rt.Cells[2, 2].RenderObject = new RenderInputCheckBox(doc, "QA - Quality Control");
            rt.Cells[2, 0].RenderObject = new RenderInputCheckBox(doc, "Biotech");
            rt.Cells[2, 1].RenderObject = new RenderInputCheckBox(doc, "Information Technology");
            rt.Cells[2, 2].RenderObject = new RenderInputCheckBox(doc, "Warehouse");
            rt.BreakAfter = BreakEnum.Page;
            doc.Body.Children.Add(rt);


            doc.Body.Children.Add(new RenderText(doc, "Desired Position", _captionStyle, _captionStyle));
            doc.Body.Children.Add(new RenderText(doc, "Describe your desired position by completing as many of the following questions as possible.\n\nPlease indicate the wage you are seeking."));

            rt = new RenderTable(doc);
            rt.Cells[0, 0].RenderObject = new RenderInputCheckBox(doc, "Full-time");
            rt.Cells[0, 1].RenderObject = new RenderInputCheckBox(doc, "Part-time");
            rt.Cells[0, 2].RenderObject = new RenderInputCheckBox(doc, "Intern");
            rt.Cells[1, 0].RenderObject = new RenderInputCheckBox(doc, "Seasonal");
            rt.Cells[1, 1].RenderObject = new RenderInputCheckBox(doc, "Temporary");
            rt.Style.Spacing.Bottom     = "5mm";
            doc.Body.Children.Add(rt);

            doc.Body.Children.Add(new RenderText(doc, "How many miles are you willing to commute to work?"));
            RenderInputComboBox rc = new RenderInputComboBox(
                doc,
                "-- Select Distance --",
                "1 mile",
                "5 miles",
                "10 miles",
                "25 miles",
                "50 miles",
                "100 miles");

            rc.Text                 = rc.Items[0].Text;
            rc.Style.Parents        = _textFieldStyle;
            rc.Style.Spacing.Bottom = "5mm";
            doc.Body.Children.Add(rc);

            doc.Body.Children.Add(new RenderText(doc, "How often are you willing to travel for work?"));
            rc = new RenderInputComboBox(
                doc,
                "Negligible",
                "Up to 25%",
                "Up to 50%",
                "Road Warrior");
            rc.DropDownStyle = ComboBoxStyle.DropDownList;
            rc.Text          = rc.Items[0].Text;
            doc.Body.Children.Add(rc);

            // Save button
            rb = new RenderInputButton(doc, "Save...");
            rb.AcceptButton = true;
            rb.InputActions.Add(
                UserActionEnum.Click,
                new ActionHandlerFileSave());
            doc.Body.Children.Add(rb);

            rb = new RenderInputButton(doc, "Save as PDF...");
            rb.InputActions.Add(
                UserActionEnum.Click,
                new ActionHandlerFileSave(null, ExportProviders.PdfExportProvider));
            doc.Body.Children.Add(rb);


            doc.Generate();
        }
Exemplo n.º 14
0
        /// <summary>
        /// Creates a document where almost all RenderObject types provided by C1Preview
        /// are used/demonstrated.
        /// </summary>
        /// <param name="doc">The document to add render objects to.</param>
        private void MakeDoc1(C1PrintDocument doc)
        {
            // clear the document
            doc.Clear();

            // Set up basic page headers and footers:
            doc.PageLayout.PageHeader = new RenderText("RenderObjects sample");
            doc.PageLayout.PageHeader.Style.TextAlignHorz  = AlignHorzEnum.Right;
            doc.PageLayout.PageHeader.Style.Spacing.Bottom = "0.5cm";
            doc.PageLayout.PageHeader.Style.Borders.Bottom = LineDef.Default;

            doc.PageLayout.PageFooter = new RenderText("Page [PageNo] of [PageCount]");
            doc.PageLayout.PageFooter.Style.TextAlignHorz = AlignHorzEnum.Right;
            doc.PageLayout.PageFooter.Style.Spacing.Top   = "0.5cm";
            doc.PageLayout.PageFooter.Style.Borders.Top   = LineDef.Default;


            //-------------
            // RenderArea
            //-------------
            // The general purpose container for other render objects
            // We create an area for a few RenderText objects,
            // and add it to another are which is a container for all elements in the document:
            RenderArea ra1 = new RenderArea();

            RenderArea ra2 = new RenderArea();

            // set the back color for the area so its bounds are visible
            ra2.Style.BackColor = Color.AntiqueWhite;
            // keep the area to 60% of its parent's width
            ra2.Width = "60%";

            // Add the area which will hold the render texts, to
            // the bigger area which will hold all else
            ra1.Children.Add(ra2);

            //-------------
            // RenderText
            //-------------
            // Allows to output a block of text in a single style
            // we also create an outline entry for each RenderText

            // plain text using the default style
            RenderText rt1 = new RenderText(strings.APOLOGIZE);

            doc.Outlines.Add("APOLOGIZE", rt1);

            // different font and color
            RenderText rt2 = new RenderText(strings.APPEAL, new Font("Arial", 16), Color.BlueViolet);

            doc.Outlines.Add("APPEAL", rt2);

            // right-alignged text
            RenderText rt3 = new RenderText(strings.BAROMETER, AlignHorzEnum.Right);

            doc.Outlines.Add("BAROMETER", rt3);

            // justified text in a different font
            RenderText rt4 = new RenderText(strings.BOTANY, new Font("Times New Roman", 14), AlignHorzEnum.Justify);

            doc.Outlines.Add("BOTANY", rt4);

            // text with a different style
            // styles can only exist on an object or as child styles of another style
            Style s1 = doc.Style.Children.Add();

            s1.BackColor   = Color.Chartreuse;
            s1.Padding.All = new Unit("3mm");
            s1.LineSpacing = 120;
            RenderText rt5 = new RenderText(strings.CALAMITY, s1);

            doc.Outlines.Add("CALAMITY", rt5);

            // add RenderText's to the nested area
            ra2.Children.Add(rt1);
            ra2.Children.Add(rt2);
            ra2.Children.Add(rt3);
            ra2.Children.Add(rt4);
            ra2.Children.Add(rt5);

            //---------------
            // RenderGraphics
            //---------------
            // Allows to insert arbitrary GDI+ drawings in the document
            // Note that RenderGraphics' size is by default automatically adjusted
            // to the actual size of the drawing.
            RenderGraphics rg1 = new RenderGraphics();

            rg1.Graphics.DrawArc(Pens.Red,
                                 new Rectangle(0, 0, 30, 40), 0, 135);
            rg1.Graphics.DrawEllipse(Pens.Blue, new Rectangle(20, 20, 90, 45));
            rg1.Style.Borders.All = new LineDef("1mm", Color.CornflowerBlue);
            ra1.Children.Add(rg1);
            // provide an outline entry for the RenderGraphics
            doc.Outlines.Add("RenderGraphics", rg1);

            //-------------
            // RenderEmpty
            //-------------
            // Allows to insert breaks in arbitrary locations w/out affecting other render objects
            RenderEmpty re1 = new RenderEmpty();

            re1.BreakAfter = BreakEnum.Column;
            ra1.Children.Add(re1);

            //---------------
            // RenderImage
            //---------------
            // Allows to insert images in the document. Again, by default the size
            // is determined by the size of the image
            RenderImage ri1 = new RenderImage(Image.FromStream(
                                                  GetType().Assembly.GetManifestResourceStream("RenderObjects.tn_img70.jpg")));

            ra1.Children.Add(ri1);
            doc.Outlines.Add("RenderImage", ri1);

            //---------------
            // RenderRichText
            //---------------
            // Allows to insert RTF in the document
            TextReader tr = new StreamReader(
                GetType().Assembly.GetManifestResourceStream("RenderObjects.Rich_Text_Format.rtf"));
            RenderRichText rrt1 = new RenderRichText(tr.ReadToEnd());

            tr.Close();
            ra1.Children.Add(rrt1);
            doc.Outlines.Add("RenderRichText", rrt1);

            //--------------
            // RenderPolygon
            //--------------
            // A bunch of classes derived from RenderShapeBase provide shapes -
            // lines, polygons and rectangles. Here we draw a polygon:
            RenderPolygon rpoly1 = new RenderPolygon();

            rpoly1.Line.Points = new UnitPoint[] {
                new UnitPoint("0.5cm", "0.5cm"),
                new UnitPoint("2.0cm", "1cm"),
                new UnitPoint("3.5cm", "0cm"),
                new UnitPoint("6cm", "4cm"),
                new UnitPoint("3cm", "5cm")
            };
            rpoly1.Line.Closed = true;
            // set the fill color
            rpoly1.Style.ShapeFillColor = Color.Gainsboro;
            // pad on all sides, otherwise corners may end up outside of the
            // RenderPolygon area and get clipped:
            rpoly1.Style.Padding.All = "0.5cm";
            rpoly1.Style.BackColor   = Color.Cornsilk;
            ra1.Children.Add(rpoly1);
            doc.Outlines.Add("RenderPolygon", rpoly1);

            //------------
            // RenderTable
            //------------
            // Allows to draw tables. Tables are very powerful and can be used
            // both for data presentation and as layout tools. Here we show
            // some very basic tables functionality:
            RenderTable rtbl1 = new RenderTable();

            // tables are logically infinte, just touching a cell creates it:
            for (int row = 0; row < 100; ++row)
            {
                for (int col = 0; col < 4; ++col)
                {
                    rtbl1.Cells[row, col].Text = string.Format("Cell ({0}, {1})", row, col);
                }
            }
            // column (see below, in headers) and row spans are supported,
            // as alignment within cells, borders around cells and more:
            rtbl1.Cells[8, 1].SpanRows            = 6;
            rtbl1.Cells[8, 1].Style.BackColor     = Color.Gold;
            rtbl1.Cells[8, 1].Style.TextAlignVert = AlignVertEnum.Center;
            rtbl1.Cells[8, 1].Style.TextAlignHorz = AlignHorzEnum.Center;
            rtbl1.Cells[8, 1].Style.Borders.All   = LineDef.DefaultBold;

            // table header is just a flag on some rows:
            rtbl1.Rows.Insert(0, 1);
            rtbl1.RowGroups[0, 1].PageHeader      = true;
            rtbl1.Cells[0, 0].SpanCols            = rtbl1.Cols.Count;
            rtbl1.Cells[0, 0].Text                = "This is table header";
            rtbl1.Cells[0, 0].Style.TextAlignHorz = AlignHorzEnum.Center;
            rtbl1.Cells[0, 0].Style.BackColor     = Color.LemonChiffon;
            // ditto for the table footer:
            // (again, just touching a row adds it):
            int n = rtbl1.Rows.Count;

            rtbl1.RowGroups[n, 1].PageFooter      = true;
            rtbl1.Cells[n, 0].SpanCols            = rtbl1.Cols.Count;
            rtbl1.Cells[n, 0].Text                = "This is table footer";
            rtbl1.Cells[n, 0].Style.TextAlignHorz = AlignHorzEnum.Center;
            rtbl1.Cells[n, 0].Style.BackColor     = Color.LemonChiffon;
            // by default, tables have no grid lines. add some:
            rtbl1.Style.GridLines.All = LineDef.Default;

            // Using RenderEmpty, we can add outline nodes to start and end of table:
            RenderEmpty rtbl1Beg = new RenderEmpty();
            RenderEmpty rtbl1End = new RenderEmpty();

            ra1.Children.Add(rtbl1Beg);
            ra1.Children.Add(rtbl1);
            ra1.Children.Add(rtbl1End);
            doc.Outlines.Add("Table - first row", rtbl1Beg);
            doc.Outlines.Add("Table - last row", rtbl1End);

            //---------------
            // RenderParagraph
            //---------------
            // Allows to render milti-line text, inline images, and hyperlinks within text
            // Create paragraph
            RenderParagraph rpar1 = new RenderParagraph();
            Font            f     = new Font(rpar1.Style.Font, FontStyle.Bold);

            rpar1.Content.AddText("This is a paragraph. This is normal text. ");
            rpar1.Content.AddText("This text is bold. ", f);
            rpar1.Content.AddText("This text is red. ", Color.Red);
            rpar1.Content.AddText("This text is superscript. ",
                                  TextPositionEnum.Superscript);
            rpar1.Content.AddText("This text is bold and red. ", f, Color.Red);
            rpar1.Content.AddText("This text is bold and red and subscript. ",
                                  f, Color.Red, TextPositionEnum.Subscript);
            rpar1.Content.AddText("This is normal text again. ");
            rpar1.Content.AddHyperlink(
                "This is a link to the start of the document.",
                ra1);
            rpar1.Content.AddText("Finally, here is an inline image: ");
            rpar1.Content.AddImage(this.Icon.ToBitmap());
            rpar1.Content.AddText(".");
            // Add paragraph to the area
            ra1.Children.Add(rpar1);
            // and an outline entry to point to it:
            doc.Outlines.Add("RenderParagraph", rpar1);

            // we're done. Add the outer RenderArea to the document:
            doc.Body.Children.Add(ra1);
        }
Exemplo n.º 15
0
        private void MakeDoc1(C1PrintDocument doc)
        {
            doc.Clear();

            RenderText rtxt1 = new RenderText(doc);

            rtxt1.Text = "This test shows the basic features of tables in C1PrintDocument:\n"
                         + "\t- table borders (the GridLines style property, which allows to specify 4 outer and 2 inner lines);\n"
                         + "\t- borders around individual cells and groups of cells;\n"
                         + "\t- style attributes (including borders) for groups of disconnected cells;\n"
                         + "\t- cells spanning rows and columns;\n"
                         + "\t- content alignment within the cells (spanned or otherwise);\n"
                         + "\t- table headers and footers;\n"
                         + "\t- tags (such as page number/total page count) anywhere in the document (see the table footer);\n"
                         + "\t- different style attributes including borders, font and background images.\n"
                         + "\t  \n"
            ;
            rtxt1.Style.Font           = new Font(rtxt1.Style.Font.FontFamily, 14);
            rtxt1.Style.Padding.Bottom = new Unit("5mm");
            doc.Body.Children.Add(rtxt1);

            //
            // make a table and fill all its cells with some demo data
            RenderTable rt1  = new RenderTable(doc);
            const int   ROWS = 100;
            const int   COLS = 4;

            for (int row = 0; row < ROWS; ++row)
            {
                for (int col = 0; col < COLS; ++col)
                {
                    RenderText celltext = new RenderText(doc);
                    celltext.Text = string.Format("Cell ({0},{1})", row, col);
                    // Note that rt1.Cells[row, col] will create cells on demand -
                    // no need to specify the number of rows/cols initially.
                    rt1.Cells[row, col].RenderObject = celltext;
                }
            }
            // add the table to the document
            doc.Body.Children.Add(rt1);

            //
            // unlike the old print-doc, in the new one changes can be made at any
            // point in the program, and they will be reflected in the document when
            // it is rendered. Add some customizations to the table:

            //
            // by default, tables have no borders. add a simple border:
            rt1.Style.GridLines.All  = new LineDef("2pt", Color.DarkGray);
            rt1.Style.GridLines.Horz = new LineDef("1pt", Color.Blue);
            rt1.Style.GridLines.Vert = new LineDef("1pt", Color.Brown);

            //
            // table headers and footers

            // add a table header:
            // setup the header as a whole
            rt1.RowGroups[0, 2].PageHeader            = true;
            rt1.RowGroups[0, 2].Style.BackgroundImage = global::Tables2.Properties.Resources.orange;
            rt1.RowGroups[0, 2].Style.BackgroundImageAlign.StretchHorz     = true;
            rt1.RowGroups[0, 2].Style.BackgroundImageAlign.StretchVert     = true;
            rt1.RowGroups[0, 2].Style.BackgroundImageAlign.KeepAspectRatio = false;
            // multiple inheritance supported in styles: the text color from the
            // group's style will merge with the font from the cell's own style:
            rt1.RowGroups[0, 2].Style.TextColor      = Color.LightGreen;
            rt1.RowGroups[0, 2].Style.GridLines.All  = new LineDef("2pt", Color.DarkCyan);
            rt1.RowGroups[0, 2].Style.GridLines.Horz = LineDef.Empty;
            rt1.RowGroups[0, 2].Style.GridLines.Vert = LineDef.Empty;
            // setup specific cells in the header:
            ((RenderText)rt1.Cells[0, 0].RenderObject).Text = "Header row 0";
            ((RenderText)rt1.Cells[1, 0].RenderObject).Text = "Header row 1";
            rt1.Cells[0, 1].SpanCols     = 2;
            rt1.Cells[0, 1].SpanRows     = 2;
            rt1.Cells[0, 1].RenderObject = new RenderText(doc);
            ((RenderText)rt1.Cells[0, 1].RenderObject).Text = "Multi-row table headers and footers are supported";
            rt1.Cells[0, 1].Style.TextAlignHorz             = AlignHorzEnum.Center;
            rt1.Cells[0, 1].Style.Font = new Font("Arial", 14, FontStyle.Bold);

            // setup a table footer
            rt1.RowGroups[rt1.Rows.Count - 2, 2].PageFooter                  = true;
            rt1.RowGroups[rt1.Rows.Count - 2, 2].Style.BackColor             = Color.LemonChiffon;
            rt1.Cells[rt1.Rows.Count - 2, 0].SpanRows                        = 2;
            rt1.Cells[rt1.Rows.Count - 2, 0].SpanCols                        = rt1.Cols.Count - 1;
            rt1.Cells[rt1.Rows.Count - 2, 0].Style.TextAlignHorz             = AlignHorzEnum.Center;
            rt1.Cells[rt1.Rows.Count - 2, 0].Style.TextAlignVert             = AlignVertEnum.Center;
            ((RenderText)rt1.Cells[rt1.Rows.Count - 2, 0].RenderObject).Text = "This is a table footer.";
            rt1.Cells[rt1.Rows.Count - 2, 3].SpanRows                        = 2;
            rt1.Cells[rt1.Rows.Count - 2, 3].Style.TextAlignHorz             = AlignHorzEnum.Right;
            // tags (such as page no/page count) can be inserted anywhere in the document
            ((RenderText)rt1.Cells[rt1.Rows.Count - 2, 3].RenderObject).Text = "Page [PageNo] of [PageCount]";

            //
            // in tables, Style.Borders merges seamlessly into the table grid lines:

            // it is easy to put a border around specific cells:
            rt1.Cells[8, 3].Style.Borders.All = new LineDef("3pt", Color.OrangeRed);
            ((RenderText)rt1.Cells[8, 3].RenderObject).Text =
                "It is easy to put a border around a single cell using cell.Style.Borders";

            //
            // cells can be combined into groups, and their styles can be manipulated as
            // a single entity:

            // define a group of cells by specifying the rectangles bounding the cells:
            ((RenderText)rt1.Cells[3, 2].RenderObject).Text =
                "Cells can be combined into groups to be manipulated as a single entity " +
                "(such as all cells with the pale green background in this table).";
            rt1.Cells[3, 2].SpanCols = 2;
            rt1.Cells[3, 2].SpanRows = 3;
            Rectangle[] cells1 = new Rectangle[] {
                new Rectangle(2, 3, 2, 3),
                new Rectangle(0, 10, 3, 2),
                new Rectangle(1, 23, 2, 4),
                new Rectangle(1, 36, 1, 24),
                new Rectangle(0, 72, 3, 6),
            };
            UserCellGroup grp1 = new UserCellGroup(cells1);

            grp1.Style.BackColor   = Color.PaleGreen;
            grp1.Style.Font        = new Font("Arial", 12, FontStyle.Bold);
            grp1.Style.Borders.All = new LineDef("2pt", Color.DarkGreen);
            rt1.UserCellGroups.Add(grp1);


            // row/col span
            ((RenderText)rt1.Cells[14, 1].RenderObject).Text =
                "Column and row spans are fully supported, as well as alignment within the (spanned or not) cells.";
            rt1.Cells[14, 1].SpanCols            = 3;
            rt1.Cells[14, 1].SpanRows            = 5;
            rt1.Cells[14, 1].Style.Font          = new Font("Arial", 12, FontStyle.Bold | FontStyle.Italic);
            rt1.Cells[14, 1].Style.Borders.All   = new LineDef("2pt", Color.DarkOrange);
            rt1.Cells[14, 1].Style.TextAlignHorz = AlignHorzEnum.Center;
            rt1.Cells[14, 1].Style.TextAlignVert = AlignVertEnum.Center;
            rt1.RowGroups[14, 5].SplitBehavior   = SplitBehaviorEnum.SplitIfLarge;
        }
Exemplo n.º 16
0
        private void CreateDoc(C1PrintDocument doc)
        {
            doc.Clear();

            doc.PageLayout.PageSettings.Landscape = true;

            Style codeStyle = doc.Style.Children.Add();

            codeStyle.Font = new Font("Courier New", 12);
            Style captionStyle = doc.Style.Children.Add();

            captionStyle.Font = new Font("Tahoma", 18, FontStyle.Bold);

            RenderParagraph rp = new RenderParagraph();

            rp.Style.Borders.All = new LineDef("1mm", Color.Blue);
            rp.Style.BackColor   = Color.LightBlue;
            rp.Style.Font        = new Font("Tahoma", 16);
            rp.Content.Add(new ParagraphText("This sample demostrates using of HyperlinkPageNo tag\r\r", captionStyle));
            rp.Content.Add(new ParagraphText("It returns number of page that hyperlink points. For example:\r\r"));
            rp.Content.Add(new ParagraphText("rt = new RenderText();\r", codeStyle));
            rp.Content.Add(new ParagraphText("rt.Text = \"(C1LinkTargetDocumentLocation) Goto page: [HyperlinkPageNo]\";\r", codeStyle));
            rp.Content.Add(new ParagraphText("rt.Hyperlink = new C1Hyperlink(new C1LinkTargetDocumentLocation(rt2));\r", codeStyle));
            rp.Content.Add(new ParagraphText("rt.Style.Borders.All = LineDef.Default;\r", codeStyle));
            rp.Content.Add(new ParagraphText("doc.Body.Children.Add(rt);", codeStyle));
            rp.Content.Add(new ParagraphText("\r\rTag HyperlinkPageNo will be replaced with number of page where object rt2 is.\r"));
            rp.Content.Add(new ParagraphText("It must be taken into consideration that when the document is being resolved, it is not always possible to evaluate HyperlinkPageNo (e.g. if it references an object that has not been resolved yet). "));
            rp.Content.Add(new ParagraphText("In such cases, if the object contains many HyperlinkPageNo tags and has auto width and/or height, the calculated size may differ from the correct size as instead of actual page numbers, the string \"XXX\" is used for size calculation.\r"));
            rp.Content.Add(new ParagraphText("To minimize such errors::\r"));
            rp.Content.Add(new ParagraphText("- use absolute sizes for such objets;\r"));
            rp.Content.Add(new ParagraphText("- place hyperlinks after the objects they reference.\r\r"));
            rp.Content.Add(new ParagraphText("In this sample, the document contains two RenderParagraph objects, each of which has HyperlinkPageNo tags. "));
            rp.Content.Add(new ParagraphText("The first paragraph is placed before the table, and hence its size is slightly bigger. The other paragraph follows the table and hence its size is exactly right."));
            doc.Body.Children.Add(rp);

            doc.Style.Font = new Font("Tahoma", 16);

            // generate siple table (3 x 100)
            RenderTable rt = new RenderTable();

            for (int r = 0; r < 100; r++)
            {
                for (int c = 0; c < 3; c++)
                {
                    rt.Cells[r, c].Text = string.Format("Cell {0}:{1}", r, c);
                }
            }
            rt.Style.GridLines.All = LineDef.DefaultBold;

            // generate RenderParagraph with hyperlinks
            rp = new RenderParagraph();
            rp.Style.Borders.All = new LineDef("1mm", Color.Red);
            rp.Style.Spacing.All = "5mm";
            rp.Style.Padding.All = "1mm";
            rp.RepeatBordersVert = true;
            rp.Content.Add(new ParagraphText("Content:\r\r", new Font("Verdana", 20)));
            for (int r = 0; r < rt.Rows.Count; r++)
            {
                ParagraphText pt = new ParagraphText(string.Format("Row{0} ([HyperlinkPageNo])", r));
                pt.Hyperlink = new C1Hyperlink(new C1LinkTargetDocumentLocation(rt.Cells[r, 0]));
                rp.Content.Add(pt);
                if (r < rt.Rows.Count - 1)
                {
                    rp.Content.Add(new ParagraphText(", "));
                }
            }
            // add paragraph into document BEFORE table
            doc.Body.Children.Add(rp);
            // add table
            doc.Body.Children.Add(rt);

            // add paragraph into document AFTER table
            RenderParagraph rp2 = (RenderParagraph)rp.Clone();

            doc.Body.Children.Add(rp2);

            doc.Generate();
        }