예제 #1
0
        public override void OnPaint(CellDrawingContext dc)
        {
            var g = dc.Graphics;

            RGFloat hh = Bounds.Height / 2 - 1;

            Rectangle rect = Bounds;

            Rectangle upRect = new Rectangle(rect.Right - ButtonSize, rect.Top, ButtonSize, hh);

            GraphicsToolkit.Draw3DButton(g.PlatformGraphics, (System.Drawing.Rectangle)upRect, isUpPressed);
            GraphicsToolkit.FillTriangle(g.PlatformGraphics, ArrowSize,
                                         new Point(upRect.Left + ButtonSize / 2 - ArrowSize / 2,
                                                   upRect.Top + hh / 2 + (isUpPressed ? 2 : 1)),
                                         GraphicsToolkit.TriangleDirection.Up);

            Rectangle downRect = new Rectangle(rect.Right - ButtonSize, rect.Top + hh + 1, ButtonSize, hh);

            GraphicsToolkit.Draw3DButton(g.PlatformGraphics, (System.Drawing.Rectangle)downRect, isDownPressed);
            GraphicsToolkit.FillTriangle(g.PlatformGraphics, ArrowSize,
                                         new Point(downRect.Left + ButtonSize / 2 - ArrowSize / 2,
                                                   downRect.Top + hh / 2 - (isDownPressed ? 1 : 2)),
                                         GraphicsToolkit.TriangleDirection.Down);
        }
예제 #2
0
            /// <summary>
            /// Repaint filter header body
            /// </summary>
            /// <param name="dc">ReoGrid drawing context</param>
            /// <param name="headerSize">Header size</param>
            public void OnPaint(CellDrawingContext dc, Size headerSize)
            {
                var controlStyle = dc.Worksheet.controlAdapter.ControlStyle;

                if (this.autoFilter.columnFilterUIFlag == AutoColumnFilterUI.DropdownButton ||
                    this.autoFilter.columnFilterUIFlag == AutoColumnFilterUI.DropdownButtonAndPanel)
                {
                    Rectangle bounds = GetColumnFilterButtonRect(headerSize);

                    SolidColor color1 = controlStyle.GetColHeadStartColor(false, IsDropdown, false, false, dc.Focused);
                    SolidColor color2 = controlStyle.GetColHeadEndColor(false, IsDropdown, false, false, dc.Focused);

                    var g = dc.Graphics;

                    g.FillRectangleLinear(color1, color2, 90f, bounds);

                    g.DrawRectangle(bounds, unvell.ReoGrid.Rendering.StaticResources.SystemColor_ControlDark);

                    unvell.Common.GraphicsToolkit.FillTriangle(dc.Graphics.PlatformGraphics,
                                                               Math.Min(7 * dc.Worksheet.renderScaleFactor, 7.0f),
                                                               new Point(bounds.X + bounds.Width / 2, bounds.Y + bounds.Height / 2),
                                                               unvell.Common.GraphicsToolkit.TriangleDirection.Down);
                }
            }
예제 #3
0
        public override void OnPaint(CellDrawingContext dc)
        {
            // try getting the cell value
            float value = 0;

            float.TryParse(dc.Cell.DisplayText, out value);

            // retrieve graphics object
            var g = dc.Graphics;

            int halfHeight   = (int)Math.Round(Bounds.Height / 2f);
            int sliderHeight = (int)Math.Min(Bounds.Height - 4, 20);

            // draw slide bar
            g.FillRectangle(4, halfHeight - 3, Bounds.Width - 8, 6, SolidColor.Gainsboro);

            int x = 2 + (int)Math.Round(value * (Bounds.Width - 12));

            // thumb rectangle
            Rectangle rect = new Rectangle(x, halfHeight - sliderHeight / 2, 8, sliderHeight);

            // draw slide thumb
            g.FillRectangle(rect, IsHover ? SolidColor.LimeGreen : SolidColor.LightGreen);
        }
예제 #4
0
 public override void OnPaint(CellDrawingContext dc)
 {
     base.OnPaint(dc);
     dc.Graphics.DrawRectangle(base.Bounds, SolidColor.DarkOrange);
 }
