Esempio n. 1
0
        public override void DrawImage(GraphicsHandler graphics, RectangleF source, RectangleF destination)
        {
            var sourceRect = new CGRect(source.X, (float)Control.Size.Height - source.Y - source.Height, source.Width, source.Height);
            var destRect   = graphics.TranslateView(destination.ToNS(), true, true);

            Control.Draw(destRect, sourceRect, NSCompositingOperation.SourceOver, 1, true, null);
        }
Esempio n. 2
0
            void DrawPattern(CGContext context)
            {
                var destRect = new CGRect(0, 0, image.Width, image.Height);

                context.ConcatCTM(new CGAffineTransform(1, 0, 0, -1, 0, image.Height));
                context.DrawImage(destRect, image);
            }
Esempio n. 3
0
        void SetPosition(Control control, PointF point, float frameHeight, bool flipped)
        {
            var offset    = ((IMacViewHandler)control.Handler).PositionOffset;
            var childView = control.GetContainerView();

            var preferredSize = control.GetPreferredSize(Control.Frame.Size.ToEtoSize());

            CGPoint origin;

            if (flipped)
            {
                origin = new CGPoint(
                    point.X + offset.Width,
                    point.Y + offset.Height
                    );
            }
            else
            {
                origin = new CGPoint(
                    point.X + offset.Width,
                    frameHeight - (preferredSize.Height + point.Y + offset.Height)
                    );
            }

            var frame = new CGRect(origin, preferredSize.ToNS());

            if (frame != childView.Frame)
            {
                childView.Frame = frame;
            }
        }
Esempio n. 4
0
            public override void DrawWithFrame(CGRect cellFrame, NSView inView)
            {
                var progress = FloatValue;

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

                base.DrawWithFrame(cellFrame, inView);

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

                if (Font != null)
                {
                    str.AddAttributes(NSDictionary.FromObjectAndKey(Font, NSAttributedString.FontAttributeName), range);
                }
                var size = FontExtensions.MeasureString(str, cellFrame.Size.ToEto());
                var rect = cellFrame.ToEto();

                rect.Offset((rect.Size - size) / 2);

                str.DrawString(rect.ToNS());
            }
Esempio n. 5
0
            public override void DrawInteriorWithFrame(CGRect cellFrame, NSView inView)
            {
                var nscontext = NSGraphicsContext.CurrentContext;

                nscontext.ImageInterpolation = ImageInterpolation;
                base.DrawInteriorWithFrame(cellFrame, inView);
            }
Esempio n. 6
0
 public override void DrawRect(CGRect dirtyRect)
 {
     if (BackgroundColor != null && BackgroundColor.AlphaComponent > 0)
     {
         BackgroundColor.Set();
         NSGraphics.RectFill(dirtyRect);
     }
     base.DrawRect(dirtyRect);
 }
Esempio n. 7
0
        public void DrawEllipse(Pen pen, float x, float y, float width, float height)
        {
            SetOffset(false);
            StartDrawing();
            var rect = new CGRect(x, y, width, height);

            pen.Apply(this);
            Control.StrokeEllipseInRect(rect);
            EndDrawing();
        }
Esempio n. 8
0
 public override CGRect DrawTitle(NSAttributedString title, CGRect frame, NSView controlView)
 {
     if (textAttributes != null)
     {
         var str = new NSMutableAttributedString(title);
         str.AddAttributes(textAttributes, new NSRange(0, title.Length));
         title = str;
     }
     return(base.DrawTitle(title, frame, controlView));
 }
