Exemple #1
0
        private void Render(Stat stat)
        {
            using (Tag("h3"))
                Write(stat.Title);
            using (Tag("p"))
                Write(stat.Description);

            // todo refactor shit
            // this is a temporary stab
            if (stat is StackTraceStat sts)
            {
                RenderTable(
                    sts.StackTraceInfos.OrderByDescending(s => s.ThreadsCount),
                    ("Threads count", s => Write(s.ThreadsCount.ToString())),
                    ("Thread ids", s => RenderPossiblyExpandableList(s.ThreadIds, ", ", 10, 5)),
                    ("Stack trace", s => RenderStackTrace(s.StackTrace)));
            }
            else if (stat is TypesStat ts)
            {
                using (Tag("h4"))
                    Write("Top 20 by objects count");
                RenderTypesStatsTable(ts.TypesStats.OrderByDescending(s => s.Value.Count).Take(20));

                using (Tag("h4"))
                    Write("Top 20 by total size");
                RenderTypesStatsTable(ts.TypesStats.OrderByDescending(s => s.Value.TotalSize).Take(20));
            }
            else
            {
                throw new NotImplementedException();
            }
        }
Exemple #2
0
 private void Render(IReadOnlyList <Metric> reportMetrics)
 {
     RenderTable(
         reportMetrics,
         ("Metric name", metric => WriteMonospace(metric.Name)),
         ("Value", metric => WriteNumericTableValue(metric.Value.ToString())));
 }
Exemple #3
0
 private void RenderTypesStatsTable(IEnumerable <KeyValuePair <string, TypeStat> > typesStats)
 {
     RenderTable(
         typesStats,
         ("Type name", s => WriteMonospace(s.Key)),
         ("Method Table", s => WriteMonospace(s.Value.MethodTable?.ToString(LongHexFormatString) ?? NA)),
         ("Objects count", s => WriteNumericTableValue(s.Value.Count.ToString())),
         ("Total objects size", s => WriteNumericTableValue(s.Value.TotalSize.ToString())));
 }
Exemple #4
0
 private void RenderTypesStatsTable(IEnumerable <KeyValuePair <string, TypeStat> > typesStats)
 {
     RenderTable(
         typesStats,
         ("Type name", s => Write(s.Key)),
         ("Method Table", s => Write(s.Value.MethodTable.ToString())),
         ("Objects count", s => Write(s.Value.Count.ToString())),
         ("Total objects size", s => Write(s.Value.TotalSize.ToString())));
 }
Exemple #5
0
        private void button3_Click(object sender, EventArgs e)
        {
            doc.Clear();

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

            // add comment
            RenderParagraph desc = new RenderParagraph();

            desc.Content.Add(new ParagraphText(_desc3));
            desc.Style.Spacing.Bottom = "5mm"; // add empty space after comment
            desc.Style.BackColor      = Color.LightPink;
            doc.Body.Children.Add(desc);

            RenderTable table = CreateTable(3, 3, "Cell {0}:{1}");

            // center text in cells by vertical and horizontal
            table.Style.TextAlignHorz = AlignHorzEnum.Center;
            table.Style.TextAlignVert = AlignVertEnum.Center;
            table.ColumnSizingMode    = TableSizingModeEnum.Auto;
            table.Style.GridLines.All = LineDef.DefaultBold;
            // stretch all rows
            table.StretchRows = StretchTableEnum.AllVectors;
            // stretch all columns
            table.StretchColumns = StretchTableEnum.AllVectors;
            doc.Body.Children.Add(table);

            doc.Generate();
        }
Exemple #6
0
        private void Form1_Load(object sender, EventArgs e)
        {
            C1PrintDocument doc = new C1PrintDocument();

            // create a RenderTable object:
            RenderTable rt = new RenderTable();

            // adjust table's properties so that columns are auto-sized:
            // 1) By default, table width is set to parent (page) width,
            // for auto-sizing we must change it to auto (i.e. based on content):
            rt.Width = Unit.Auto;
            // 2) Set ColumnSizingMode to Auto (default means Fixed for columns):
            rt.ColumnSizingMode = TableSizingModeEnum.Auto;
            // that's it, now the table's columns will be auto-sized.

            // Turn table grid lines on to better see autosizing, add some padding:
            rt.Style.GridLines.All   = LineDef.Default;
            rt.CellStyle.Padding.All = "2mm";

            // add some data
            rt.Cells[0, 0].Text = "aaa";
            rt.Cells[0, 1].Text = "bbbbbbbbbb";
            rt.Cells[0, 2].Text = "cccccc";
            rt.Cells[1, 0].Text = "aaa aaa aaa";
            rt.Cells[1, 1].Text = "bbbbb";
            rt.Cells[1, 2].Text = "cccccc cccccc";
            rt.Cells[2, 2].Text = "zzzzzzzzzzzzzzz zz z";

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

            // show the document
            c1PrintPreviewControl1.Document = doc;
        }
Exemple #7
0
        /// <summary>
        /// Creates a data bound table with Title, Price and Stock columns.
        /// Price and Stock columns are auto-sized, whereas Title takes up
        /// the remaining spcae.
        /// </summary>
        /// <param name="bookList">AmazonBookDescription data source.</param>
        /// <returns>Created table.</returns>
        private RenderTable MakeTable_TitlePriceStock(object bookList)
        {
            // data bound table:
            RenderTable rt = new RenderTable();

            // Setting the sizing properties as follows make the last two columns (Price and StockAmount)
            // auto-adjust their widths, with the first column taking up the remaining space (it contais
            // long wrapped texts):
            rt.Width            = Unit.Auto;
            rt.ColumnSizingMode = TableSizingModeEnum.Auto;
            rt.Cols[0].Width    = "50%";                 // allocate at least 50% to 1st column
            rt.Cols[0].Stretch  = StretchColumnEnum.Yes; // but allow it to stretch to take up the free space
            // add grid lines and padding to better see the layout:
            rt.Style.GridLines.All   = LineDef.Default;
            rt.CellStyle.Padding.All = "2mm";
            // header row:
            rt.Cells[0, 0].Text       = "Title";
            rt.Cells[0, 1].Text       = "Price";
            rt.Cells[0, 2].Text       = "Stock Amount";
            rt.RowGroups[0, 1].Header = TableHeaderEnum.All;
            // data row:
            rt.Cells[1, 0].Text = "[Fields!Title.Value]";
            rt.Cells[1, 1].Text = "[Fields!Price.Value]";
            rt.Cells[1, 2].Text = "[Fields!StockAmount.Value]";
            // right-align price and stock columns:
            rt.Cells[1, 1].Style.TextAlignHorz = AlignHorzEnum.Right;
            rt.Cells[1, 2].Style.TextAlignHorz = AlignHorzEnum.Right;
            // center headers:
            rt.Rows[0].Style.TextAlignHorz = AlignHorzEnum.Center;
            // rt.RowGroups[1, 1].DataBinding.DataSource = books; -- can't do that yet
            rt.RowGroups[1, 1].DataBinding.DataSource = bookList;

            // done:
            return(rt);
        }
