示例#1
0
        protected override void OnPaint(DrawableCellPaintEventArgs e)
        {
            base.OnPaint(e);

            string filePath = Binding.GetValue(e.Item);

            _thumbnailRenderer.FilePath = filePath;
            _thumbnailRenderer.RenderCanvas(e.Graphics, e.ClipRectangle);
        }
示例#2
0
            protected override void OnRender(swm.DrawingContext dc)
            {
                var handler  = Column.Handler;
                var graphics = new Graphics(new GraphicsHandler(this, dc, new sw.Rect(RenderSize), new RectangleF(RenderSize.ToEto()), false));
                var state    = IsSelected ? DrawableCellStates.Selected : DrawableCellStates.None;
                var args     = new DrawableCellPaintEventArgs(graphics, new Rectangle(RenderSize.ToEtoSize()), state, DataContext);

                handler.Callback.OnPaint(handler.Widget, args);
            }
示例#3
0
        protected override void OnPaint(DrawableCellPaintEventArgs e)
        {
            base.OnPaint(e);

            Color color = e.CellState == DrawableCellStates.Selected ? SelectedColor : Color;

            string bindingValue = Binding.GetValue(e.Item);

            SizeF totalSize = e.Graphics.MeasureString(_font, bindingValue);

            string[] lines = bindingValue.Split('\n');

            for (int i = 0; i < lines.Length; i++)
            {
                string line = lines[i];

                SizeF lineSize = e.Graphics.MeasureString(_font, line);

                PointF position = new PointF();

                if (VerticalAlign == VerticalAlignment.Center)
                {
                    position.Y = e.ClipRectangle.MiddleY - (float)Math.Ceiling(totalSize.Height) / 2;
                }
                else if (VerticalAlign == VerticalAlignment.Top)
                {
                    position.Y = e.ClipRectangle.Top - Padding.Top;
                }
                else
                {
                    position.Y = e.ClipRectangle.Bottom - Padding.Bottom;
                }

                position.Y += i * _font.LineHeight;

                if (HorizontalAlign == HorizontalAlignment.Left)
                {
                    position.X = e.ClipRectangle.Left - Padding.Left;
                }
                else if (HorizontalAlign == HorizontalAlignment.Right)
                {
                    position.X = e.ClipRectangle.Right - (float)Math.Ceiling(lineSize.Width) - Padding.Right;
                }
                else
                {
                    position.X = e.ClipRectangle.MiddleX - (float)Math.Ceiling(lineSize.Width) / 2;
                }

                TextLayout layout = new TextLayout();
                layout.Text     = line;
                layout.Position = position;

                e.Graphics.DrawText(_font, color, layout.Position, layout.Text);
            }
        }
示例#4
0
            protected override void OnRender(Cairo.Context cr, Gtk.Widget widget, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, Gtk.CellRendererState flags)
            {
                using (var graphics = new Graphics(new GraphicsHandler(cr, null, false)))
                {
                    var item = Handler.Source.GetItem(Row);
#pragma warning disable 618
                    var args = new DrawableCellPaintEventArgs(graphics, cell_area.ToEto(), flags.ToEto(), item);
                    Handler.Callback.OnPaint(Handler.Widget, args);
#pragma warning restore 618
                }
            }
示例#5
0
 protected override void OnRender(Cairo.Context cr, Gtk.Widget widget, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, Gtk.CellRendererState flags)
 {
     if (Handler.FormattingEnabled)
     {
         Handler.Format(new GtkGridCellFormatEventArgs <Renderer> (this, Handler.Column.Widget, Item, Row));
     }
     using (var graphics = new Graphics(new GraphicsHandler(cr, null, false)))
     {
         var args = new DrawableCellPaintEventArgs(graphics, cell_area.ToEto(), flags.ToEto(), Item);
         Handler.Callback.OnPaint(Handler.Widget, args);
     }
 }
示例#6
0
            protected override void Paint(sd.Graphics graphics, sd.Rectangle clipBounds, sd.Rectangle cellBounds, int rowIndex, swf.DataGridViewElementStates cellState, object value, object formattedValue, string errorText, swf.DataGridViewCellStyle cellStyle, swf.DataGridViewAdvancedBorderStyle advancedBorderStyle, swf.DataGridViewPaintParts paintParts)
            {
                if (!object.ReferenceEquals(cachedGraphicsKey, graphics) ||
                    cachedGraphics == null)
                {
                    cachedGraphicsKey = graphics;
                    cachedGraphics    = new Graphics(new GraphicsHandler(graphics, shouldDisposeGraphics: false));
                }

                graphics.SetClip(cellBounds);
                var args = new DrawableCellPaintEventArgs(cachedGraphics, cellBounds.ToEto(), cellState.ToEto(), value);

                Handler.Callback.OnPaint(Handler.Widget, args);
                graphics.ResetClip();
            }