Esempio n. 9
0
        public override void DrawInteriorWithFrame(CGRect cellFrame, NSView inView)
        {
            var data = ObjectValue as MacImageData;

            if (data != null)
            {
                if (data.Image != null)
                {
                    var imageSize = data.Image.Size;
                    if (imageSize.Width > 0 && imageSize.Height > 0)
                    {
                        var newHeight = (nfloat)Math.Min(imageSize.Height, cellFrame.Height);
                        var newWidth  = (nfloat)(imageSize.Width * newHeight / imageSize.Height);

                        var imageRect = new CGRect(cellFrame.X, cellFrame.Y, newWidth, newHeight);
                        imageRect.Y += (cellFrame.Height - newHeight) / 2;

                        if (data.Image.RespondsToSelector(new Selector(selDrawInRectFromRectOperationFractionRespectFlippedHints)))
                        {
                            // 10.6+
                            data.Image.Draw(imageRect, new CGRect(CGPoint.Empty, data.Image.Size), NSCompositingOperation.SourceOver, 1, true, null);
                        }
                        else
                        {
                            // 10.5-
                                                        #pragma warning disable 618
                            data.Image.Flipped = ControlView.IsFlipped;
                                                        #pragma warning restore 618
                            data.Image.Draw(imageRect, new CGRect(CGPoint.Empty, data.Image.Size), NSCompositingOperation.SourceOver, 1);
                        }
                        cellFrame.Width -= newWidth + ImagePadding;
                        cellFrame.X     += newWidth + ImagePadding;
                    }
                }
            }

            var titleSize = AttributedStringValue.Size;

            // test to see if the text height is bigger then the cell, if it is,
            // don't try to center it or it will be pushed up out of the cell!
            if (titleSize.Height < cellFrame.Size.Height)
            {
                cellFrame.Y = cellFrame.Y + (cellFrame.Size.Height - titleSize.Height) / 2;
            }

            if (UseTextShadow)
            {
                var str = new NSMutableAttributedString(StringValue);
                str.AddAttribute(NSAttributedString.ShadowAttributeName, Highlighted ? TextHighlightShadow : TextShadow, new NSRange(0, (int)str.Length));
                AttributedStringValue = str;
            }

            base.DrawInteriorWithFrame(cellFrame, inView);
        }
Esempio n. 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();
        }
Esempio n. 11
0
            public override void DrawRect(CGRect dirtyRect)
            {
                if (Handler.HasFocus)
                {
                    NSGraphicsContext.CurrentContext.SaveGraphicsState();
                    GraphicsExtensions.SetFocusRingStyle(NSFocusRingPlacement.RingOnly);
                    NSGraphics.RectFill(this.Bounds);
                    NSGraphicsContext.CurrentContext.RestoreGraphicsState();
                }

                base.DrawRect(dirtyRect);
            }
Esempio n. 12
0
            public override void DrawBorderAndBackground(CGRect cellFrame, NSView controlView)
            {
                if (DrawsBackground)
                {
                    var nscontext = NSGraphicsContext.CurrentContext;
                    var context   = nscontext.GraphicsPort;

                    context.SetFillColor(BackgroundColor.CGColor);
                    context.FillRect(cellFrame);
                }

                base.DrawBorderAndBackground(cellFrame, controlView);
            }
Esempio n. 13
0
            public override void DrawRect(CGRect dirtyRect)
            {
                var operation = NSPrintOperation.CurrentOperation;

                var context = Messaging.GetNSObject <NSGraphicsContext>(Messaging.IntPtr_objc_msgSend(classNSGraphicsContext, selCurrentContext));

                // this causes monomac to hang for some reason:
                //var context = NSGraphicsContext.CurrentContext;

                using (var graphics = new Graphics(new GraphicsHandler(this, context, (float)Frame.Height, IsFlipped)))
                {
                    Handler.Callback.OnPrintPage(Handler.Widget, new PrintPageEventArgs(graphics, operation.PrintInfo.PaperSize.ToEto(), (int)operation.CurrentPage - 1));
                }
            }
Esempio n. 14
0
            /// <summary>
            /// The area to the right and below the rows is not filled with the background
            /// color. This fixes that. See http://orangejuiceliberationfront.com/themeing-nstableview/
            /// </summary>
            public override void DrawBackground(CGRect clipRect)
            {
                var backgroundColor = Handler.BackgroundColor;

                if (backgroundColor != Colors.Transparent)
                {
                    backgroundColor.ToNSUI().Set();
                    NSGraphics.RectFill(clipRect);
                }
                else
                {
                    base.DrawBackground(clipRect);
                }
            }
Esempio n. 15
0
            public override CGRect DrawTitle(NSAttributedString title, CGRect frame, NSView controlView)
            {
                if (TextColor != null)
                {
                    var newtitle = (NSMutableAttributedString)title.MutableCopy();
                    var range    = new NSRange(0, (int)title.Length);
                    newtitle.RemoveAttribute(NSStringAttributeKey.ForegroundColor, range);
                    newtitle.AddAttribute(NSStringAttributeKey.ForegroundColor, TextColor, range);
                    title = newtitle;
                }
                var rect = base.DrawTitle(title, frame, controlView);

                return(rect);
            }