예제 #5
0
        /// <summary>
        /// Render the negative progress cell body.
        /// </summary>
        /// <param name="dc"></param>
        public override void OnPaint(CellDrawingContext dc)
        {
            double value = this.Cell.GetData <double>();

            if (LimitedInsideCell)
            {
                if (value > 1)
                {
                    value = 1;
                }
                else if (value < -1)
                {
                    value = -1;
                }
            }

            var g = dc.Graphics;

            Rectangle rect;

            if (value >= 0)
            {
                rect = new Rectangle(Bounds.Left + Bounds.Width / 2, Bounds.Top + 1,
                                     (RGFloat)(Bounds.Width * (value / 2.0d)), Bounds.Height - 1);

                if (rect.Width > 0 && rect.Height > 0)
                {
                    if (this.LinearGradient)
                    {
                        g.FillRectangleLinear(this.PositiveColor,
                                              new SolidColor(0, this.PositiveColor), 0, rect);
                    }
                    else
                    {
                        g.FillRectangle(rect, this.PositiveColor);
                    }
                }
            }
            else
            {
                RGFloat center = Bounds.Left + Bounds.Width / 2.0f;
                RGFloat left   = (RGFloat)(Bounds.Width * value * 0.5d);
                rect = new Rectangle(center + left, Bounds.Top + 1, -left, Bounds.Height - 1);

                if (rect.Width > 0 && rect.Height > 0)
                {
                    if (this.LinearGradient)
                    {
                        g.FillRectangleLinear(this.NegativeColor,
                                              new SolidColor(0, this.NegativeColor), 180, rect);
                    }
                    else
                    {
                        g.FillRectangle(rect, this.NegativeColor);
                    }
                }
            }

            if (DisplayCellText)
            {
                dc.DrawCellText();
            }
        }
예제 #6
0
 public override void DrawView(CellDrawingContext dc)
 {
     this.sheet.drawingCanvas.ClipBounds = this.ViewBounds;
     this.sheet.drawingCanvas.Draw(dc);
 }
예제 #7
0
 /// <summary>
 /// Paint this header body.
 /// </summary>
 /// <param name="dc">Drawing context</param>
 /// <param name="headerSize">Header size</param>
 public virtual void OnPaint(CellDrawingContext dc, Size headerSize)
 {
 }
예제 #8
0
 public override void Draw(CellDrawingContext dc)
 {
     throw new NotImplementedException();
 }
