Ejemplo n.º 1
0
        // Handle C1FlexGridPrintable2.PrintCell event:
        // if we are printing the first cell containing an expanded child grid,
        // we use C1FlexGridPrinter to insert a RenderTable representing that
        // child grid into that cell.
        protected override void OnPrintCell(PrintCellEventArgs e)
        {
            base.OnPrintCell(e);

            if (!IsExpandedChildGridCell(e.Row, e.Col))
            {
                return;
            }

            // get child grid occupying the current row:
            C1FlexGrid childGrid = (C1FlexGrid)Rows[e.Row - 1].UserData;

            System.Diagnostics.Debug.Assert(childGrid != null);
            C1FlexGridPrinter childPrinter = new C1FlexGridPrinter(childGrid);

            // use our own PrintInfo on the child:
            childPrinter.PrintInfo = this.Printer.PrintInfo;
            // make render object representing the child:
            C1.C1Preview.RenderObject childRO = childPrinter.MakeGridTable(e.TableCell.Table.Document);
            // span all columns to the right:
            e.TableCell.SpanCols = e.TableCell.Table.Cols.Count - 1;
            // allow the nested table to be split horizontally:
            e.TableCell.Table.Rows[e.TableCell.Row].SplitBehavior = C1.C1Preview.SplitBehaviorEnum.SplitIfNeeded;
            // set our cell's render object to the child grid:
            e.TableCell.RenderObject = childRO;
        }
Ejemplo n.º 2
0
        void _flex_PrintCell(object sender, C1FlexGridPrintable2.PrintCellEventArgs e)
        {
            Hyperlink link = _flex[e.Row, e.Col] as Hyperlink;

            if (link == null)
            {
                return;
            }

            C1.C1Preview.RenderObject cellRo = e.TableCell.RenderObject;
            if (cellRo == null)
            {
                return;
            }

            cellRo.Hyperlink = new C1.C1Preview.C1Hyperlink(new C1.C1Preview.C1LinkTargetFile(link.Link));
        }
Ejemplo n.º 3
0
        private void btnPreviewSample_Click(object sender, EventArgs e)
        {
            C1.C1Preview.C1PrintDocument doc = null;
            if (_selectedWrapper != null)
            {
                doc = _selectedWrapper.MakeDoc(_printInfo, printer_LongOperation);
                if (doc == null)
                {
                    C1FlexGrid flex = _selectedWrapper.Flex;
                    if (flex != null)
                    {
                        C1.Win.C1FlexGrid.C1FlexGridPrinter printer = new C1.Win.C1FlexGrid.C1FlexGridPrinter(flex);
                        printer.LongOperation += new C1.C1Preview.LongOperationEventHandler(printer_LongOperation);

                        doc = new C1.C1Preview.C1PrintDocument();
                        printer.PrintInfo = _printInfo;
                        C1.C1Preview.RenderObject gridRO = printer.MakeGridTable(doc);
                        // if flex grid borders are not printed, provide our own:
                        if (!_printInfo.PrintBorders && chkOverrideBorders.Checked)
                        {
                            gridRO.Style.GridLines.All = new C1.C1Preview.LineDef("0.5pt", Color.LightGray);
                        }
                        doc.Body.Children.Add(gridRO);
                        doc.PageLayout.PageHeader = printer.MakePageHeader(doc);
                        doc.PageLayout.PageFooter = printer.MakePageFooter(doc);
                    }
                }
            }

            if (doc != null)
            {
                doc.PageLayout.PageSettings.Landscape = chkLandscape.Checked;
                C1.Win.C1Preview.C1PrintPreviewDialog pview = new C1.Win.C1Preview.C1PrintPreviewDialog();
                // Assign document after showing the dialog - this delays generation
                // and improves user experience for long documents:
                // pview.Document = doc;
                pview.Shown += (o, ev) => { pview.Document = doc; };
                pview.ShowDialog();
                progressBar1.Value = 0;
                label2.Text        = string.Format((string)label2.Tag, 0);
            }
            else
            {
                MessageBox.Show("Could not load the selected sample.");
            }
        }
Ejemplo n.º 4
0
        public C1.C1Preview.C1PrintDocument MakeDoc(C1.Win.C1FlexGrid.C1FlexGridPrintInfo printInfo)
        {
            C1FlexGrid flex = _tab.SelectedTab.Controls[0] as C1FlexGrid;

            if (flex == null)
            {
                return(null);
            }

            C1.Win.C1FlexGrid.C1FlexGridPrinter printer = new C1.Win.C1FlexGrid.C1FlexGridPrinter(flex);
            C1.C1Preview.C1PrintDocument        doc     = new C1.C1Preview.C1PrintDocument();
            printer.PrintInfo = printInfo;
            C1.C1Preview.RenderObject gridRO = printer.MakeGridTable(doc);
            // if flex grid borders are not printed, provide our own:
            if (!printInfo.PrintBorders)
            {
                gridRO.Style.GridLines.All = new C1.C1Preview.LineDef("0.5pt", Color.LightGray);
            }
            doc.Body.Children.Add(gridRO);
            doc.PageLayout.PageHeader = printer.MakePageHeader(doc);
            doc.PageLayout.PageFooter = printer.MakePageFooter(doc);
            return(doc);
        }