Esempio n. 16
0
        public override void DrawImage(GraphicsHandler graphics, RectangleF source, RectangleF destination)
        {
            var sourceRect = new CGRect(source.X, (float)Control.Size.Height - source.Y - source.Height, source.Width, source.Height);
            var destRect   = destination.ToNS();

            if (alpha)
            {
                Control.Draw(destRect, sourceRect, NSCompositingOperation.SourceOver, 1, true, null);
            }
            else
            {
                Control.Draw(destRect, sourceRect, NSCompositingOperation.Copy, 1, true, null);
            }
        }
Esempio n. 17
0
 public override void DrawBezelWithFrame(CGRect frame, NSView controlView)
 {
     if (Color != null)
     {
         MacEventView.Colourize(controlView, Color.Value, delegate
         {
             base.DrawBezelWithFrame(frame, controlView);
         });
     }
     else
     {
         base.DrawBezelWithFrame(frame, controlView);
     }
 }
Esempio n. 18
0
 public Bitmap Clone(Rectangle?rectangle = null)
 {
     if (rectangle == null)
     {
         return(new Bitmap(new BitmapHandler((NSImage)Control.Copy())));
     }
     else
     {
         var rect    = new CGRect(CGPoint.Empty, Control.Size);
         var image   = new NSImage();
         var cgimage = Control.AsCGImage(ref rect, null, null).WithImageInRect(rectangle.Value.ToSDRectangleF());
         image.AddRepresentation(new NSBitmapImageRep(cgimage));
         return(new Bitmap(new BitmapHandler(image)));
     }
 }
Esempio n. 19
0
        // TODO: Mac64
                #if !Mac64 && !XAMMAC2
        public override CGSize CellSizeForBounds(CGRect bounds)
        {
            var size = base.CellSizeForBounds(bounds);
            var data = ObjectValue as MacImageData;

            if (data != null && data.Image != null)
            {
                var imageSize = data.Image.Size;
                var newHeight = Math.Min(imageSize.Height, size.Height);
                var newWidth  = imageSize.Width * newHeight / imageSize.Height;
                size.Width += (nfloat)(newWidth + ImagePadding);
            }
            size.Width = (nfloat)Math.Min(size.Width, bounds.Width);
            return(size);
        }
Esempio n. 20
0
 public override void Zoom(NSObject sender)
 {
     if (zoom)
     {
         SetFrame(oldFrame, true, true);
         zoom = false;
     }
     else
     {
         oldFrame = Frame;
         base.Zoom(sender ?? this);                 // null when double clicking the title bar, but xammac/monomac doesn't allow it
         zoom = true;
     }
     Handler.Callback.OnWindowStateChanged(Handler.Widget, EventArgs.Empty);
 }
Esempio n. 21
0
 public override void DrawRect(CGRect dirtyRect)
 {
     if (Handler.curValue != null)
     {
         base.DrawRect(dirtyRect);
     }
     else
     {
         // paint with no elements visible
         var old = DatePickerElements;
         DatePickerElements = 0;
         base.DrawRect(dirtyRect);
         DatePickerElements = old;
     }
 }
Esempio n. 22
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);
                }

                nscontext.ImageInterpolation = ImageInterpolation;

                base.DrawInteriorWithFrame(cellFrame, inView);
            }
Esempio n. 23
0
 public override void Zoom(NSObject sender)
 {
     if (zoom)
     {
         SetFrame(oldFrame, true, true);
         zoom = false;
     }
     else
     {
         oldFrame = Frame;
         base.Zoom(sender);
         zoom = true;
     }
     Handler.Callback.OnWindowStateChanged(Handler.Widget, EventArgs.Empty);
 }
            void SetPattern()
            {
                sectionSize = new CGSize((EndPoint.X - StartPoint.X) + 1, (EndPoint.Y - StartPoint.Y) + 1);
                if (Wrap == GradientWrapMode.Reflect)
                {
                    tileSize = new CGSize(sectionSize.Width * 4, sectionSize.Height * 4);
                }
                else
                {
                    tileSize = new CGSize(sectionSize.Width * 2, sectionSize.Height * 2);
                }
                var rect = new CGRect(StartPoint, tileSize);
                var t    = CGAffineTransform.Multiply(transform, viewTransform);

                pattern = new CGPattern(rect, t, rect.Width, rect.Height, CGPatternTiling.NoDistortion, true, DrawPattern);
            }