예제 #9
0
        public override void DrawView(CellDrawingContext dc)
        {
            var r = dc.Renderer;
            var g = dc.Graphics;

            if (bounds.Height <= 0 || sheet.controlAdapter == null)
            {
                return;
            }

            var controlStyle = sheet.workbook.controlAdapter.ControlStyle;

            r.BeginDrawHeaderText(this.scaleFactor);

            var splitterLinePen = r.GetPen(controlStyle.Colors[ControlAppearanceColors.RowHeadSplitter]);
            var headerTextBrush = r.GetBrush(controlStyle.Colors[ControlAppearanceColors.ColHeadText]);

            bool isFullColSelected = sheet.SelectionRange.Rows == sheet.RowCount;

            for (int i = visibleRegion.startCol; i <= visibleRegion.endCol; i++)
            {
                bool isSelected = i >= sheet.SelectionRange.Col && i <= sheet.SelectionRange.EndCol;

                ColumnHeader header = sheet.cols[i];

                RGFloat x     = header.Left * this.scaleFactor;
                RGFloat width = header.InnerWidth * this.scaleFactor;

                if (!header.IsVisible)
                {
                    g.DrawLine(splitterLinePen, x - 1, 0, x - 1, bounds.Bottom);
                }
                else
                {
                    Rectangle rect = new Rectangle(x, 0, width, bounds.Height);

#if WINFORM || WPF
                    g.FillRectangleLinear(controlStyle.GetColHeadStartColor(false, isSelected, isSelected && isFullColSelected, false),
                                          controlStyle.GetColHeadEndColor(false, isSelected, isSelected && isFullColSelected, false), 90f, rect);
#elif ANDROID
                    g.FillRectangle(rect, controlStyle.GetRowHeadEndColor(false, isSelected, isSelected && isFullColSelected, false));
#endif // ANDROID

                    g.DrawLine(splitterLinePen, x, 0, x, bounds.Height);

                    var textBrush = header.TextColor != null?dc.Renderer.GetBrush((SolidColor)header.TextColor) : headerTextBrush;

                    if (textBrush == null)
                    {
                        textBrush = headerTextBrush;
                    }

                    r.DrawHeaderText(header.RenderText, textBrush, rect);

                    if (header.Body != null)
                    {
                        g.PushTransform();
                        g.TranslateTransform(rect.X, rect.Y);
                        header.Body.OnPaint(dc, rect.Size);
                        g.PopTransform();
                    }
                }
            }

            RGFloat lx = sheet.cols[visibleRegion.endCol].Right * this.scaleFactor;
            g.DrawLine(splitterLinePen, lx, 0, lx, bounds.Height);

            //g.DrawLine(splitterLinePen, this.ViewLeft, bounds.Height, this.ViewLeft + bounds.Width, bounds.Height);

            // bottom line
            //if (!sheet.HasSettings(WorksheetSettings.View_ShowGuideLine))
            //{
            //	g.DrawLine(ViewLeft, bounds.Bottom,
            //		Math.Min((sheet.cols[sheet.cols.Count - 1].Right - ViewLeft) * this.scaleFactor + bounds.Left, bounds.Width),
            //		//ViewLeft+ bounds.Width,
            //		bounds.Bottom, controlStyle.Colors[ControlAppearanceColors.ColHeadSplitter]);
            //}
        }
예제 #10
0
        public override void Draw(CellDrawingContext dc)
        {
            var sheet = this.ViewportController.Worksheet;

            if (sheet == null || sheet.controlAdapter == null)
            {
                return;
            }

            var g            = dc.Graphics;
            var controlStyle = sheet.workbook.controlAdapter.ControlStyle;

            switch (sheet.operationStatus)
            {
            case OperationStatus.AdjustColumnWidth:
                #region Draw Column Header Adjust Line
                if (sheet.currentColWidthChanging >= 0)
                {
                    ColumnHeader col = sheet.cols[sheet.currentColWidthChanging];

                    RGFloat left   = col.Left * this.scaleFactor;
                    RGFloat right  = Math.Max(left, PointToView(new Point(sheet.headerAdjustNewValue, 0)).X *this.scaleFactor);
                    RGFloat top    = ScrollViewTop * this.scaleFactor;
                    RGFloat bottom = ScrollViewTop * this.scaleFactor + this.Height;

                    g.DrawLine(left, top, left, bottom, SolidColor.Black, 1, LineStyles.Dot);
                    g.DrawLine(right, top, right, bottom, SolidColor.Black, 1, LineStyles.Dot);
                }
                #endregion                         // Draw Column Header Adjust Line
                break;

            case OperationStatus.AdjustRowHeight:
                #region Draw Row Header Adjust Line
                if (sheet.currentRowHeightChanging >= 0)
                {
                    RowHeader row = sheet.rows[sheet.currentRowHeightChanging];

                    RGFloat top    = row.Top * this.scaleFactor;
                    RGFloat bottom = Math.Max(top, PointToView(new Point(0, sheet.headerAdjustNewValue)).Y *this.scaleFactor);
                    RGFloat left   = ScrollViewLeft * this.scaleFactor;
                    RGFloat right  = ScrollViewLeft * this.scaleFactor + this.Width;

                    g.DrawLine(left, top, right, top, SolidColor.Black, 1, LineStyles.Dot);
                    g.DrawLine(left, bottom, right, bottom, SolidColor.Black, 1, LineStyles.Dot);
                }
                #endregion                         // Draw Row Header Adjust Line
                break;

            case OperationStatus.DragSelectionFillSerial:
            case OperationStatus.SelectionRangeMovePrepare:
            case OperationStatus.SelectionRangeMove:
                #region Selection Moving
                if (sheet.draggingSelectionRange != RangePosition.Empty &&
                    dc.DrawMode == DrawMode.View &&
                    sheet.HasSettings(WorksheetSettings.Edit_DragSelectionToMoveCells))
                {
                    var scaledSelectionMovingRect = CellsViewport.GetScaledAndClippedRangeRect(this,
                                                                                               sheet.draggingSelectionRange.StartPos,
                                                                                               sheet.draggingSelectionRange.EndPos,
                                                                                               controlStyle.SelectionBorderWidth);

                    scaledSelectionMovingRect.Offset(-1, -1);

                    SolidColor selectionBorderColor = controlStyle.Colors[ControlAppearanceColors.SelectionBorder];

                    dc.Graphics.DrawRectangle(scaledSelectionMovingRect,
                                              ColorUtility.FromAlphaColor(255, selectionBorderColor),
                                              controlStyle.SelectionBorderWidth, LineStyles.Solid);
                }
                #endregion                         // Selection Moving
                break;
            }
        }