Exemple #8
0
        private void Form1_Load(object sender, EventArgs e)
        {
            // make a demo C1PrintDocument; a "real" document can be loaded
            // via the File Open button.
            C1PrintDocument doc = new C1PrintDocument();

            doc.PageLayout.PageHeader = new RenderText("Page [PageNo] of [PageCount]");
            doc.PageLayout.PageHeader.Style.TextAlignHorz = AlignHorzEnum.Right;
            doc.PageLayout.PageHeader.Style.TextAlignVert = AlignVertEnum.Top;
            doc.PageLayout.PageHeader.Height = "1cm";
            RenderText title = new RenderText("This is just a sample; load any C1PrintDocument from a C1D file");

            title.Style.Font          = new Font("Arial", 16);
            title.Style.TextAlignHorz = AlignHorzEnum.Center;
            title.Style.Padding.All   = "5mm";
            doc.Body.Children.Add(title);
            RenderTable rt = new RenderTable();

            rt.Style.GridLines.All = LineDef.Default;
            for (int row = 0; row < 100; ++row)
            {
                for (int col = 0; col < 4; ++col)
                {
                    rt.Cells[row, col].Text = string.Format("cell ({0},{1})", row, col);
                }
            }
            doc.Body.Children.Add(rt);
            c1PrintPreviewControl1.Document = doc;
        }
Exemple #9
0
        public Screen48(SpectrumBase machine)
            : base(machine)
        {
            // interrupt
            InterruptStartTime = 3;
            InterruptLength    = 32;
            // offsets
            RenderTableOffset = 56;
            ContentionOffset  = 6;
            FloatingBusOffset = 1;
            // timing
            ClockSpeed       = 3500000;
            FrameCycleLength = 69888;
            ScanlineTime     = 224;
            BorderLeftTime   = 24;
            BorderRightTime  = 24;
            FirstPaperLine   = 64;
            FirstPaperTState = 64;
            // screen layout
            Border4T           = true;
            Border4TStage      = 0;
            ScreenWidth        = 256;
            ScreenHeight       = 192;
            BorderTopHeight    = 48;         // 55;// 48;
            BorderBottomHeight = 48;         // 56;
            BorderLeftWidth    = 48;
            BorderRightWidth   = 48;
            ScanLineWidth      = BorderLeftWidth + ScreenWidth + BorderRightWidth;

            RenderingTable = new RenderTable(this,
                                             MachineType.ZXSpectrum48);

            SetupScreenSize();
        }
Exemple #10
0
        private void button2_Click(object sender, EventArgs e)
        {
            doc.Clear();

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

            doc.Body.Children.Add(new RenderText("Some rows of header and footer are hidden"));

            RenderTable rt = CreateTable(doc, 3, 50, "Cell {0} : {1}");

            rt.Style.GridLines.All = new LineDef("1mm", Color.Blue);

            // build table header
            TableVectorGroup ph = rt.RowGroups[0, 3];

            ph.PageHeader      = true;
            ph.Style.BackColor = Color.LightSlateGray;
            ph.Style.Font      = new Font("Verdana", 25);
            // hide row in table header
            rt.Rows[0].Visible = false;

            // build table footer
            TableVectorGroup pf = rt.RowGroups[rt.Rows.Count - 3, 3];

            pf.PageFooter      = true;
            pf.Style.BackColor = Color.CornflowerBlue;
            pf.Style.Font      = new Font("Tahoma", 25);
            // hide row in table footer
            rt.Rows[rt.Rows.Count - 1].Visible = false;

            doc.Body.Children.Add(rt);

            doc.Generate();
        }
Exemple #11
0
        /// <summary>
        /// Creates a simple table with 3 auto-sized columns.
        /// </summary>
        /// <returns>Created table.</returns>
        private RenderTable MakeTable_Simple()
        {
            // create a RenderTable object:
            RenderTable rt = new RenderTable();

            // adjust table's properties so that columns are auto-sized:
            // 1) By default, table width is set to parent (page) width,
            // for auto-sizing we must change it to auto (i.e. based on content):
            rt.Width = Unit.Auto;
            // 2) Set ColumnSizingMode to Auto (default means Fixed for columns):
            rt.ColumnSizingMode = TableSizingModeEnum.Auto;
            // that's it, now the table's columns will be auto-sized.

            // Turn table grid lines on to better see autosizing, add some padding:
            rt.Style.GridLines.All   = LineDef.Default;
            rt.CellStyle.Padding.All = "1mm";

            // add some data
            rt.Cells[0, 0].Text = "aaa";
            rt.Cells[0, 1].Text = "bbbbbbbbbb";
            rt.Cells[0, 2].Text = "cccccc";
            rt.Cells[1, 0].Text = "aaa aaa aaa";
            rt.Cells[1, 1].Text = "bbbbb";
            rt.Cells[1, 2].Text = "cccccc cccccc";
            rt.Cells[2, 2].Text = "zzzzzzzzzzzzzzz zz z";

            // done:
            return(rt);
        }