Esempio n. 25
0
        public override CGRect DrawingRectForBounds(CGRect theRect)
        {
            var rect      = base.DrawingRectForBounds(theRect);
            var titleSize = CellSizeForBounds(theRect);

            switch (VerticalAlign)
            {
            case VerticalAlignment.Center:
                rect.Y = (nfloat)Math.Round(theRect.Y + (theRect.Height - titleSize.Height) / 2.0F);
                break;

            case VerticalAlignment.Bottom:
                rect.Y = theRect.Y + (theRect.Height - titleSize.Height);
                break;
            }
            return(rect);
        }
Esempio n. 26
0
        public void DrawArc(Pen pen, float x, float y, float width, float height, float startAngle, float sweepAngle)
        {
            SetOffset(false);
            StartDrawing();

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

            pen.Apply(this);
            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.AddArc(centerX, centerY, rect.Width / 2, CGConversions.DegreesToRadians(startAngle), CGConversions.DegreesToRadians(startAngle + sweepAngle), sweepAngle < 0);
            Control.StrokePath();
            EndDrawing();
        }
Esempio n. 27
0
 public CGRect TranslateView(CGRect rect, bool halfers = false, bool inverse = false)
 {
     if (halfers)
     {
         if (inverse)
         {
             rect.X += inverseoffset;
             rect.Y += inverseoffset;
         }
         else
         {
             rect.X += offset;
             rect.Y += offset;
         }
     }
     return(rect);
 }
Esempio n. 28
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();
        }
Esempio n. 29
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
                }
            }
Esempio n. 30
0
        static bool HandleShouldZoom(NSWindow window, CGRect newFrame)
        {
            var handler = GetHandler(window) as MacWindow <TControl, TWidget, TCallback>;

            if (handler == null)
            {
                return(true);
            }
            if (!handler.Maximizable)
            {
                return(false);
            }
            if (!window.IsZoomed && window.Screen != null)
            {
                handler.RestoreBounds = handler.Widget.Bounds;
            }
            return(true);
        }
Esempio n. 31
0
		public CGRect TranslateView(CGRect rect, bool halfers = false, bool inverse = false)
		{
			if (halfers)
			{
				if (inverse)
				{
					rect.X += inverseoffset;
					rect.Y += inverseoffset;
				}
				else
				{
					rect.X += offset;
					rect.Y += offset;
				}
			}
			return rect;
		}
Esempio n. 32
0
		static extern void RectangleF_objc_msgSend_stret_SizeF_int(out CGRect retval, IntPtr receiver, IntPtr selector, CGSize arg1, nint arg2);
Esempio n. 33
0
		public override void DrawInteriorWithFrame(CGRect cellFrame, NSView inView)
		{
			var data = ObjectValue as MacImageData;
			if (data != null)
			{
					
				if (data.Image != null)
				{
					var imageSize = data.Image.Size;
					if (imageSize.Width > 0 && imageSize.Height > 0)
					{
						var newHeight = (nfloat)Math.Min(imageSize.Height, cellFrame.Height);
						var newWidth = (nfloat)(imageSize.Width * newHeight / imageSize.Height);
						
						var imageRect = new CGRect(cellFrame.X, cellFrame.Y, newWidth, newHeight);
						imageRect.Y += (cellFrame.Height - newHeight) / 2;

						if (data.Image.RespondsToSelector(new Selector(selDrawInRectFromRectOperationFractionRespectFlippedHints)))
							// 10.6+
							data.Image.Draw(imageRect, new CGRect(CGPoint.Empty, data.Image.Size), NSCompositingOperation.SourceOver, 1, true, null);
						else
						{
							// 10.5-
							#pragma warning disable 618
							data.Image.Flipped = ControlView.IsFlipped; 
							#pragma warning restore 618
							data.Image.Draw(imageRect, new CGRect(CGPoint.Empty, data.Image.Size), NSCompositingOperation.SourceOver, 1);
						}
						cellFrame.Width -= newWidth + ImagePadding;
						cellFrame.X += newWidth + ImagePadding;
					}
				}
			}

			var titleSize = AttributedStringValue.Size;
			
			// test to see if the text height is bigger then the cell, if it is,
			// don't try to center it or it will be pushed up out of the cell!
			if (titleSize.Height < cellFrame.Size.Height)
			{
				cellFrame.Y = cellFrame.Y + (cellFrame.Size.Height - titleSize.Height) / 2;
			}
			
			if (UseTextShadow)
			{
				var str = new NSMutableAttributedString(StringValue);
				str.AddAttribute(NSAttributedString.ShadowAttributeName, Highlighted ? TextHighlightShadow : TextShadow, new NSRange(0, (int)str.Length));
				AttributedStringValue = str;
			}
			
			base.DrawInteriorWithFrame(cellFrame, inView);
		}
