예제 #1
0
 /// <summary>
 /// Fires the <see cref="LongOperation"/> event.
 /// </summary>
 /// <param name="e">The event arguments.</param>
 private void OnLongOperation(LongOperationEventArgs e)
 {
     if (LongOperation != null)
     {
         LongOperation(this, e);
     }
 }
예제 #2
0
 protected void LongOperationHandler(object sender, LongOperationEventArgs e)
 {
     if (LongOperation != null)
     {
         LongOperation(sender, e);
     }
 }
예제 #3
0
 /// <summary>
 /// Raises the <see cref="C1FlexGridPrintable2.LongOperation"/> event.
 /// </summary>
 /// <param name="e">Event arguments.</param>
 protected internal virtual void OnLongOperation(LongOperationEventArgs e)
 {
     if (_longOperationEventHandler != null)
     {
         _longOperationEventHandler(this, e);
     }
 }
예제 #4
0
 private void _item_LongOperation(object sender, LongOperationEventArgs e)
 {
     if (CheckedStatus != CheckedStatus.Working)
     {
         _checkedStatusBeforeLongOp = CheckedStatus;
     }
     if (e.Complete < 1)
     {
         CheckedStatus = CheckedStatus.Working;
     }
     else
     {
         CheckedStatus = _checkedStatusBeforeLongOp;
         _checkedStatusBeforeLongOp = CheckedStatus.Unknown;
     }
 }
예제 #5
0
        /// <summary>
        /// Called periodically while the document is generating. Updates the progress window,
        /// closes it when the document is ready.
        /// </summary>
        private void doc_LongOperation(object sender, LongOperationEventArgs e)
        {
            DispatcherHelper.DoEvents();
            C1PrintDocument doc = (C1PrintDocument)sender;
            ProgressWindow  pw  = doc.Body.Children[0].UserData as ProgressWindow;

            if (pw != null)
            {
                if (!doc.IsGenerating)
                {
                    doc.Body.Children[0].UserData = null;
                    pw.Close();
                }
                else
                {
                    pw.progressBar1.Value = e.Complete * 100;
                }
            }
            DispatcherHelper.DoEvents();
        }