Exemple #12
0
        private void button2_Click(object sender, EventArgs e)
        {
            const int rowCount = 60; // count of rows in table
            const int colCount = 4;  // count of columns in table

            doc.Clear();

            doc.Style.Font = new Font("Verdana", 18);

            // add comment
            RenderParagraph desc = new RenderParagraph();

            desc.Content.Add(new ParagraphText(_desc2));
            desc.Style.Spacing.Bottom = "5mm"; // add empty space after comment
            desc.Style.BackColor      = Color.LightPink;
            doc.Body.Children.Add(desc);

            // use image from dictionary
            doc.Dictionary.Add(new DictionaryImage("Checked", Image.FromFile(@"..\..\Checked.bmp")));

            RenderTable rt = new RenderTable();

            rt.Style.GridLines.All = LineDef.Default;

            for (int r = 0; r < rowCount; r++)
            {
                // create RenderImage object in the first column
                RenderImage ri = new RenderImage();
                ri.ImageName = "Checked";
                ri.Style.ImageAlign.AlignHorz = ImageAlignHorzEnum.Center;
                ri.Style.ImageAlign.AlignVert = ImageAlignVertEnum.Center;
                rt.Cells[r, 0].RenderObject   = ri;

                // generate content for all other columns
                for (int c = 1; c < colCount; c++)
                {
                    StringBuilder sb = new StringBuilder();
                    for (int i = 0; i < (c % 2 == 0 ? 2 : 1); i++)
                    {
                        sb.Append(string.Format("Line{0}\r", i));
                    }
                    rt.Cells[r, c].Text = sb.ToString();
                }

                if (r % 2 == 0)
                {
                    rt.Rows[r].Style.BackColor = Color.LightBlue;
                }
            }

            // change sizing mode of first column, it width will be determinated
            // by the width of image
            rt.Cols[0].SizingMode = TableSizingModeEnum.Auto;

            doc.Body.Children.Add(rt);

            doc.Generate();
        }
Exemple #13
0
        static public C1PrintDocument WideTable()
        {
            C1.C1Preview.C1PrintDocument doc = new C1.C1Preview.C1PrintDocument();

            RenderText rtxt = new RenderText();

            rtxt.Text = "This test demonstrates horizontal (extended) pages, which allow to " +
                        "render for example tables with many columns on separate pages that can " +
                        "be \"glued\" side to side.\n\n";
            doc.Body.Children.Add(rtxt);

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

            const int ROWS = 63;
            const int COLS = 16;

            RenderTable rt = new RenderTable();

            rt.Width             = "16in";
            rt.SplitHorzBehavior = SplitBehaviorEnum.SplitIfNeeded;
            for (int row = 0; row < ROWS; ++row)
            {
                for (int col = 0; col < COLS; ++col)
                {
                    RenderText celltext = new RenderText();
                    celltext.Text = string.Format("Cell ({0},{1})", row, col);
                    rt.Cells[row, col].RenderObject = celltext;
                }
            }

            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < 10; i++)
            {
                sb.Append(string.Format("Text fragment{0}", i));
            }
            rt.Cells[1, 1].Text = sb.ToString();
            // add the table to the document
            doc.Body.Children.Add(rt);

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

#if skip_this // does not work in WPF viewer yet
            // add some comments at the bottom
            rtxt      = new RenderText();
            rtxt.Text = "\n\nNote also that the preview supports such documents by showing " +
                        "the pages side by side rather than one below the other (this can be turned off " +
                        "if desired). Also, the vertical margins can be hidden in the preview for better viewing.";
            doc.Body.Children.Add(rtxt);
#endif

            return(doc);
        }
Exemple #14
0
 /// <summary>
 /// Adjusts the global properties of the RenderTable representing the grid
 /// (such as column and row sizing modes etc.) according to PrintInfo.
 /// </summary>
 /// <param name="rt">The RenderTable to adjust.</param>
 /// <param name="gridColFirst">Index of the first grid column that will be printed.</param>
 /// <param name="gridColLast">Index of the last grid column that will be printed.</param>
 private void AdjustTable(RenderTable rt, int gridColFirst, int gridColLast)
 {
     // adjust global table properties:
     rt.BordersSplitHorzMode = BordersSplitMode.Square;
     rt.BordersSplitVertMode = BordersSplitMode.Square;
     if (PrintInfo.AllowHorzSplit)
     {
         rt.SplitHorzBehavior = SplitBehaviorEnum.SplitIfLarge;
         rt.Width             = Unit.Auto;
         if (PrintInfo.AutoColWidths)
         {
             rt.ColumnSizingMode = TableSizingModeEnum.Auto;
             if (!PrintInfo.AutosizeFixedCols)
             {
                 int tblCol = 0;
                 for (int gridCol = 0; gridCol < _grid.Cols.Fixed; ++gridCol)
                 {
                     if (!PrintGridCol(gridCol))
                     {
                         continue;
                     }
                     int width = Math.Min(_grid.Cols[gridCol].WidthDisplay, PrintInfo.MaxColWidth);
                     rt.Cols[tblCol].SizingMode = TableSizingModeEnum.Fixed;
                     rt.Cols[tblCol++].Width    = PixelsToUnit(width);
                 }
             }
         }
         else
         {
             rt.ColumnSizingMode = TableSizingModeEnum.Fixed;
             int tblCol = 0;
             // we must still limit column width:
             for (int gridCol = gridColFirst; gridCol <= gridColLast; ++gridCol)
             {
                 if (!PrintGridCol(gridCol))
                 {
                     continue;
                 }
                 int width = Math.Min(_grid.Cols[gridCol].WidthDisplay, PrintInfo.MaxColWidth);
                 rt.Cols[tblCol++].Width = PixelsToUnit(width);
             }
         }
     }
     else
     {
         rt.SplitHorzBehavior = SplitBehaviorEnum.Never;
     }
     if (_grid.ExtendLastCol)
     {
         rt.StretchColumns = StretchTableEnum.LastVectorOnPage;
     }
 }
Exemple #15
0
        private C1.C1Preview.C1PrintDocument makeDoc_TableStyles()
        {
            C1.C1Preview.C1PrintDocument doc = new C1.C1Preview.C1PrintDocument();

            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;


            return(doc);
        }