示例#7
0
            public override void DrawRect(CGRect dirtyRect)
            {
                var nscontext        = NSGraphicsContext.CurrentContext;
                var isFirstResponder = Window.FirstResponder == this;

                if (DrawsBackground)
                {
                    var context = nscontext.GraphicsPort;
                    context.SetFillColor(BackgroundColor.ToCG());
                    context.FillRect(dirtyRect);
                }
                var cellFrame = Bounds;

                var handler = Handler;

                if (handler == null)
                {
                    return;
                }
                var graphicsHandler = new GraphicsHandler(null, nscontext, (float)cellFrame.Height, flipped: true);

                using (var graphics = new Graphics(graphicsHandler))
                {
                    var rowView = this.Superview as NSTableRowView;
                    var state   = CellStates.None;
                    if (rowView != null && rowView.Selected)
                    {
                        state |= CellStates.Selected;
                    }
                    if (isFirstResponder)
                    {
                        state |= CellStates.Editing;
                        SetKeyboardFocusRingNeedsDisplay(cellFrame);
                        nscontext.SaveGraphicsState();
                        GraphicsExtensions.SetFocusRingStyle(NSFocusRingPlacement.RingOnly);
                        NSGraphics.RectFill(cellFrame);
                        nscontext.RestoreGraphicsState();
                    }
                    var item = val as EtoCellValue;
                                        #pragma warning disable 618
                    var args = new DrawableCellPaintEventArgs(graphics, cellFrame.ToEto(), state, item != null ? item.Item : null);
                    handler.Callback.OnPaint(handler.Widget, args);
                                        #pragma warning restore 618
                }
            }
示例#8
0
        protected override void OnPaint(DrawableCellPaintEventArgs e)
        {
            base.OnPaint(e);

            string colourCode = Binding.GetValue(e.Item);

            if (!string.IsNullOrEmpty(colourCode))
            {
                Color colour = Color.Parse(colourCode);

                float x = e.ClipRectangle.Location.X + Padding.Left;
                float y = e.ClipRectangle.Location.Y + Padding.Top;
                float w = MaxWidth > 0 ? MaxWidth : e.ClipRectangle.Width - Padding.Right;
                float h = e.ClipRectangle.Height - Padding.Bottom;

                e.Graphics.FillRectangle(colour, new RectangleF(x, y, w, h));
            }
        }
示例#9
0
            public override void DrawInteriorWithFrame(CGRect cellFrame, NSView inView)
            {
                var nscontext = NSGraphicsContext.CurrentContext;

                if (DrawsBackground)
                {
                    var context = nscontext.GraphicsPort;
                    context.SetFillColor(BackgroundColor.ToCGColor());
                    context.FillRect(cellFrame);
                }

                var handler         = Handler;
                var graphicsHandler = new GraphicsHandler(null, nscontext, (float)cellFrame.Height, flipped: true);

                using (var graphics = new Graphics(graphicsHandler))
                {
                    var state = Highlighted ? DrawableCellStates.Selected : DrawableCellStates.None;
                    var item  = ObjectValue as EtoCellValue;
                    var args  = new DrawableCellPaintEventArgs(graphics, cellFrame.ToEto(), state, item != null ? item.Item : null);
                    handler.Callback.OnPaint(handler.Widget, args);
                }
            }
示例#10
0
            protected override void Paint(sd.Graphics graphics, sd.Rectangle clipBounds, sd.Rectangle cellBounds, int rowIndex, swf.DataGridViewElementStates cellState, object value, object formattedValue, string errorText, swf.DataGridViewCellStyle cellStyle, swf.DataGridViewAdvancedBorderStyle advancedBorderStyle, swf.DataGridViewPaintParts paintParts)
            {
                // save graphics state to prevent artifacts in other paint operations in the grid
                var state = graphics.Save();

                if (!object.ReferenceEquals(cachedGraphicsKey, graphics) || cachedGraphics == null)
                {
                    cachedGraphicsKey = graphics;
                    cachedGraphics    = new Graphics(new GraphicsHandler(graphics, dispose: false));
                }
                else
                {
                    ((GraphicsHandler)cachedGraphics.Handler).SetInitialState();
                }
                graphics.SetClip(cellBounds);
#pragma warning disable 618
                var args = new DrawableCellPaintEventArgs(cachedGraphics, cellBounds.ToEto(), cellState.ToEto(), value);
                Handler.Callback.OnPaint(Handler.Widget, args);
#pragma warning restore 618
                graphics.ResetClip();
                graphics.Restore(state);
            }