示例#1
0
            public override void DrawInteriorWithFrame(System.Drawing.RectangleF cellFrame, NSView inView)
            {
                var nscontext = NSGraphicsContext.CurrentContext;

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

                var drawableCellHandler = Handler as DrawableCellHandler;
                var handler             = new GraphicsHandler(null, nscontext, cellFrame.Height, flipped: false);
                var graphics            = new Graphics(drawableCellHandler.Widget.Generator, handler);

                if (drawableCellHandler.Widget.PaintHandler != null)
                {
                    var b = graphics.ClipBounds;
                    //graphics.SetClip(clipBounds);
                    drawableCellHandler.Widget.PaintHandler(new DrawableCellPaintArgs
                    {
                        Graphics   = graphics,                       // cachedGraphics,
                        CellBounds = cellFrame.ToEto(),
                        Item       = drawableCellHandler.dataItem,
                        CellState  = DrawableCellState.Normal, // cellState.ToEto(),
                    });
                    graphics.SetClip(b);                       // restore
                }
                //base.DrawInteriorWithFrame (cellFrame, inView);
            }
示例#2
0
        public void FillRectangle(Brush brush, float x, float y, float width, float height)
        {
            SetOffset(true);
            StartDrawing();
            var rect = new CGRect(x, y, width, height);

            Control.AddRect(rect);
            Control.Clip();
            brush.Draw(this, rect.ToEto());
            EndDrawing();
        }
示例#3
0
        public void FillEllipse(Brush brush, float x, float y, float width, float height)
        {
            SetOffset(true);
            StartDrawing();

            /*	if (width == 1 || height == 1)
             * {
             *      DrawLine(color, x, y, x+width-1, y+height-1);
             *      return;
             * }*/
            var rect = new CGRect(x, y, width, height);

            Control.AddEllipseInRect(rect);
            Control.Clip();
            brush.Draw(this, rect.ToEto());
            EndDrawing();
        }
示例#4
0
            public override void DrawWithFrame(CGRect cellFrame, NSView inView)
            {
                if (DrawsBackground && BackgroundColor != null && BackgroundColor.AlphaComponent > 0)
                {
                    BackgroundColor.Set();
                    NSGraphics.RectFill(cellFrame);
                }

                base.DrawWithFrame(cellFrame, inView);

                var progress = FloatValue;

                if (float.IsNaN((float)progress))
                {
                    return;
                }

                string progressText = (int)(progress * 100f) + "%";
                var    str          = new NSMutableAttributedString(progressText, NSDictionary.FromObjectAndKey(TextColor, NSStringAttributeKey.ForegroundColor));
                var    range        = new NSRange(0, str.Length);

                if (Font != null)
                {
                    str.AddAttributes(NSDictionary.FromObjectAndKey(Font, NSStringAttributeKey.Font), range);
                }
                var h = Handler;

                if (h == null)
                {
                    return;
                }


                var size   = h._fontUtility.MeasureString(str, cellFrame.Size.ToEto());
                var rect   = cellFrame.ToEto();
                var offset = (rect.Size - size) / 2;

                if (!NSGraphicsContext.CurrentContext.IsFlipped)
                {
                    offset.Height = -offset.Height;
                }
                rect.Offset(offset);

                str.DrawString(rect.ToNS());
            }
示例#5
0
        public void FillPie(Brush brush, float x, float y, float width, float height, float startAngle, float sweepAngle)
        {
            SetOffset(true);
            StartDrawing();

            var rect = new CGRect(x, y, width, height);

            Control.SaveState();
            var yscale  = rect.Height / rect.Width;
            var centerY = rect.GetMidY();
            var centerX = rect.GetMidX();

            Control.ConcatCTM(new CGAffineTransform(1.0f, 0, 0, yscale, 0, centerY - centerY * yscale));
            Control.MoveTo(centerX, centerY);
            Control.AddArc(centerX, centerY, rect.Width / 2, CGConversions.DegreesToRadians(startAngle), CGConversions.DegreesToRadians(startAngle + sweepAngle), sweepAngle < 0);
            Control.AddLineToPoint(centerX, centerY);
            Control.ClosePath();
            Control.RestoreState();
            Control.Clip();
            brush.Draw(this, rect.ToEto());
            EndDrawing();
        }
示例#6
0
            public override void DrawRect(CGRect dirtyRect)
            {
                var drawable = Drawable;

                if (drawable == null)
                {
                    return;
                }
                if (!IsFlipped)
                {
                    dirtyRect.Y = Frame.Height - dirtyRect.Y - dirtyRect.Height;
                }
                if (dirtyRect.X % 1.0f > 0f)
                {
                    dirtyRect.Width += 1;
                }
                if (dirtyRect.Y % 1.0f > 0f)
                {
                    dirtyRect.Height += 1;
                }
                ApplicationHandler.QueueResizing = true;
                drawable.DrawRegion(Rectangle.Ceiling(dirtyRect.ToEto()));
                ApplicationHandler.QueueResizing = false;
            }
示例#7
0
            public override void DrawInteriorWithFrame(CGRect cellFrame, NSView inView)
            {
                var nscontext = NSGraphicsContext.CurrentContext;

                if (DrawsBackground)
                {
                    var context = nscontext.GraphicsPort;
                    context.SetFillColor(BackgroundColor.ToCG());
                    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 ? CellStates.Selected : CellStates.None;
                    var item  = ObjectValue 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
		public void FillPie(Brush brush, float x, float y, float width, float height, float startAngle, float sweepAngle)
		{
			SetOffset(true);
			StartDrawing();

			var rect = new CGRect(x, y, width, height);
			Control.SaveState();
			var yscale = rect.Height / rect.Width;
			var centerY = rect.GetMidY();
			var centerX = rect.GetMidX();
			Control.ConcatCTM(new CGAffineTransform(1.0f, 0, 0, yscale, 0, centerY - centerY * yscale));
			Control.MoveTo(centerX, centerY);
			Control.AddArc(centerX, centerY, rect.Width / 2, CGConversions.DegreesToRadians(startAngle), CGConversions.DegreesToRadians(startAngle + sweepAngle), sweepAngle < 0);
			Control.AddLineToPoint(centerX, centerY);
			Control.ClosePath();
			Control.RestoreState();
			Control.Clip();
			brush.Draw(this, rect.ToEto());
			EndDrawing();
		}
示例#9
0
		public void FillEllipse(Brush brush, float x, float y, float width, float height)
		{
			SetOffset(true);
			StartDrawing();
			/*	if (width == 1 || height == 1)
			{
				DrawLine(color, x, y, x+width-1, y+height-1);
				return;
			}*/
			var rect = new CGRect(x, y, width, height);
			Control.AddEllipseInRect(rect);
			Control.Clip();
			brush.Draw(this, rect.ToEto());
			EndDrawing();
		}
示例#10
0
		public void FillRectangle(Brush brush, float x, float y, float width, float height)
		{
			SetOffset(true);
			StartDrawing();
			var rect = new CGRect(x, y, width, height);
			Control.AddRect(rect);
			Control.Clip();
			brush.Draw(this, rect.ToEto());
			EndDrawing();
		}