Esempio n. 34
0
		public override void DrawInteriorWithFrame(CGRect cellFrame, NSView inView)
		{
			var frame = cellFrame;
			var data = ObjectValue as MacImageData;
			if (data != null)
			{
				if (data.Image != null)
				{
					var imageSize = data.Image.Size;
					if (imageSize.Width > 0 && imageSize.Height > 0)
					{
						var newHeight = (nfloat)Math.Min(imageSize.Height, frame.Height);
						var newWidth = (nfloat)(imageSize.Width * newHeight / imageSize.Height);

						if (DrawsBackground && !Highlighted)
						{
							var g = NSGraphicsContext.CurrentContext.GraphicsPort;
							g.SetFillColor(BackgroundColor.CGColor);
							g.FillRect(new CGRect(frame.X, frame.Y, newWidth + ImagePadding, frame.Height));
						}

						var imageRect = new CGRect(frame.X, frame.Y, newWidth, newHeight);
						imageRect.Y += (frame.Height - newHeight) / 2;

						nfloat alpha = Enabled ? 1 : (nfloat)0.5;

						if (data.Image.RespondsToSelector(new Selector(selDrawInRectFromRectOperationFractionRespectFlippedHints)))
							// 10.6+
							data.Image.Draw(imageRect, new CGRect(CGPoint.Empty, data.Image.Size), NSCompositingOperation.SourceOver, alpha, true, null);
						else
						{
							// 10.5-
							#pragma warning disable 618
							data.Image.Flipped = ControlView.IsFlipped; 
							#pragma warning restore 618
							data.Image.Draw(imageRect, new CGRect(CGPoint.Empty, data.Image.Size), NSCompositingOperation.SourceOver, alpha);
						}
						frame.Width -= newWidth + ImagePadding;
						frame.X += newWidth + ImagePadding;
					}
				}
			}

			var titleSize = AttributedStringValue.Size;
			
			// test to see if the text height is bigger then the cell, if it is,
			// don't try to center it or it will be pushed up out of the cell!
			if (titleSize.Height < frame.Size.Height)
			{
				//frame.Y = frame.Y + (frame.Size.Height - titleSize.Height) / 2;
			}
			
			if (UseTextShadow)
			{
				var str = new NSMutableAttributedString(StringValue);
				str.AddAttribute(NSStringAttributeKey.Shadow, Highlighted ? TextHighlightShadow : TextShadow, new NSRange(0, (int)str.Length));
				AttributedStringValue = str;
			}
			
			base.DrawInteriorWithFrame(frame, inView);
		}
Esempio n. 35
0
		public override CGSize CellSizeForBounds(CGRect bounds)
		{
			var size = base.CellSizeForBounds(bounds);
			var data = ObjectValue as MacImageData;
			if (data != null && data.Image != null)
			{
				var ctl = ControlView as NSTableView;
				var imageSize = data.Image.Size;
				var newHeight = Math.Min(imageSize.Height, ctl != null ? ctl.RowHeight : bounds.Height);
				var newWidth = imageSize.Width * newHeight / imageSize.Height;
				size.Width += (nfloat)(newWidth + ImagePadding);
			}
			size.Width = (nfloat)Math.Min(size.Width, bounds.Width);
			return size;
		}
Esempio n. 36
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();
		}
Esempio n. 37
0
		public void DrawEllipse(Pen pen, float x, float y, float width, float height)
		{
			SetOffset(false);
			StartDrawing();
			var rect = new CGRect(x, y, width, height);
			pen.Apply(this);
			Control.StrokeEllipseInRect(rect);
			EndDrawing();
		}
Esempio n. 38
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();
		}
Esempio n. 39
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();
		}
Esempio n. 40
0
		public void DrawArc(Pen pen, float x, float y, float width, float height, float startAngle, float sweepAngle)
		{
			SetOffset(false);
			StartDrawing();

			var rect = new CGRect(x, y, width, height);
			pen.Apply(this);
			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.AddArc(centerX, centerY, rect.Width / 2, CGConversions.DegreesToRadians(startAngle), CGConversions.DegreesToRadians(startAngle + sweepAngle), sweepAngle < 0);
			Control.StrokePath();
			EndDrawing();
		}