예제 #11
0
 public override void OnPaint(CellDrawingContext dc, unvell.ReoGrid.Graphics.Size headerSize)
 {
     dc.Graphics.FillRectangle(HatchStyles.OutlinedDiamond, Color.FromArgb(120, Color.BlueViolet), SolidColor.Transparent, new Rectangle(new Point(0, 0), headerSize));
 }
예제 #12
0
 public override void OnPaint(CellDrawingContext dc)
 {
     base.OnPaint(dc);
     dc.Graphics.DrawText(cornerDisplay, "Calibri", 8, SolidColor.Black, Bounds, unvell.ReoGrid.ReoGridHorAlign.Right, unvell.ReoGrid.ReoGridVerAlign.Top);
 }
예제 #13
0
        public override void Draw(CellDrawingContext dc)
        {
#if DEBUG
            Stopwatch sw = Stopwatch.StartNew();
#endif

            if (!Visible ||          //|| visibleGridRegion == GridRegion.Empty
                bounds.Width <= 0 || bounds.Height <= 0)
            {
                return;
            }

            //bool needClip = this.Parent == null
            //	|| this.bounds != this.Parent.Bounds;

            //bool needTranslate = this.Parent == null
            //	|| this.viewStart.X != this.Parent.ViewLeft
            //	|| this.ViewStart.Y != this.Parent.ViewTop;

            var g = dc.Graphics;

            if (PerformTransform)
            {
                g.PushClip(this.bounds);
                g.PushTransform();
                g.TranslateTransform(bounds.Left - ScrollViewLeft * this.scaleFactor, bounds.Top - ScrollViewTop * this.scaleFactor);
            }

            DrawView(dc);

            if (this.PerformTransform)
            {
                g.PopTransform();
                g.PopClip();
            }

#if VP_DEBUG
            if (this is SheetViewport ||
                this is ColumnHeaderView
                //|| this is RowHeaderView
                || this is RowOutlineView)
            {
                //var rect = this.bounds;
                //rect.Width--;
                //rect.Height--;
                //dc.Graphics.DrawRectangle(this.bounds, this is SheetViewport ? SolidColor.Blue : SolidColor.Purple);

                var msg = $"{ this.GetType().Name }\n" +
                          $"{visibleRegion.ToRange()}\n" +
                          $"{this.ViewLeft}, {this.ViewTop}, ({ScrollX}, {ScrollY}), {this.Width}, {this.Height}\n" +
                          $"{this.ScrollableDirections}";

                dc.Graphics.PlatformGraphics.DrawString(msg,
                                                        System.Drawing.SystemFonts.DefaultFont, System.Drawing.Brushes.Blue, this.Left + Width / 2, Top + Height / 2);
            }
#endif // VP_DEBUG

#if DEBUG
            sw.Stop();
            if (sw.ElapsedMilliseconds > 20)
            {
                Debug.WriteLine("draw viewport takes " + sw.ElapsedMilliseconds + " ms. visible region: rows: " + visibleRegion.Rows + ", cols: " + visibleRegion.Cols);
            }
#endif // Debug
        }