Exemple #16
0
        private void Render(Stat stat)
        {
            using (Tag("h3"))
                Write(stat.Title);

            using (new DetailsTag(
                       Writer,
                       () =>
            {
                using (Tag("span"))
                    Write(stat.Description);
            }))
            {
                if (stat is StackTraceStat sts)
                {
                    RenderTable(
                        sts.StackTraceInfos.OrderByDescending(s => s.ThreadsCount),
                        ("Threads count", s => WriteNumericTableValue(s.ThreadsCount.ToString())),
                        ("Thread ids", s => RenderPossiblyExpandableList(
                             s.ThreadIds,
                             ", ",
                             10,
                             5,
                             id => WriteMonospace(id.ToString()))
                        ),
                        ("Stack trace", s => RenderStackTrace(s.StackTrace)));
                }
                else if (stat is TypesStat ts)
                {
                    using (Tag("h4"))
                        Write("Top 20 by objects count");
                    RenderTypesStatsTable(ts.TypesStats.OrderByDescending(s => s.Value.Count).Take(20));

                    using (Tag("h4"))
                        Write("Top 20 by total size");
                    RenderTypesStatsTable(ts.TypesStats.OrderByDescending(s => s.Value.TotalSize).Take(20));
                }
            }
        }
Exemple #17
0
        private RenderArea ListFile(string fileName, RenderObject dirHeader)
        {
            RenderArea  file       = new RenderArea();
            PageLayout  pl         = new PageLayout();
            RenderTable pageHeader = new RenderTable();

            pageHeader.Cells[0, 0].Text      = "Dir:";
            pageHeader.Cells[0, 1].Text      = Path.GetDirectoryName(fileName);
            pageHeader.Cells[1, 0].Text      = "File:";
            pageHeader.Cells[1, 1].Text      = Path.GetFileName(fileName);
            pageHeader.Cols[0].SizingMode    = TableSizingModeEnum.Auto;
            pageHeader.Cols[1].Stretch       = StretchColumnEnum.Yes;
            pageHeader.Style.GridLines.All   = new LineDef("1pt", Color.LightGray);
            pageHeader.CellStyle.Padding.All = "1mm";
            pageHeader.Style.Spacing.Bottom  = "3mm";
            pl.PageHeader           = pageHeader;
            file.LayoutChangeBefore = new LayoutChangeNewPage(pl);

            if (dirHeader != null)
            {
                file.Children.Add(dirHeader);
            }

            RenderText fileHeader = new RenderText(Path.GetFileName(fileName));

            fileHeader.Style.BackColor      = Color.AliceBlue;
            fileHeader.Style.FontSize       = 12;
            fileHeader.Style.FontItalic     = true;
            fileHeader.Style.Spacing.Bottom = "2mm";
            fileHeader.Style.TextAlignHorz  = AlignHorzEnum.Right;
            file.Children.Add(fileHeader);

            using (StreamReader sr = new StreamReader(fileName))
            {
                int curLine = 1;
                while (!sr.EndOfStream)
                {
                    string     line = sr.ReadLine();
                    RenderText rt   = new RenderText(line);
                    // doc.Body.Children.Add(rt);
                    file.Children.Add(rt);
                    this.LineAdded(rt, fileName, line, curLine);
                    curLine++;
                }
                // show total lines in page header:
                pageHeader.Cells[1, 2].Text     = string.Format("{0} lines", curLine - 1);
                pageHeader.Cells[0, 1].SpanCols = 2;
                pageHeader.Cols[2].SizingMode   = TableSizingModeEnum.Auto;
            }
            return(file);
        }
Exemple #18
0
        internal RenderTable CreateTable(C1PrintDocument doc, int colCount, int rowCount, string cellTextMask)
        {
            RenderTable result = new RenderTable(doc);

            for (int r = 0; r < rowCount; r++)
            {
                for (int c = 0; c < colCount; c++)
                {
                    result.Cells[r, c].Text = string.Format(cellTextMask, r, c);
                }
            }

            return(result);
        }
Exemple #19
0
 protected override void OnDataBinding(EventArgs e)
 {
     if (DataSource != null)
     {
         foreach (GINColumnDescriptor column in Driver.Columns)
         {
             if (column.IsViewable)
             {
                 column.AttachedRenderer.DataSource = DataSource;
             }
         }
         RenderTable.DataBind();
     }
 }
Exemple #20
0
        private RenderTable CreateTable(int colCount, int rowCount, string cellTextMask)
        {
            RenderTable result = new RenderTable();

            for (int r = 0; r < rowCount; r++)
            {
                for (int c = 0; c < colCount; c++)
                {
                    result.Cells[r, c].Text = string.Format(cellTextMask, r, c);
                }
            }

            return(result);
        }
Exemple #21
0
        private void CustomEditors_Load(object sender, EventArgs e)
        {
            //Create business-card sized page settings
            C1.C1Preview.PageLayout pl = new C1.C1Preview.PageLayout();
            pl.PageSettings                      = new C1.C1Preview.C1PageSettings();
            pl.PageSettings.PaperKind            = System.Drawing.Printing.PaperKind.Custom;
            pl.PageSettings.Width                = new Unit(3.5, UnitTypeEnum.Inch);
            pl.PageSettings.Height               = new Unit(2, UnitTypeEnum.Inch);
            pl.PageSettings.TopMargin            = new Unit(3, UnitTypeEnum.Mm);
            pl.PageSettings.RightMargin          = new Unit(3, UnitTypeEnum.Mm);
            pl.PageSettings.LeftMargin           = new Unit(3, UnitTypeEnum.Mm);
            pl.PageSettings.BottomMargin         = new Unit(3, UnitTypeEnum.Mm);
            c1PrintDocument1.PageLayouts.Default = pl;

            //Create watermark
            RenderImage ri = new RenderImage();

            ri.Image = Properties.Resources.Referesh;
            c1PrintDocument1.PageLayout.Watermark   = ri;
            c1PrintDocument1.PageLayout.Watermark.X = new Unit(1.75, UnitTypeEnum.Inch);

            //Create data table with border
            rtMain                      = new RenderTable(3, 2);
            rtSub                       = new RenderTable(3, 1);
            rtBorder                    = new RenderTable(1, 1);
            rtBorder.Width              = 3.26;
            rtBorder.Height             = 1.76;
            rtBorder.Style.Borders.All  = new C1.C1Preview.LineDef("2pt", Color.Gray);
            rtBorder.Style.Padding.Left = new Unit(1, UnitTypeEnum.Mm);
            rtMain.Style.Padding.Top    = new Unit(1, UnitTypeEnum.Mm);
            rtMain.Cells[1, 1].Area.Children.Add(rtSub);
            rtBorder.Cells[0, 0].Area.Children.Add(rtMain);
            rtMain.Cols[0].Width    = 1;
            rtMain.Cells[0, 0].Text = "ComponentOne Dev-Tools License";
            rtMain.Cells[0, 0].Style.TextAlignHorz = AlignHorzEnum.Center;
            rtMain.Rows[0].Style.FontBold          = true;
            rtMain.Cells[0, 0].SpanCols            = 2;
            rtSub.Cells[0, 0].Text      = "Name: ";
            rtSub.Cells[1, 0].Text      = "Age: ";
            rtSub.Cells[2, 0].Text      = "Gender: ";
            rtMain.Cells[2, 0].Text     = "Expertise: ";
            rtMain.Cells[2, 0].SpanCols = 2;
            c1PrintDocument1.Body.Children.Add(rtBorder);
            c1PrintDocument1.Style.Borders.All = new C1.C1Preview.LineDef("2pt", Color.Red);

            loadImage();
            c1PreviewPane1.Document = c1PrintDocument1;

            textBoxHost1.TextBox.BorderStyle = BorderStyle.None;
        }