예제 #6
0
        /// <summary>
        /// Creates a RenderTable representing the flex grid.
        /// </summary>
        /// <param name="doc">The target document. May be null.</param>
        /// <returns>The created RenderTable.</returns>
        private RenderTable MakeGridTableInternal(C1PrintDocument doc)
        {
            // Fire PrintStarting event:
            if (_grid2 != null)
            {
                _grid2.OnPrintStarting(EventArgs.Empty);
            }

            RenderTable rt = new RenderTable();

            InitCommonStyles(rt);

            // PrintInfo:
            if (PrintInfo.RepeatFixedRows && PrintInfo.PrintFixedRows && _grid.Rows.Fixed > 0)
            {
                rt.RowGroups[0, _grid.Rows.Fixed].Header = TableHeaderEnum.All;
            }
            if (PrintInfo.RepeatFixedCols && PrintInfo.PrintFixedCols && _grid.Cols.Fixed > 0)
            {
                rt.ColGroups[0, _grid.Cols.Fixed].Header = TableHeaderEnum.All;
            }

            int gridRowFirst, gridColFirst, gridRowLast, gridColLast;

            // find indices of first/last printed row and column:
            for (gridRowFirst = PrintInfo.PrintFixedRows ? 0 : _grid.Rows.Fixed;
                 gridRowFirst < _grid.Rows.Count && !PrintGridRow(gridRowFirst);
                 ++gridRowFirst)
            {
                ;
            }
            for (gridColFirst = PrintInfo.PrintFixedCols ? 0 : _grid.Cols.Fixed;
                 gridColFirst < _grid.Cols.Count && !PrintGridCol(gridColFirst);
                 ++gridColFirst)
            {
                ;
            }
            for (gridRowLast = _grid.Rows.Count - 1;
                 gridRowLast >= 0 && !PrintGridRow(gridRowLast);
                 --gridRowLast)
            {
                ;
            }
            for (gridColLast = _grid.Cols.Count - 1;
                 gridColLast >= 0 && !PrintGridCol(gridColLast);
                 --gridColLast)
            {
                ;
            }

            // adjust global table properties:
            AdjustTable(rt, gridColFirst, gridColLast);

            // this is used to keep bottom borders of cells above the current row
            // (indexed by RenderTable column index) for setting up cells' top borders
            // (flex grid's styles specify right and bottom border of a cell):
            List <LineDef> bordersTop = new List <LineDef>(gridColLast + 1);

            for (int i = 0; i <= gridColLast; ++i)
            {
                bordersTop.Add(null);
            }

            // the big loop over grid rows and columns:
            int tblRow = 0; // RenderTable row

            for (int gridRow = gridRowFirst; gridRow <= gridRowLast; ++gridRow)
            {
                if (!PrintGridRow(gridRow))
                {
                    continue;
                }

                // fire long operation event:
                LongOperationEventArgs e = new LongOperationEventArgs((double)gridRow / (double)gridRowLast, true);
                OnLongOperation(e);
                if (e.Cancel)
                {
                    break;
                }

                if (!PrintInfo.AutoRowHeights ||
                    (!PrintInfo.AutosizeFixedRows && gridRow < _grid.Rows.Fixed))
                {
                    rt.Rows[tblRow].Height = PixelsToUnit(_grid.Rows[gridRow].HeightDisplay);
                }

                int tblCol = 0; // RenderTable col
                for (int gridCol = gridColFirst; gridCol <= gridColLast; ++gridCol)
                {
                    if (!PrintGridCol(gridCol))
                    {
                        continue;
                    }

                    CellRange cr = _grid.GetMergedRange(gridRow, gridCol);
                    cr.Normalize(); // todo: clarify whether this call is needed after GetMergedRange
                    if (cr.r1 == gridRow && cr.c1 == gridCol)
                    {
                        TableCell tc = rt.Cells[tblRow, tblCol];
                        tc.SpanCols = cr.c2 - cr.c1 + 1;
                        tc.SpanRows = cr.r2 - cr.r1 + 1;

                        CellStyle cellStyle = _grid.GetCellStyleDisplay(gridRow, gridCol);
                        string    cellText;
                        // note: style may be changed by owner-draw cell event invoked from MakeCellRO:
                        RenderObject cellContent = MakeCellRO(gridRow, gridCol, ref cellStyle, out cellText);
                        Style        style       = StyleFromGridStyle(cellStyle, rt.Style.Children, cellStyle.DataType, cellText,
                                                                      CalcEdges(cr, gridRowFirst, gridColFirst, gridRowLast, gridColLast),
                                                                      GetLeftBorder(gridRow, gridCol), bordersTop[tblCol]);
                        tc.Style.Parents = style;

                        if (PrintInfo.PrintBorders)
                        {
                            // update top borders for next row (left border for next cell is calculated):
                            for (int i = 0; i < tc.SpanCols && tblCol + i < bordersTop.Count; ++i)
                            {
                                bordersTop[tblCol + i] = style.Borders.Bottom;
                            }
                        }

                        // For tree cells, cellContent is inserted into a RenderArea that additionally
                        // contains tree glyphs (plus/minus etc) and offsets; otherwise, just use cellContent:
                        if (gridCol == _grid.Tree.Column && _grid.Rows[gridRow].Node != null)
                        {
                            tc.RenderObject = MakeTreeRO(cellContent, gridRow);
                        }
                        else // not a tree cell:
                        {
                            tc.RenderObject = cellContent;
                        }

                        // print current row indicator (DBCursor):
                        if (gridRow == _grid.Row && PrintInfo.PrintDBCursor && gridCol == 0 && gridCol < _grid.Cols.Fixed)
                        {
                            PrintDBCursor(tc);
                        }

                        // account for CellStyle.Margins (added as Spacing between cell's RO and cell):
                        if (tc.RenderObject != null)
                        {
                            tc.RenderObject.Style.Parent = CellRoStyleFromGridStyle(cellStyle, rt.Style.Children);
                        }

                        // fire C1FlexGridPrintable2.PrintCell event:
                        if (_grid2 != null)
                        {
                            _grid2.OnPrintCell(new C1FlexGridPrintable2.PrintCellEventArgs(tc, doc, gridRow, gridCol));
                        }
                    }
                    ++tblCol;
                }
                ++tblRow;
            }

            // show sort glyphs:
            // if (PrintInfo.PrintFixedRows && _grid.ShowSort && _grid.SortColumn != null && _grid.Rows.Fixed > 0 && PrintGridRow(0))
            if (PrintInfo.PrintFixedRows && (_grid.ShowSortPosition != ShowSortPositionEnum.None) && _grid.SortColumn != null && _grid.Rows.Fixed > 0 && PrintGridRow(0))
            {
                PrintSortGlyph(rt, gridColFirst, gridColLast);
            }

            // Fire PrintEnded event:
            if (_grid2 != null)
            {
                _grid2.OnPrintEnded(EventArgs.Empty);
            }

            return(rt);
        }
예제 #7
0
 void doc_LongOperation(object sender, LongOperationEventArgs e)
 {
     _progress.label1.Text = string.Format("Complete: {0:P}", e.Complete);
     Application.DoEvents();
 }