예제 #14
0
        private void DrawDataProvider(CellDrawingContext dc)
        {
            if (DataProviders.Count == 0)
            {
                return;
            }
            DataProviders.ForEach(x =>
            {
                if (x.Trigger.TryGetTarget(out var trigger) && trigger != null)
                {
                    trigger.Visibility = System.Windows.Visibility.Collapsed;
                }
            });
            DataProviders.ForEach(x =>
            {
                if (x.Selector.TryGetTarget(out var selector) && selector != null)
                {
                    selector.IsOpen = false;
                }
            });
            if (sheet.SelectionRange.IsEmpty || dc.DrawMode != DrawMode.View)
            {
                return;
            }

            var g = dc.Graphics as WPFGraphics;
            var scaledSelectionRect = GetScaledAndClippedRangeRect(this,
                                                                   sheet.SelectionRange.StartPos, sheet.SelectionRange.StartPos, 0);

            Cell cell = sheet.GetCell(sheet.SelectionRange.StartPos);

            if (cell == null || cell.DataProvider == null)
            {
                return;
            }

            if (g.TransformStack.Count != 0)
            {
                MatrixTransform mt = g.TransformStack.Peek();
                if (mt.TryTransform(new System.Windows.Point(cell.Right, cell.Top), out var righttop))
                {
                    if (righttop.X < this.Left || righttop.Y < this.Top)
                    {
                        if (cell.DataProvider.Trigger.TryGetTarget(out var tigger))
                        {
                            tigger.Visibility = System.Windows.Visibility.Collapsed;

                            tigger.Height = cell.Height;
                        }
                        return;
                    }
                    else
                    {
                        mt.TryTransform(new System.Windows.Point(cell.Left, cell.Bottom), out var leftbottom);
                        if (cell.DataProvider.Trigger.TryGetTarget(out var tigger) && tigger != null)
                        {
                            tigger.Height     = cell.Height;
                            tigger.Visibility = System.Windows.Visibility.Collapsed;
                            var position = (tigger.Parent as Canvas).PointToScreen(leftbottom);
                            tigger.Margin     = new System.Windows.Thickness(righttop.X, righttop.Y, 0, 0);
                            tigger.Visibility = System.Windows.Visibility.Visible;
                            Rectangle rectangle = new Rectangle(position.X, position.Y, righttop.X - leftbottom.X, righttop.Y - leftbottom.Y);
                            cell.DataProvider.Update(rectangle, cell);
                        }
                    }
                }
            }
            else
            {
                if (cell.DataProvider.Trigger.TryGetTarget(out var tigger))
                {
                    tigger.Margin     = new System.Windows.Thickness(this.Left + scaledSelectionRect.Right, this.Top + scaledSelectionRect.Top, 0, 0);
                    tigger.Visibility = System.Windows.Visibility.Visible;
                }
            }
        }
예제 #15
0
 /// <summary>
 /// Draw button surface.
 /// </summary>
 /// <param name="dc">Platform independence drawing context.</param>
 /// <param name="state">Button state.</param>
 protected virtual void DrawButton(CellDrawingContext dc)
 {
     ControlPaint.DrawButton(dc.Graphics.PlatformGraphics, (System.Drawing.Rectangle)Bounds,
                             this.IsPressed ? ButtonState.Pushed :
                             (this.Cell.IsReadOnly ? ButtonState.Inactive : ButtonState.Normal));
 }