Exemple #22
0
        public override void updateRenderObject(BuildContext context, RenderObject renderObject)
        {
            RenderTable _renderObject = (RenderTable)renderObject;

            D.assert(_renderObject.columns == (children.isNotEmpty() ? children[0].children.Count : 0));
            D.assert(_renderObject.rows == children.Count);

            _renderObject.columnWidths             = columnWidths;
            _renderObject.defaultColumnWidth       = defaultColumnWidth;
            _renderObject.border                   = border;
            _renderObject.rowDecorations           = _rowDecorations;
            _renderObject.configuration            = ImageUtils.createLocalImageConfiguration(context);
            _renderObject.defaultVerticalAlignment = defaultVerticalAlignment;
            _renderObject.textBaseline             = textBaseline;
        }
Exemple #23
0
        private void Form1_Load(object sender, EventArgs e)
        {
            doc.Style.Font = new Font("Tahoma", 20);

            doc.Body.Children.Add(new RenderText("This table has the rows and columns with zero-width.\r\rColumn 1 is hidden and rows 2, 5 are hidden."));

            RenderTable rt = CreateTable(doc, 3, 10, "Cell {0} : {1}");

            rt.Style.GridLines.All = new LineDef("1mm", Color.Blue);
            rt.Cols[1].Width       = Unit.Empty;
            rt.Rows[2].Height      = Unit.Empty;
            rt.Rows[5].Height      = Unit.Empty;
            doc.Body.Children.Add(rt);

            doc.Generate();
        }
Exemple #24
0
        // This method creates a C1PrintDocument acroform using the StartDoc/EndDoc approach.
        // When using StartDoc/EndDoc the content is created using the Render methods.
        private void createQuizForm()
        {
            doc.Clear();
            doc.PageLayouts.Default.PageSettings = new C1.C1Preview.C1PageSettings(false, System.Drawing.Printing.PaperKind.Letter, false, "1in", "1in", "1in", "1in");
            doc.AllowNonReflowableDocs           = true;
            doc.Style.Font = new Font("Comic Sans MS", 12);
            doc.StartDoc();
            doc.RenderBlockRichText(@"{\fonttbl{\f0\froman\fprq2\fcharset2 Webdings;}{\f1\fscript\fprq2\fcharset0 Comic Sans MS;}{\f2\fswiss\fcharset0 Arial;}}{\*\generator Msftedit 5.41.21.2507;}\viewkind4\uc1\pard\f0\fs96 [\f1\fs28  \fs72 Brain Quiz\f2\fs20\par}");
            doc.RenderBlockText("Instructions: Answer the following questions to the best of your ability.  Click the 'Check Answers' button to see your score.");

            // Read in quiz questions from text file
            try
            {
                StreamReader sr = new StreamReader(File.Open(AppDomain.CurrentDomain.BaseDirectory + "Reports\\Files\\quiz1.txt", FileMode.Open));
                string       question, choice;
                int          count = 1, numOfChoices = 3;
                while (!sr.EndOfStream)
                {
                    // Read in Question
                    question = sr.ReadLine();
                    doc.RenderBlockText(" ");
                    doc.RenderBlockText(count.ToString() + ") " + question);
                    RenderTable rtChoices = new RenderTable(1, numOfChoices);
                    for (int i = 0; i < numOfChoices; i++)
                    {
                        // Read in each choice
                        choice = sr.ReadLine();
                        rtChoices.Cells[0, i].Area.Children.Add(new RenderInputRadioButton("rad" + count.ToString() + i.ToString(), (char)(65 + i) + ") " + choice, count));
                        rtChoices.Name = "rtChoices" + count.ToString();
                    }
                    doc.RenderBlock(rtChoices);
                    answers = answers + sr.ReadLine(); // store correct answer
                    count  += 1;
                }
                sr.Close();
            }
            catch
            {
                MessageBox.Show("Sorry, unable to read quiz file :(");
            }

            doc.EndDoc();

            // Add a custom ToolBar button for checking answers
            btnCheckAnswers.Visible = true;
        }
Exemple #25
0
        private void Form1_Load(object sender, EventArgs e)
        {
            // create "welcome" document

            RenderTable rt = new RenderTable();

            rt.Height                   = "parent.height";
            rt.RowSizingMode            = TableSizingModeEnum.Fixed;
            rt.Cells[0, 0].RenderObject = CreateButton("Demo1");
            rt.Cells[0, 1].RenderObject = CreateDesc(_desc1);
            rt.Cells[1, 0].RenderObject = CreateButton("Demo2");
            rt.Cells[1, 1].RenderObject = CreateDesc(_desc2);
            rt.Cells[2, 0].RenderObject = CreateButton("Demo3");
            rt.Cells[2, 1].RenderObject = CreateDesc(_desc3);
            doc.Body.Children.Add(rt);
            doc.Generate();
        }