예제 #16
0
        public override void Draw(CellDrawingContext dc)
        {
#if DEBUG
            Stopwatch sw = Stopwatch.StartNew();
#endif

            if (!Visible ||          //|| visibleGridRegion == GridRegion.Empty
                bounds.Width <= 0 || bounds.Height <= 0)
            {
                return;
            }

            //bool needClip = this.Parent == null
            //	|| this.bounds != this.Parent.Bounds;

            //bool needTranslate = this.Parent == null
            //	|| this.viewStart.X != this.Parent.ViewLeft
            //	|| this.ViewStart.Y != this.Parent.ViewTop;

            var g = dc.Graphics;

            if (PerformTransform)
            {
                g.PushClip(this.bounds);
                g.PushTransform();
                g.TranslateTransform(bounds.Left - ScrollViewLeft * this.scaleFactor, bounds.Top - ScrollViewTop * this.scaleFactor);
            }

            DrawView(dc);

            if (this.PerformTransform)
            {
                g.PopTransform();
                g.PopClip();
            }

#if VP_DEBUG
#if WINFORM
            if (this is SheetViewport ||
                this is ColumnHeaderView
                //|| this is RowHeaderView
                || this is RowOutlineView)
            {
                //var rect = this.bounds;
                //rect.Width--;
                //rect.Height--;
                //dc.Graphics.DrawRectangle(this.bounds, this is SheetViewport ? SolidColor.Blue : SolidColor.Purple);

                var msg = $"{ this.GetType().Name }\n" +
                          $"{visibleRegion.ToRange()}\n" +
                          $"{this.ViewLeft}, {this.ViewTop}, ({ScrollX}, {ScrollY}), {this.Width}, {this.Height}\n" +
                          $"{this.ScrollableDirections}";

                dc.Graphics.PlatformGraphics.DrawString(msg,
                                                        System.Drawing.SystemFonts.DefaultFont, System.Drawing.Brushes.Blue, this.Left + Width / 2, Top + Height / 2);
            }
#elif WPF
            var msg = string.Format("VR {0},{1}-{2},{3} VS X{4},Y{5}\nSD {6}", this.visibleRegion.startRow,
                                    this.visibleRegion.startCol, this.visibleRegion.endRow, this.visibleRegion.endCol, this.ViewLeft, this.ViewTop,
                                    this.ScrollableDirections.ToString());

            var ft = new System.Windows.Media.FormattedText(msg, System.Globalization.CultureInfo.CurrentCulture, System.Windows.FlowDirection.LeftToRight,
                                                            new System.Windows.Media.Typeface("Arial"), 12, System.Windows.Media.Brushes.Blue, 96);

            dc.Graphics.PlatformGraphics.DrawText(ft, new System.Windows.Point(this.Left + 1, this.Top + ((this is CellsViewport) ? 30 : this.Height / 2)));
#endif // WPF
#endif // VP_DEBUG

#if DEBUG
            sw.Stop();
            if (sw.ElapsedMilliseconds > 20)
            {
                Debug.WriteLine("draw viewport takes " + sw.ElapsedMilliseconds + " ms. visible region: rows: " + visibleRegion.Rows + ", cols: " + visibleRegion.Cols);
            }
#endif // Debug
        }
예제 #17
0
 public virtual void DrawView(CellDrawingContext dc)
 {
     this.DrawChildren(dc);
 }
예제 #18
0
 /// <summary>
 /// Paint the content of body.
 /// </summary>
 /// <param name="dc">Platform independency graphics context.</param>
 public virtual void OnPaint(CellDrawingContext dc)
 {
     dc.DrawCellBackground();
     dc.DrawCellText();
 }