Exemple #26
0
        static public C1PrintDocument TableBorders()
        {
            C1PrintDocument doc = new C1PrintDocument();

            RenderText rtxt = new RenderText(doc);

            rtxt.Text = "This test shows a non-standard way to draw table borders.\n\n";
            doc.Body.Children.Add(rtxt);

            doc.Style.FontName = "Arial";
            doc.Style.FontSize = 14;

            const int ROWS = 42;
            const int COLS = 4;// 16;

            RenderTable rt = new RenderTable(doc);

            // rt.Width = "16in";
            rt.Width             = "auto";
            rt.ColumnSizingMode  = TableSizingModeEnum.Auto;
            rt.SplitHorzBehavior = SplitBehaviorEnum.SplitIfNeeded;
            for (int row = 0; row < ROWS; ++row)
            {
                for (int col = 0; col < COLS; ++col)
                {
                    //if (row == col)
                    //continue;
                    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("1pt", Colors.Black);
            rt.Style.GridLines.Horz  = LineDef.Empty;
            rt.Style.GridLines.Vert  = LineDef.Empty;
            rt.CellStyle.Borders.All = new LineDef("1pt", Colors.DarkOrange);
            rt.CellStyle.Spacing.All = new Unit("0.5mm");
            rt.Style.TextAlignVert   = AlignVertEnum.Center;

            return(doc);
        }
Exemple #27
0
        private void btnCheckAnswers_Click(object sender, EventArgs e)
        {
            if (c1PrintPreviewControl1.Document != doc)
            {
                MessageBox.Show("You should view the quiz first.");
                return;
            }
            string guesses = "";
            int    leftBlank;

            // Cycle through each render table containing each set of radio buttons
            foreach (RenderObject ro in doc.Body.Children)
            {
                if (ro.GetType() == typeof(C1.C1Preview.RenderTable))
                {
                    RenderTable rt = (RenderTable)ro;
                    leftBlank = guesses.Length;
                    for (int i = 0; i < 3; i++)
                    {
                        RenderInputRadioButton rib = (RenderInputRadioButton)rt.Cells[0, i].Area.Children[0];
                        // Mark the selected choice
                        if (rib.Checked)
                        {
                            guesses = guesses + (char)(65 + i);
                        }
                    }
                    if (guesses.Length == leftBlank) // Mark questions left blank with X
                    {
                        guesses = guesses + "X";
                    }
                }
            }
            int num_correct = 0;

            for (int i = 0; i < guesses.Length; i++)
            {
                if (answers.Length >= guesses.Length && guesses[i] == answers[i])
                {
                    num_correct += 1;
                }
            }
            MessageBox.Show("You got " + num_correct.ToString() + " out of 10 correct!");
        }
Exemple #28
0
        void setCaption(RenderTable renderTable)
        {
            DataTable dtConfigure = DataOperate.dataSet11.Tables["Configure"];

            renderTable.Rows.Insert(0, 1);
            renderTable.RowGroups[0, 1].Header = TableHeaderEnum.All;
            int col = 0;

            foreach (DataRow r in dtConfigure.Rows)
            {
                int _width = int.Parse(r["打印宽度"].ToString());

                if (bool.Parse(r["是否打印"].ToString()) && _width > 0)
                {
                    renderTable.Cells[0, col].Text = r["打印名称"].ToString();
                    col++;
                }
            }
        }
Exemple #29
0
        /// <summary>
        /// Adds an appropriate sort glyph to the sort column.
        /// </summary>
        /// <param name="rt">The render table representing the grid.</param>
        /// <param name="gridColFirst">Index of the first printed grid column.</param>
        /// <param name="gridColLast">Index of the last printed grid column.</param>
        private void PrintSortGlyph(RenderTable rt, int gridColFirst, int gridColLast)
        {
            Debug.Assert(PrintInfo.PrintFixedRows && (_grid.ShowSortPosition != ShowSortPositionEnum.None) && _grid.SortColumn != null && _grid.Rows.Fixed > 0 && PrintGridRow(0));
            int tblCol = 0;

            // the loop is to exactly mimic the logic used to build the table:
            for (int gridCol = gridColFirst; gridCol <= gridColLast; ++gridCol)
            {
                if (!PrintGridCol(gridCol))
                {
                    continue;
                }
                if (_grid.SortColumn.Index == tblCol)
                {
                    RenderImage sortGlyph;
                    if ((_grid.SortColumn.Sort & SortFlags.Ascending) != 0)
                    {
                        sortGlyph = MakeGlyphRO(GlyphEnum.Ascending);
                    }
                    else if ((_grid.SortColumn.Sort & SortFlags.Descending) != 0)
                    {
                        sortGlyph = MakeGlyphRO(GlyphEnum.Descending);
                    }
                    else
                    {
                        sortGlyph = null;
                    }
                    if (sortGlyph != null)
                    {
                        if (rt.Cells[0, tblCol].RenderObject == null)
                        {
                            rt.Cells[0, tblCol].RenderObject = new RenderArea();
                        }
                        sortGlyph.X = "50%parent.width - 50%width";
                        rt.Cells[0, tblCol].RenderObject.Children.Add(sortGlyph);
                    }
                    break;
                }
                ++tblCol;
            }
        }
Exemple #30
0
        /// <summary>
        /// Auto-sizes the table based on cells' content.
        /// </summary>
        /// <param name="rt">The table to auto-size.</param>
        private static void AutoSizeTable(RenderTable rt)
        {
            if (rt.Document == null)
            {
                throw new Exception("The table must be already added to the document");
            }
            double[] widths = new double[rt.Cols.Count];
            for (int row = 0; row < rt.Rows.Count; ++row)
            {
                for (int col = 0; col < rt.Cols.Count; ++col)
                {
                    if (rt.Cells[row, col].RenderObject != null)
                    {
                        SizeD s = rt.Cells[row, col].RenderObject.CalcSize(Unit.Auto, Unit.Auto);
                        widths[col] = Math.Max(widths[col], s.Width);
                    }
                }
            }
            // 1. grid line widths are added to the columns' widths, so we must take them into consideration.
            // 2. for calculations in the document, the maximum width is used, so we do that too.
            // 3. first and last columns include an extra half-width of a line.
            double wVert      = rt.Style.GridLines.Vert == null ? 0 : rt.Style.GridLines.Vert.Width.ConvertUnit(rt.Document.ResolvedUnit);
            double wLeft      = rt.Style.GridLines.Left == null ? 0 : rt.Style.GridLines.Left.Width.ConvertUnit(rt.Document.ResolvedUnit);
            double wRight     = rt.Style.GridLines.Right == null ? 0 : rt.Style.GridLines.Right.Width.ConvertUnit(rt.Document.ResolvedUnit);
            double lineWidths = Math.Max(wVert, Math.Max(wLeft, wRight));

            for (int col = 0; col < rt.Cols.Count; ++col)
            {
                if (col == 0 || col == rt.Cols.Count - 1)
                {
                    rt.Cols[col].Width = new Unit(widths[col] + lineWidths * 1.5, rt.Document.ResolvedUnit);
                }
                else
                {
                    rt.Cols[col].Width = new Unit(widths[col] + lineWidths, rt.Document.ResolvedUnit);
                }
            }
            // the default for a table is 100% of the parent's width, so we must set the width
            // to auto (which means the sum of all columns' widths).
            rt.Width = Unit.Auto;
        }
Exemple #31
0
        /// <summary>
        /// Adds header and footer tags (common for all documents)
        /// </summary>
        /// <param name="doc"></param>
        private static void AddHeadersFooters(C1PrintDocument doc)
        {
            RenderTable theader = new RenderTable();
            theader.Cells[0, 0].Style.TextAlignHorz = AlignHorzEnum.Left;
            theader.Cells[0, 1].Style.TextAlignHorz = AlignHorzEnum.Center;
            theader.Cells[0, 2].Style.TextAlignHorz = AlignHorzEnum.Right;
            theader.CellStyle.Padding.Bottom = "2mm";
            theader.Cells[0, 0].Text = "[Document.Tags!HeaderLeft.Value]";
            theader.Cells[0, 1].Text = "[Document.Tags!HeaderCenter.Value]";
            theader.Cells[0, 2].Text = "[Document.Tags!HeaderRight.Value]";

            doc.PageLayouts.Default.PageHeader = theader;

            theader = new RenderTable();
            theader.Cells[0, 0].Style.TextAlignHorz = AlignHorzEnum.Left;
            theader.Cells[0, 1].Style.TextAlignHorz = AlignHorzEnum.Center;
            theader.Cells[0, 2].Style.TextAlignHorz = AlignHorzEnum.Right;
            theader.CellStyle.Padding.Bottom = "2mm";
            theader.Cells[0, 0].Text = "[IIf(Document.Tags!ReverseOnEvenPages.Value, Document.Tags!HeaderRight.Value, Document.Tags!HeaderLeft.Value)]";
            theader.Cells[0, 1].Text = "[Document.Tags!HeaderCenter.Value]";
            theader.Cells[0, 2].Text = "[IIf(Document.Tags!ReverseOnEvenPages.Value, Document.Tags!HeaderLeft.Value, Document.Tags!HeaderRight.Value)]";

            doc.PageLayouts.EvenPages = new PageLayout();
            doc.PageLayouts.EvenPages.PageHeader = theader;

            RenderTable tfooter = new RenderTable();
            tfooter.Cells[0, 0].Style.TextAlignHorz = AlignHorzEnum.Left;
            tfooter.Cells[0, 1].Style.TextAlignHorz = AlignHorzEnum.Center;
            tfooter.Cells[0, 2].Style.TextAlignHorz = AlignHorzEnum.Right;
            tfooter.CellStyle.Padding.Top = "2mm";
            tfooter.Cells[0, 0].Text = "[Document.Tags!FooterLeft.Value]";
            tfooter.Cells[0, 1].Text = "[Document.Tags!FooterCenter.Value]";
            tfooter.Cells[0, 2].Text = "[Document.Tags!FooterRight.Value]";

            doc.PageLayouts.Default.PageFooter = tfooter;

            tfooter = new RenderTable();
            tfooter.Cells[0, 0].Style.TextAlignHorz = AlignHorzEnum.Left;
            tfooter.Cells[0, 1].Style.TextAlignHorz = AlignHorzEnum.Center;
            tfooter.Cells[0, 2].Style.TextAlignHorz = AlignHorzEnum.Right;
            tfooter.CellStyle.Padding.Top = "2mm";
            tfooter.Cells[0, 0].Text = "[IIf(Document.Tags!ReverseOnEvenPages.Value, Document.Tags!FooterRight.Value, Document.Tags!FooterLeft.Value)]";
            tfooter.Cells[0, 1].Text = "[Document.Tags!FooterCenter.Value]";
            tfooter.Cells[0, 2].Text = "[IIf(Document.Tags!ReverseOnEvenPages.Value, Document.Tags!FooterLeft.Value, Document.Tags!FooterRight.Value)]";

            doc.PageLayouts.EvenPages.PageFooter = tfooter;

            // add page header/footer tags
            Tag newTag = new Tag("HeaderLeft", String.Empty, typeof(string));
            doc.Tags.Add(newTag);
            newTag = new Tag("HeaderCenter", String.Empty, typeof(string));
            doc.Tags.Add(newTag);
            newTag = new Tag("HeaderRight", String.Empty, typeof(string));
            doc.Tags.Add(newTag);
            newTag = new Tag("FooterLeft", String.Empty, typeof(string));
            doc.Tags.Add(newTag);
            newTag = new Tag("FooterCenter", "[PageNo]", typeof(string));
            doc.Tags.Add(newTag);
            newTag = new Tag("FooterRight", String.Empty, typeof(string));
            doc.Tags.Add(newTag);
            newTag = new Tag("ReverseOnEvenPages", false, typeof(bool));
            doc.Tags.Add(newTag);
            newTag = new Tag("HeaderColor", Colors.Black, typeof(System.Windows.Media.Color));
            doc.Tags.Add(newTag);
            newTag = new Tag("FooterColor", Colors.Black, typeof(System.Windows.Media.Color));
            doc.Tags.Add(newTag);
            newTag = new Tag("HeaderFont", new Font("Tahoma", 8), typeof(Font));
            doc.Tags.Add(newTag);
            newTag = new Tag("FooterFont", new Font("Tahoma", 8), typeof(Font));
            doc.Tags.Add(newTag);

            newTag = new Tag("DateHeadingsFont", new Font("Segoe UI", 12, FontStyle.Bold), typeof(Font));
            doc.Tags.Add(newTag);
            newTag = new Tag("AppointmentsFont", new Font("Segoe UI", 8), typeof(Font));
            doc.Tags.Add(newTag);

            doc.DocumentStartingScript =
                "Document.Style.Font = Document.Tags!AppointmentsFont.Value\r\n" +
                "Document.PageLayout.PageFooter.Style.TextColor = Document.Tags!FooterColor.Value\r\n" +
                "Document.PageLayouts.EvenPages.PageFooter.Style.TextColor = Document.Tags!FooterColor.Value\r\n" +
                "Document.PageLayout.PageHeader.Style.TextColor = Document.Tags!HeaderColor.Value\r\n" +
                "Document.PageLayouts.EvenPages.PageHeader.Style.TextColor = Document.Tags!HeaderColor.Value\r\n" +
                "Document.PageLayout.PageFooter.Style.Font = Document.Tags!FooterFont.Value\r\n" +
                "Document.PageLayouts.EvenPages.PageFooter.Style.Font = Document.Tags!FooterFont.Value\r\n" +
                "Document.PageLayout.PageHeader.Style.Font = Document.Tags!HeaderFont.Value\r\n" +
                "Document.PageLayouts.EvenPages.PageHeader.Style.Font = Document.Tags!HeaderFont.Value\r\n";
        }
Exemple #32
0
		static public C1PrintDocument MakeDoc()
		{
			C1PrintDocument doc = C1ReportViewer.CreateC1PrintDocument();

			doc.Style.FontSize += 2;

			// setup a page header with links to first|prev|next|last pages:
			RenderTable rtnav = new RenderTable();
			// suppress different display of visited hyperlinks for page navigator:
			rtnav.Style.VisitedHyperlinkAttrs = rtnav.Style.HyperlinkAttrs;
			// space things out
			rtnav.Style.Spacing.Bottom = "5mm";
			// add navigator links
			rtnav.Cells[0, 0].Text = "First page";
			rtnav.Cells[0, 0].RenderObject.Hyperlink = new C1Hyperlink(
				new C1LinkTargetPage(PageJumpTypeEnum.First), "Go to first page");
			rtnav.Cells[0, 1].Text = "Previous page";
			rtnav.Cells[0, 1].RenderObject.Hyperlink = new C1Hyperlink(
				new C1LinkTargetPage(PageJumpTypeEnum.Previous), "Go to previous page");
			rtnav.Cells[0, 2].Text = "Next page";
			rtnav.Cells[0, 2].RenderObject.Hyperlink = new C1Hyperlink(
				new C1LinkTargetPage(PageJumpTypeEnum.Next), "Go to next page");
			rtnav.Cells[0, 3].Text = "Last page";
			rtnav.Cells[0, 3].RenderObject.Hyperlink = new C1Hyperlink(
				new C1LinkTargetPage(PageJumpTypeEnum.Last), "Go to last page");
			doc.PageLayout.PageHeader = rtnav;

			// make the body of the document

			// make an anchor
			RenderText rt1 = new RenderText("This is text with anchor1.");
			// the name ("anchor1") will be used to jump to this link:
			rt1.Anchors.Add(new C1Anchor("anchor1"));
			rt1.Hyperlink = new C1Hyperlink(new C1LinkTargetPage(PageJumpTypeEnum.Last),
				"Go to the last page of the document");
			doc.Body.Children.Add(rt1);

			// add a link to open doc2:
			/*
			RenderText rt2 = new RenderText("Click here to open 'StylesInTables' document.");
			rt2.Hyperlink = new C1Hyperlink(new C1LinkTargetFile(
				"javascript:window.changeReport('','StylesInTables')"));
			doc.Body.Children.Add(rt2);
			*/

			// add filler
			for (int i = 0; i < 500; ++i)
				doc.Body.Children.Add(new RenderText(string.Format("... filler {0} ...", i)));

			// add hyperlink to anchor1
			RenderText rt3 = new RenderText("Click here to go to anchor1.");
			rt3.Hyperlink = new C1Hyperlink(new C1LinkTargetAnchor("anchor1"),
				"This is status text when the mouse hovers over link to anchor1");
			doc.Body.Children.Add(rt3);

			// to jump to a render object, an anchor is really not needed:
			RenderText rt4 = new RenderText("Click here to go to the middle of document.");
			rt4.Hyperlink = new C1Hyperlink(doc.Body.Children[doc.Body.Children.Count / 2]);
			rt4.Hyperlink.StatusText = "Go to the approximate middle of the document";
			doc.Body.Children.Add(rt4);

			// add image with hyperlink to a URL
			RenderImage ri1 = new RenderImage(Image.FromFile(HttpContext.Current.Server.MapPath("~/C1ReportViewer/Images/google.gif")));
			ri1.Hyperlink = new C1Hyperlink(new C1LinkTargetFile("http://www.google.com"),
				" Go googling... (Use Ctrl+Click in order to open link in a new window");
			doc.Body.Children.Add(ri1);


			RenderText rt5 = new RenderText("alert 'Hello'.");
			rt5.Hyperlink = new C1Hyperlink(new C1LinkTargetFile("javascript:alert('Hello')"));
			rt5.Hyperlink.StatusText = "Show 'Hello' message.";
			doc.Body.Children.Add(rt5);

			RenderText rt6 = new RenderText("printWithPreview");
			rt6.Hyperlink = new C1Hyperlink(new C1LinkTargetFile("exec:printWithPreview()"));
			rt6.Hyperlink.StatusText = "Preview and print report.";
			doc.Body.Children.Add(rt6);


			return doc;
		}
Exemple #33
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);
        }
Exemple #34
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);
        }
Exemple #35
0
		static public C1PrintDocument MakeDoc()
		{
			C1PrintDocument doc = C1ReportViewer.CreateC1PrintDocument();

			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 C1.C1Preview.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 = System.Drawing.Image.FromFile(HttpContext.Current.Server.MapPath("~/C1ReportViewer/Images/orange.jpg"));
			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].CanSplit = false;

			return doc;
		}