예제 #19
0
        public override void DrawView(CellDrawingContext dc)
        {
            var g = dc.Renderer;

            if (bounds.Width <= 0 || sheet.controlAdapter == null)
            {
                return;
            }

            var controlStyle = sheet.workbook.controlAdapter.ControlStyle;

            g.BeginDrawHeaderText(this.scaleFactor);

            var splitterLinePen  = dc.Renderer.GetPen(controlStyle.Colors[ControlAppearanceColors.RowHeadSplitter]);
            var defaultTextBrush = dc.Renderer.GetBrush(controlStyle.Colors[ControlAppearanceColors.RowHeadText]);

            bool isFullRowSelected = sheet.SelectionRange.Cols == sheet.ColumnCount;

            for (int i = visibleRegion.startRow; i <= visibleRegion.endRow; i++)
            {
                bool isSelected = i >= sheet.SelectionRange.Row && i <= sheet.SelectionRange.EndRow;

                RowHeader row = sheet.rows[i];
                RGFloat   y   = row.Top * this.scaleFactor;

                if (!row.IsVisible)
                {
                    g.DrawLine(splitterLinePen, 0, y - 1, bounds.Width, y - 1);
                }
                else
                {
                    Rectangle rect = new Rectangle(0, y, bounds.Width, row.InnerHeight * this.scaleFactor);

                    if (rect.Height > 0)
                    {
                        g.FillRectangle(rect, controlStyle.GetRowHeadEndColor(false, isSelected, isSelected && isFullRowSelected, false));
                        g.DrawLine(splitterLinePen, new Point(0, y), new Point(bounds.Width, y));

                        var headerText = row.Text != null ? row.Text : (row.Row + 1).ToString();

                        if (!string.IsNullOrEmpty(headerText))
                        {
                            var textBrush = row.TextColor != null?
                                            dc.Renderer.GetBrush((SolidColor)row.TextColor) : defaultTextBrush;

                            if (textBrush == null)
                            {
                                textBrush = defaultTextBrush;
                            }

                            g.DrawHeaderText(headerText, textBrush, rect);
                        }
                    }
                }
            }

            if (visibleRegion.endRow >= 0)
            {
                RGFloat ly = sheet.rows[visibleRegion.endRow].Bottom * this.scaleFactor;
                g.DrawLine(splitterLinePen, 0, ly, bounds.Width, ly);
            }

            // right line
            if (!sheet.HasSettings(WorksheetSettings.View_ShowGridLine))
            {
                dc.Graphics.DrawLine(dc.Renderer.GetPen(controlStyle.Colors[ControlAppearanceColors.RowHeadSplitter]),
                                     bounds.Right, bounds.Y, bounds.Right,
                                     Math.Min((sheet.rows[sheet.rows.Count - 1].Bottom - ViewTop) * this.scaleFactor + bounds.Top, bounds.Bottom));
            }
        }
예제 #20
0
 /// <summary>
 /// Paint content of cell body.
 /// </summary>
 /// <param name="dc">Platform independency graphics context.</param>
 protected virtual void OnContentPaint(CellDrawingContext dc)
 {
 }
예제 #21
0
 public override void Draw(CellDrawingContext dc)
 {
     dc.Graphics.FillRectangle(bounds, Rendering.StaticResources.SystemColor_Control);
 }
예제 #22
0
        public override void DrawView(CellDrawingContext dc)
        {
            var g            = dc.Graphics;
            var controlStyle = sheet.workbook.controlAdapter.ControlStyle;

#if DEBUG
            Stopwatch sw = Stopwatch.StartNew();
#endif
            var outlines = sheet.outlines[RowOrColumn.Column];

            if (outlines != null)
            {
                var p = dc.Renderer.GetPen(controlStyle[ControlAppearanceColors.OutlineButtonBorder]);

                RGFloat scale          = Math.Min(this.scaleFactor, 1f);
                RGFloat halfButtonSize = Worksheet.OutlineButtonSize / 2f * scale;

                for (int idx = 0; idx < outlines.Count; idx++)
                {
                    OutlineGroup <ReoGridOutline> line = null;

                    if (idx < outlines.Count - 1)
                    {
                        line = outlines[idx];

                        foreach (var outline in line)
                        {
                            var endCol = sheet.cols[outline.End];

                            if (!endCol.IsVisible)
                            {
                                continue;
                            }

                            if (this.scaleFactor > 0.5f)
                            {
                                p.Width = 2;
                            }

                            Rectangle bbRect = outline.ToggleButtonBounds;

                            RGFloat crossX = bbRect.X + bbRect.Width / 2;
                            RGFloat crossY = bbRect.Y + bbRect.Height / 2;

                            if (outline.InternalCollapsed)
                            {
                                g.DrawLine(p, crossX, bbRect.Top + 3, crossX, bbRect.Bottom - 2);
                            }
                            else
                            {
                                // -

                                var     startCol = sheet.cols[outline.Start];
                                RGFloat x        = startCol.Left * this.scaleFactor;

                                g.DrawLine(p, x, bbRect.Bottom - 1, x, crossY);
                                g.DrawLine(p, x - 1, crossY, bbRect.Left, crossY);
                            }

                            // |
                            g.DrawLine(p, bbRect.Left + 3, crossY, bbRect.Right - 2, crossY);

                            // frame
                            p.Width = 1;
                            g.DrawRectangle(p, bbRect.X, bbRect.Y, bbRect.Width, bbRect.Height);
                        }
                    }

                    // draw dot
                    var prevGroup = idx <= 0 ? null : outlines[idx - 1];
                    if (prevGroup != null)
                    {
                        int y = (int)Math.Round((3 + Worksheet.OutlineButtonSize) * idx * scale);

                        foreach (var prevol in prevGroup)
                        {
                            if (!prevol.InternalCollapsed)
                            {
                                for (int r = prevol.Start; r < prevol.End; r++)
                                {
                                    if (line == null || !line.Any(o => o.Start <= r && o.End >= r))
                                    {
                                        var colHead = sheet.cols[r];
                                        if (colHead.IsVisible)
                                        {
                                            RGFloat x = (colHead.Left + colHead.InnerWidth / 2) * this.scaleFactor;

                                            g.DrawLine(p, x - 1, y + halfButtonSize, x - 1, y + halfButtonSize + 1);
                                            g.DrawLine(p, x, y + halfButtonSize, x, y + halfButtonSize + 1);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

#if DEBUG
            sw.Stop();
            long ms = sw.ElapsedMilliseconds;
            if (ms > 10)
            {
                Debug.WriteLine("draw column outlines takes " + ms + " ms.");
            }
#endif
        }
예제 #23
0
파일: ImageCell.cs 프로젝트: zxscn/ReoGrid
        /// <summary>
        /// Render the image cell body.
        /// </summary>
        /// <param name="dc">Platform no-associated drawing context instance.</param>
        public override void OnPaint(CellDrawingContext dc)
        {
            if (Image != null)
            {
                RGFloat x = Bounds.X, y = Bounds.Y, width = 0, height = 0;
                bool    needClip = false;

                switch (this.viewMode)
                {
                default:
                case ImageCellViewMode.Stretch:
                    width  = Bounds.Width;
                    height = Bounds.Height;
                    break;

                case ImageCellViewMode.Zoom:
                    RGFloat widthRatio  = (RGFloat)Bounds.Width / Image.Width;
                    RGFloat heightRatio = (RGFloat)Bounds.Height / Image.Height;
                    RGFloat minRatio    = Math.Min(widthRatio, heightRatio);
                    width  = minRatio * Image.Width;
                    height = minRatio * Image.Height;
                    break;

                case ImageCellViewMode.Clip:
                    width  = Image.Width;
                    height = Image.Height;

                    if (width > Bounds.Width || height > Bounds.Height)
                    {
                        needClip = true;
                    }
                    break;
                }

                switch (Cell.Style.HAlign)
                {
                default:
                case ReoGridHorAlign.Left:
                    x = Bounds.X;
                    break;

                case ReoGridHorAlign.Center:
                    x = (Bounds.Width - width) / 2;
                    break;

                case ReoGridHorAlign.Right:
                    x = Bounds.Width - width;
                    break;
                }

                switch (Cell.Style.VAlign)
                {
                default:
                case ReoGridVerAlign.Top:
                    y = Bounds.Y;
                    break;

                case ReoGridVerAlign.Middle:
                    y = (Bounds.Height - height) / 2;
                    break;

                case ReoGridVerAlign.Bottom:
                    y = Bounds.Height - height;
                    break;
                }

                var g = dc.Graphics;

                if (needClip)
                {
                    g.PushClip(Bounds);
                }

                g.DrawImage(Image, x, y, width, height);

                if (needClip)
                {
                    g.PopClip();
                }
            }

            dc.DrawCellText();
        }
 public override void OnPaint(CellDrawingContext dc)
 {
     base.OnPaint(dc);
 }