Example #1
0
        public void DrawRect(CGRect aRect, bool selected)
        {
            NSGraphics.RectClip(aRect);

            aRect.Intersect(Frame);

            Color.Set();
            NSGraphics.RectFill(aRect);

            if (selected)
            {
                NSColor.Black.Set();
                NSGraphics.FrameRectWithWidth(Frame, 4.0f);
            }

            if (IsLocked)
            {
                float xSize = (Frame.Width > 10.0f) ? 5.0f : 3.0f;

                NSBezierPath path = new NSBezierPath();

                NSColor.Black.Set();
                path.LineWidth = 3.0f;
                path.MoveTo(new CGPoint(MidX(Frame) - xSize, MidY(Frame) - xSize));
                path.LineTo(new CGPoint(MidX(Frame) + xSize, MidY(Frame) + xSize));
                path.MoveTo(new CGPoint(MidX(Frame) - xSize, MidY(Frame) + xSize));
                path.LineTo(new CGPoint(MidX(Frame) + xSize, MidY(Frame) - xSize));
                path.Stroke();
            }
        }
Example #2
0
		public void DrawRect(CGRect aRect, bool selected)
		{
			NSGraphics.RectClip (aRect);
			
			aRect.Intersect (Frame);
			
			Color.Set ();
			NSGraphics.RectFill (aRect);
			
		    if (selected) {
		        NSColor.Black.Set ();
		        NSGraphics.FrameRectWithWidth (Frame, 4.0f);
		    }
			
			if (IsLocked){
				float xSize = (Frame.Width > 10.0f) ? 5.0f : 3.0f;
				
				NSBezierPath path = new NSBezierPath ();
				
				NSColor.Black.Set ();
				path.LineWidth = 3.0f;
				path.MoveTo (new CGPoint (MidX (Frame) - xSize, MidY (Frame) - xSize));
				path.LineTo (new CGPoint (MidX (Frame) + xSize, MidY (Frame) + xSize));
				path.MoveTo (new CGPoint (MidX (Frame) - xSize, MidY (Frame) + xSize));
				path.LineTo (new CGPoint (MidX (Frame) + xSize, MidY (Frame) - xSize));
				path.Stroke ();
				
			}
	
		}
Example #3
0
        public override void MouseDown(NSEvent theEvent)
        {
            Element.Points.CollectionChanged -= OnPointsCollectionChanged;
            Element.Points.Clear();
            currentPath.RemoveAllPoints();

            previousPoint = theEvent.LocationInWindow;
            currentPath.MoveTo(previousPoint);

            InvokeOnMainThread(Layer !.SetNeedsDisplay);
            Element.Points.CollectionChanged += OnPointsCollectionChanged;
        }
        public static XIR.Image RemoteRepresentation(this NSLineJoinStyle obj)
        {
            // Customize the line cap style for the new object.
            var aPath       = new NSBezierPath();
            var lineWidth   = 10;
            var sampleWidth = 50;

            // First we draw the presentation line
            aPath.LineWidth = lineWidth;
            aPath.MoveTo(new CGPoint(lineWidth, lineWidth));
            aPath.LineTo(new CGPoint(lineWidth + sampleWidth / 2, sampleWidth));
            aPath.LineTo(new CGPoint(lineWidth + sampleWidth, lineWidth));

            switch ((NSLineJoinStyle)obj)
            {
            case NSLineJoinStyle.Bevel:
                aPath.LineJoinStyle = NSLineJoinStyle.Bevel;
                break;

            case NSLineJoinStyle.Miter:
                aPath.LineJoinStyle = NSLineJoinStyle.Miter;
                break;

            case NSLineJoinStyle.Round:
                aPath.LineJoinStyle = NSLineJoinStyle.Round;
                break;
            }

            // let's make sure we leave a little room for the line width drawing as well by adding the lineWidth as well
            var width  = aPath.ControlPointBounds.Right + lineWidth;
            var height = aPath.ControlPointBounds.Bottom + lineWidth;

            var nsimage = new NSImage(new CGSize(width, height));

            nsimage.LockFocus();

            brush.Set();
            aPath.Stroke();

            // Second, we draw the inset line to demonstrate the bounds
            aPath.RemoveAllPoints();
            aPath.LineWidth = 2;
            aPath.MoveTo(new CGPoint(lineWidth, lineWidth));
            aPath.LineTo(new CGPoint(lineWidth + sampleWidth / 2, sampleWidth));
            aPath.LineTo(new CGPoint(lineWidth + sampleWidth, lineWidth));

            pen.Set();
            aPath.Stroke();

            nsimage.UnlockFocus();
            return(nsimage.RemoteRepresentation());
        }
Example #5
0
        public void CreateRandomPath()
        {
            CGPoint p = RandomPoint();

            mPath.MoveTo(p);

            for (nint i = 0; i < 25; i++)
            {
                p = RandomPoint();
                mPath.LineTo(p);
            }
            mPath.ClosePath();
        }
Example #6
0
        private NSBezierPath MosconeRooms()
        {
            var path = new NSBezierPath();

            path.MoveTo(new CGPoint(553, -387));
            path.LineTo(new CGPoint(426, -387));
            path.LineTo(new CGPoint(426, -383));
            path.LineTo(new CGPoint(549, -383));
            path.LineTo(new CGPoint(549, -194));
            path.LineTo(new CGPoint(357, -194));
            path.LineTo(new CGPoint(357, -383));
            path.LineTo(new CGPoint(411, -383));
            path.LineTo(new CGPoint(411, -387));
            path.LineTo(new CGPoint(255, -387));
            path.LineTo(new CGPoint(255, -383));
            path.LineTo(new CGPoint(353, -383));
            path.LineTo(new CGPoint(353, -194));
            path.LineTo(new CGPoint(175, -194));
            path.LineTo(new CGPoint(175, -383));
            path.LineTo(new CGPoint(240, -383));
            path.LineTo(new CGPoint(240, -387));
            path.LineTo(new CGPoint(171, -387));
            path.LineTo(new CGPoint(171, -190));
            path.LineTo(new CGPoint(553, -190));
            path.LineTo(new CGPoint(553, -387));

            path.MoveTo(new CGPoint(474, -141));
            path.LineTo(new CGPoint(474, -14));
            path.LineTo(new CGPoint(294, -14));
            path.LineTo(new CGPoint(294, -141));
            path.LineTo(new CGPoint(407, -141));
            path.LineTo(new CGPoint(407, -145));
            path.LineTo(new CGPoint(172, -145));
            path.LineTo(new CGPoint(172, -141));
            path.LineTo(new CGPoint(290, -141));
            path.LineTo(new CGPoint(290, -14));
            path.LineTo(new CGPoint(124, -14));
            path.LineTo(new CGPoint(124, -141));
            path.LineTo(new CGPoint(157, -141));
            path.LineTo(new CGPoint(157, -145));
            path.LineTo(new CGPoint(120, -145));
            path.LineTo(new CGPoint(120, -10));
            path.LineTo(new CGPoint(478, -10));
            path.LineTo(new CGPoint(478, -145));
            path.LineTo(new CGPoint(422, -145));
            path.LineTo(new CGPoint(422, -141));
            path.LineTo(new CGPoint(474, -141));

            return(path);
        }
Example #7
0
		public MyView (CGRect frame) : base (frame)
		{
			lineColor = NSColor.Blue;
			path = new NSBezierPath ();
			path.MoveTo (Bounds.Location);
			path.LineTo (new CGPoint (Bounds.GetMaxX (),Bounds.GetMaxY ()));
		}
Example #8
0
        public static NSBezierPath CreatePolygonPath(this CGRect rect, int sides, double cornerRadius = 0.0, double rotationOffset = 0.0)
        {
            var offsetRadians = rotationOffset * Math.PI / 180;
            var path          = new NSBezierPath();
            var theta         = 2 * Math.PI / sides;

            var width  = (-cornerRadius + Math.Min(rect.Size.Width, rect.Size.Height)) / 2;
            var center = new CGPoint(rect.Width / 2, rect.Height / 2);

            var radius = width + cornerRadius - (Math.Cos(theta) * cornerRadius) / 2;

            var angle  = offsetRadians;
            var corner = new CGPoint(center.X + (radius - cornerRadius) * Math.Cos(angle), center.Y + (radius - cornerRadius) * Math.Sin(angle));

            path.MoveTo(new CGPoint(corner.X + cornerRadius * Math.Cos(angle + theta), corner.Y + cornerRadius * Math.Sin(angle + theta)));

            for (var i = 0; i < sides; i++)
            {
                angle += theta;
                corner = new CGPoint(center.X + (radius - cornerRadius) * Math.Cos(angle), center.Y + (radius - cornerRadius) * Math.Sin(angle));
                var tip   = new CGPoint(center.X + radius * Math.Cos(angle), center.Y + radius * Math.Sin(angle));
                var start = new CGPoint(corner.X + cornerRadius * Math.Cos(angle - theta), corner.Y + cornerRadius * Math.Sin(angle - theta));
                var end   = new CGPoint(corner.X + cornerRadius * Math.Cos(angle + theta), corner.Y + cornerRadius * Math.Sin(angle + theta));

                path.AddLineTo(start);
                path.AddQuadCurveToPoint(end, tip);
            }

            path.ClosePath();

            return(path);
        }
Example #9
0
        CGPath?GetRoundedPath(CGRect rect, nfloat left, nfloat top, nfloat right, nfloat bottom)
        {
#if __IOS__
            var path = new UIBezierPath();
#else
            var path = new NSBezierPath();
#endif
            path.MoveTo(new CGPoint(rect.Width - right, rect.Y));

            path.AddArc(new CGPoint((float)rect.X + rect.Width - right, (float)rect.Y + right), (nfloat)right, (float)(Math.PI * 1.5), (float)Math.PI * 2, true);
            path.AddLineTo(new CGPoint(rect.Width, rect.Height - bottom));

            path.AddArc(new CGPoint((float)rect.X + rect.Width - bottom, (float)rect.Y + rect.Height - bottom), (nfloat)bottom, 0, (float)(Math.PI * .5), true);
            path.AddLineTo(new CGPoint(left, rect.Height));

            path.AddArc(new CGPoint((float)rect.X + left, (float)rect.Y + rect.Height - left), (nfloat)left, (float)(Math.PI * .5), (float)Math.PI, true);
            path.AddLineTo(new CGPoint(rect.X, top));

            path.AddArc(new CGPoint((float)rect.X + top, (float)rect.Y + top), (nfloat)top, (float)Math.PI, (float)(Math.PI * 1.5), true);

            path.ClosePath();

#if __IOS__
            return(path.CGPath);
#else
            return(path.ToCGPath());
#endif
        }
Example #10
0
        public override void DrawRect(CGRect dirtyRect)
        {
            if (_brushToRenderer != null)
            {
                _brushToRenderer.SetFill();
            }
            else
            {
                _colorToRenderer.SetFill();
            }

            var innerRect = NSBezierPath.FromRoundedRect(Bounds, 0, 0);

            NSBezierPath bezierPath = new NSBezierPath();

            bezierPath.MoveTo(new CGPoint(innerRect.Bounds.X, innerRect.Bounds.Y + _bottomLeft));

            // Bottom left (origin):
            bezierPath.AppendPathWithArc(new CGPoint(innerRect.Bounds.X + _bottomLeft, innerRect.Bounds.Y + _bottomLeft), _bottomLeft, (float)180.0, (float)270.0);

            // Bottom right:
            bezierPath.AppendPathWithArc(new CGPoint(innerRect.Bounds.X + innerRect.Bounds.Width - _bottomRight, innerRect.Bounds.Y + _bottomRight), _bottomRight, (float)270.0, (float)360.0);

            // Top right:
            bezierPath.AppendPathWithArc(new CGPoint(innerRect.Bounds.X + innerRect.Bounds.Width - _topRight, innerRect.Bounds.Y + innerRect.Bounds.Height - _topRight), _topRight, (float)0.0, (float)90.0);

            // Top left:
            bezierPath.AppendPathWithArc(new CGPoint(innerRect.Bounds.X + _topLeft, innerRect.Bounds.Y + innerRect.Bounds.Height - _topLeft), _topLeft, (float)90.0, (float)180.0);

            // Implicitly creates left edge.
            bezierPath.Fill();

            base.DrawRect(dirtyRect);
        }
Example #11
0
        public override void DrawRow(nint row, CGRect clipRect)
        {
            if (row >= RowCount)
            {
                return;
            }

            base.DrawRow(row, clipRect);

            NSGraphicsContext.GlobalSaveGraphicsState();
            NSGraphicsContext.CurrentContext.ShouldAntialias = false;

            CGRect rectRow    = RectForRow(row);
            CGRect rectColumn = RectForColumn(0);
            CGRect rect       = Frame;

            CGPoint start = new CGPoint(rectColumn.Left, rectRow.Top);
            CGPoint end   = new CGPoint(rectRow.Right, rectRow.Top);

            var linePath = new NSBezierPath();

            GridColor.Set();
            linePath.MoveTo(start);
            linePath.LineTo(end);
            linePath.ClosePath();
            linePath.Stroke();

            NSGraphicsContext.GlobalRestoreGraphicsState();
        }
Example #12
0
        public override void DrawRect(CGRect dirtyRect)
        {
            base.DrawRect(dirtyRect);

            // Use Core Graphic routines to draw our UI
            NSBezierPath path = new NSBezierPath();

            foreach (var p in _paths)
            {
                path.MoveTo(p.Item1);
                path.LineTo(p.Item2);
            }

            foreach (var n in _nodes)
            {
                path.AppendPathWithOvalInRect(new CGRect(
                                                  n.X - NodeRadius, n.Y - NodeRadius,
                                                  2 * NodeRadius, 2 * NodeRadius));
            }

            NSColor.Cyan.SetStroke();
            path.Stroke();
            NSColor.Orange.SetFill();
            path.Fill();
        }
Example #13
0
			public override void DrawWithFrame (CGRect cellFrame, NSView inView)
			{
				if (IdeApp.Preferences.UserInterfaceTheme == Theme.Dark) {
					var inset = cellFrame.Inset (0.25f, 0.25f);
					inset = new CGRect (inset.X, inset.Y + 2, inset.Width, inset.Height - 2);

					var path = NSBezierPath.FromRoundedRect (inset, 3, 3);
					path.LineWidth = 0.5f;
					Styles.DarkBorderColor.ToNSColor ().SetStroke ();
					path.Stroke ();

					inset = new CGRect (inset.X + 3, inset.Y, inset.Width, inset.Height);
					DrawInteriorWithFrame (inset, inView);

					path = new NSBezierPath ();

					// Draw the separators
					for (int segment = 1; segment < SegmentCount; segment++) {
						nfloat x = inset.X + (33 * segment);
						path.MoveTo (new CGPoint (x, 0));
						path.LineTo (new CGPoint (x, inset.Y + inset.Height));
					}
					path.LineWidth = 0.5f;
					path.Stroke ();
				} else {
					base.DrawWithFrame (cellFrame, inView);
				}
			}
Example #14
0
        public static CAShapeLayer ToShape(this LinePath element)
        {
            var line = new CAShapeLayer();

            var bezierPath = new NSBezierPath();

            bezierPath.MoveTo(new CGPoint(element.X1, element.Y1));
            bezierPath.LineTo(new CGPoint(element.X2, element.Y2));
            line.Path = bezierPath.ToCGPath();

            if (!string.IsNullOrEmpty(element.Stroke))
            {
                line.StrokeColor = XExtensions.ConvertToNSColor(element.Stroke).CGColor;
            }

            if (!string.IsNullOrEmpty(element.Fill))
            {
                line.FillColor = XExtensions.ConvertToNSColor(element.Fill).CGColor;
            }

            line.LineWidth = element.StrokeWidth;

            var width  = Math.Max(element.X1, element.X2) - Math.Min(element.X1, element.X2);
            var height = Math.Max(element.Y1, element.Y2) - Math.Min(element.Y1, element.Y2);

            line.Bounds = new CGRect(0, 0, width, height);

            return(line);
        }
 public MyView(RectangleF frame) : base(frame)
 {
     lineColor = NSColor.Blue;
     path      = new NSBezierPath();
     path.MoveTo(Bounds.Location);
     path.LineTo(new PointF(Bounds.GetMaxX(), Bounds.GetMaxY()));
 }
Example #16
0
        public void DrawLayer(CALayer layer, CoreGraphics.CGContext context)
        {
            NSGraphicsContext.GlobalSaveGraphicsState();
            NSGraphicsContext graphicsContext = NSGraphicsContext.FromGraphicsPort(context, true);

            NSGraphicsContext.CurrentContext = graphicsContext;

            NSBezierPath path = new NSBezierPath();
            //ベジェ曲線
            var x1 = this.Frame.Left;
            var y1 = this.Frame.Top;
            var x2 = this.Frame.Right;
            var y2 = this.Frame.Bottom;

            path.MoveTo(new CoreGraphics.CGPoint(x1, y1));
            path.CurveTo(new CoreGraphics.CGPoint(x2, y1),
                         new CoreGraphics.CGPoint(x1, y2),
                         new CoreGraphics.CGPoint(x2, y2));
            //背景は白
            NSColor.White.Set();
            path.Fill();
            //線は青
            NSColor.Blue.Set();
            //線の太さ
            path.LineWidth = 2;
            path.Stroke();

            NSGraphicsContext.GlobalRestoreGraphicsState();
        }
Example #17
0
            public override void DrawWithFrame(CGRect cellFrame, NSView inView)
            {
                if (IdeApp.Preferences.UserInterfaceTheme == Theme.Dark)
                {
                    var inset = cellFrame.Inset(0.25f, 0.25f);
                    inset = new CGRect(inset.X, inset.Y + 2, inset.Width, inset.Height - 2);

                    var path = NSBezierPath.FromRoundedRect(inset, 3, 3);
                    path.LineWidth = 0.5f;
                    Styles.DarkBorderColor.ToNSColor().SetStroke();
                    path.Stroke();

                    inset = new CGRect(inset.X + 3, inset.Y, inset.Width, inset.Height);
                    DrawInteriorWithFrame(inset, inView);

                    path = new NSBezierPath();

                    // Draw the separators
                    for (int segment = 1; segment < SegmentCount; segment++)
                    {
                        nfloat x = inset.X + (33 * segment);
                        path.MoveTo(new CGPoint(x, 0));
                        path.LineTo(new CGPoint(x, inset.Y + inset.Height));
                    }
                    path.LineWidth = 0.5f;
                    path.Stroke();
                }
                else
                {
                    base.DrawWithFrame(cellFrame, inView);
                }
            }
        private NSBezierPath StarPath(float innerRadius, float outerRadius)
        {
            var raysCount = 5;
            var delta     = 2.0f * (float)Math.PI / raysCount;

            var path = new NSBezierPath();

            for (var i = 0; i < raysCount; ++i)
            {
                var alpha = i * delta + (float)Math.PI / 2;

                if (i == 0)
                {
                    path.MoveTo(new CGPoint(outerRadius * (float)Math.Cos(alpha), outerRadius * (float)Math.Sin(alpha)));
                }
                else
                {
                    path.LineTo(new CGPoint(outerRadius * (float)Math.Cos(alpha), outerRadius * (float)Math.Sin(alpha)));
                }

                alpha += 0.5f * delta;
                path.LineTo(new CGPoint(innerRadius * (float)Math.Cos(alpha), innerRadius * (float)Math.Sin(alpha)));
            }

            return(path);
        }
Example #19
0
        public override void DrawRect(RectangleF rect)
        {
            var xamarinBlue = NSColor.FromDeviceRgba(0.071f, 0.463f, 0.725f, 1.000f);

            NSBezierPath xamarinLogoPath = new NSBezierPath();

            xamarinLogoPath.MoveTo(new PointF(230.49f, 92.68f));
            xamarinLogoPath.LineTo(new PointF(200.74f, 92.68f));
            xamarinLogoPath.LineTo(new PointF(159.7f, 167.71f));
            xamarinLogoPath.LineTo(new PointF(200.74f, 242.73f));
            xamarinLogoPath.LineTo(new PointF(230.49f, 242.73f));
            xamarinLogoPath.LineTo(new PointF(191.23f, 167.71f));
            xamarinLogoPath.LineTo(new PointF(230.49f, 92.68f));
            xamarinLogoPath.ClosePath();
            xamarinLogoPath.MoveTo(new PointF(118.66f, 92.68f));
            xamarinLogoPath.LineTo(new PointF(88.92f, 92.68f));
            xamarinLogoPath.LineTo(new PointF(128.18f, 167.71f));
            xamarinLogoPath.LineTo(new PointF(88.92f, 242.73f));
            xamarinLogoPath.LineTo(new PointF(118.66f, 242.73f));
            xamarinLogoPath.LineTo(new PointF(159.7f, 167.71f));
            xamarinLogoPath.LineTo(new PointF(118.66f, 92.68f));
            xamarinLogoPath.ClosePath();
            xamarinLogoPath.MoveTo(new PointF(220.7f, 37.0f));
            xamarinLogoPath.CurveTo(new PointF(232.55f, 41.1f), new PointF(220.7f, 37.0f), new PointF(227.07f, 38.03f));
            xamarinLogoPath.CurveTo(new PointF(242.62f, 49.31f), new PointF(238.03f, 44.18f), new PointF(242.62f, 49.31f));
            xamarinLogoPath.LineTo(new PointF(304.22f, 152.47f));
            xamarinLogoPath.CurveTo(new PointF(308.95f, 170.05f), new PointF(304.22f, 152.47f), new PointF(309.55f, 163.02f));
            xamarinLogoPath.CurveTo(new PointF(304.22f, 183.53f), new PointF(308.36f, 177.09f), new PointF(304.22f, 183.53f));
            xamarinLogoPath.LineTo(new PointF(243.57f, 286.11f));
            xamarinLogoPath.CurveTo(new PointF(234.05f, 294.31f), new PointF(243.57f, 286.11f), new PointF(239.7f, 291.09f));
            xamarinLogoPath.CurveTo(new PointF(220.97f, 299.0f), new PointF(228.4f, 297.53f), new PointF(220.97f, 299.0f));
            xamarinLogoPath.LineTo(new PointF(97.25f, 299.0f));
            xamarinLogoPath.CurveTo(new PointF(84.16f, 294.31f), new PointF(97.25f, 299.0f), new PointF(89.51f, 297.53f));
            xamarinLogoPath.CurveTo(new PointF(75.83f, 286.11f), new PointF(78.81f, 291.09f), new PointF(75.83f, 286.11f));
            xamarinLogoPath.LineTo(new PointF(13.99f, 181.77f));
            xamarinLogoPath.CurveTo(new PointF(11.03f, 170.05f), new PointF(13.99f, 181.77f), new PointF(11.33f, 176.21f));
            xamarinLogoPath.CurveTo(new PointF(12.81f, 157.16f), new PointF(10.73f, 163.9f), new PointF(12.81f, 157.16f));
            xamarinLogoPath.LineTo(new PointF(75.59f, 49.31f));
            xamarinLogoPath.CurveTo(new PointF(85.07f, 41.1f), new PointF(75.59f, 49.31f), new PointF(79.59f, 44.18f));
            xamarinLogoPath.CurveTo(new PointF(97.5f, 37.0f), new PointF(90.54f, 38.03f), new PointF(97.5f, 37.0f));
            xamarinLogoPath.LineTo(new PointF(220.7f, 37.0f));
            xamarinLogoPath.LineTo(new PointF(220.7f, 37.0f));
            xamarinLogoPath.ClosePath();
            xamarinBlue.SetFill();
            xamarinLogoPath.Fill();
        }
Example #20
0
        private NSBezierPath OutlineChamferProfilePath()
        {
            var path = new NSBezierPath();

            path.MoveTo(new CGPoint(1, 1));
            path.LineTo(new CGPoint(1, 0));
            return(path);
        }
Example #21
0
        public override void DrawRect(CoreGraphics.CGRect dirtyRect)
        {
            NSBezierPath path = new NSBezierPath();

            path.MoveTo(new CoreGraphics.CGPoint(200, 50));
            path.CurveTo(new CoreGraphics.CGPoint(300, 50),
                         new CoreGraphics.CGPoint(100, 300),
                         new CoreGraphics.CGPoint(400, 300));
            DrawPath(path);
        }
        //

        void DrawBottomLine()
        {
            var linePath = new NSBezierPath();

            Utility.ColorWithHexColorValue(BookInfo.FontColor, 1.0f).SetStroke();

            linePath.LineWidth = 2;
            linePath.MoveTo(bottomLineTS);
            linePath.LineTo(bottomLineTE);
            linePath.ClosePath();

            linePath.Stroke();

            //var lineTPath = new NSBezierPath ();
            linePath.MoveTo(bottomLineBS);
            linePath.LineTo(bottomLineBE);
            linePath.ClosePath();
            linePath.Stroke();
        }
Example #23
0
        private NSBezierPath TextChamferProfile()
        {
            var profile = new NSBezierPath();

            profile.MoveTo(new CGPoint(0, 1));
            profile.LineTo(new CGPoint(1.5f, 1));
            profile.LineTo(new CGPoint(1.5f, 0));
            profile.LineTo(new CGPoint(1, 0));
            return(profile);
        }
Example #24
0
        public static NSBezierPath SCArrowBezierPath(CGSize baseSize, CGSize tipSize, float hollow, bool twoSides)
        {
            var arrow = new NSBezierPath();

            var h = new nfloat[5];
            var w = new nfloat[4];

            w [0] = 0;
            w [1] = baseSize.Width - tipSize.Width - hollow;
            w [2] = baseSize.Width - tipSize.Width;
            w [3] = baseSize.Width;

            h [0] = 0;
            h [1] = (tipSize.Height - baseSize.Height) * 0.5f;
            h [2] = (tipSize.Height) * 0.5f;
            h [3] = (tipSize.Height + baseSize.Height) * 0.5f;
            h [4] = tipSize.Height;

            if (twoSides)
            {
                arrow.MoveTo(new CGPoint(tipSize.Width, h [1]));
                arrow.LineTo(new CGPoint(tipSize.Width + hollow, h [0]));
                arrow.LineTo(new CGPoint(0, h [2]));
                arrow.LineTo(new CGPoint(tipSize.Width + hollow, h [4]));
                arrow.LineTo(new CGPoint(tipSize.Width, h [3]));
            }
            else
            {
                arrow.MoveTo(new CGPoint(0, h [1]));
                arrow.LineTo(new CGPoint(0, h [3]));
            }

            arrow.LineTo(new CGPoint(w [2], h [3]));
            arrow.LineTo(new CGPoint(w [1], h [4]));
            arrow.LineTo(new CGPoint(w [3], h [2]));
            arrow.LineTo(new CGPoint(w [1], h [0]));
            arrow.LineTo(new CGPoint(w [2], h [1]));

            arrow.ClosePath();

            return(arrow);
        }
Example #25
0
        private static void DrawHand(NSBezierPath path, PointF center, double radians, float radius)
        {
            path.MoveTo(center);
            path.LineTo(new PointF
            {
                X = center.X + (float)Math.Sin(radians) * radius,
                Y = center.Y + (float)Math.Cos(radians) * radius,
            });

            path.Stroke();
        }
Example #26
0
        public override void DrawRect(CGRect dirtyRect)
        {
            base.DrawRect(dirtyRect);

            var line = new NSBezierPath();

            line.MoveTo(new CGPoint(Frame.Width / 2, 0));
            line.LineTo(new CGPoint(Frame.Width / 2, Frame.Height));
            line.LineWidth = 1;
            NSColor.Gray.Set();
            line.Stroke();
        }
        public override void MouseDown(NSEvent theEvent)
        {
            Element.Lines.CollectionChanged -= OnLinesCollectionChanged;
            if (!Element.MultiLineMode)
            {
                Element.Lines.Clear();
                currentPath.RemoveAllPoints();
            }

            previousPoint = theEvent.LocationInWindow;
            currentPath.MoveTo(previousPoint);
            currentLine = new Line
            {
                Points = new ObservableCollection <Point>
                {
                    new (previousPoint.X, previousPoint.Y)
                }
            };

            UpdateDisplay();
            Element.Lines.CollectionChanged += OnLinesCollectionChanged;
        }
Example #28
0
        public override void MouseDown(NSEvent theEvent)
        {
            Element.Lines.CollectionChanged -= OnLinesCollectionChanged;
            if (!Element.MultiLineMode)
            {
                Element.Lines.Clear();
                currentPath.RemoveAllPoints();
            }

            previousPoint = theEvent.LocationInWindow;
            currentPath.MoveTo(previousPoint);
            currentLine = new Line()
            {
                Points = new ObservableCollection <Point>()
                {
                    new Point(previousPoint.X, previousPoint.Y)
                }
            };

            InvokeOnMainThread(Layer !.SetNeedsDisplay);
            Element.Lines.CollectionChanged += OnLinesCollectionChanged;
        }
Example #29
0
        private NSBezierPath MosconeFloor()
        {
            var path = new NSBezierPath();

            path.MoveTo(new CGPoint(69, 0));
            path.LineTo(new CGPoint(69, -107));
            path.LineTo(new CGPoint(0, -107));
            path.LineTo(new CGPoint(0, -480));
            path.LineTo(new CGPoint(104, -480));
            path.LineTo(new CGPoint(104, -500));
            path.LineTo(new CGPoint(184, -480));
            path.LineTo(new CGPoint(226, -480));
            path.LineTo(new CGPoint(226, -500));
            path.LineTo(new CGPoint(306, -480));
            path.LineTo(new CGPoint(348, -480));
            path.LineTo(new CGPoint(348, -500));
            path.LineTo(new CGPoint(428, -480));
            path.LineTo(new CGPoint(470, -480));
            path.LineTo(new CGPoint(470, -500));
            path.LineTo(new CGPoint(550, -480));
            path.LineTo(new CGPoint(592, -480));
            path.LineTo(new CGPoint(592, -505));
            path.LineTo(new CGPoint(752.548776f, -460.046343f));
            path.CurveTo(new CGPoint(767.32333f, -440.999893f), new CGPoint(760.529967f, -457.811609f), new CGPoint(767.218912f, -449.292876f));
            path.CurveTo(new CGPoint(700, 0), new CGPoint(767.32333f, -440.999893f), new CGPoint(776, -291));
            path.LineTo(new CGPoint(69, 0));

            path.MoveTo(new CGPoint(676, -238));
            path.LineTo(new CGPoint(676, -348));
            path.LineTo(new CGPoint(710, -348));
            path.LineTo(new CGPoint(710, -238));
            path.LineTo(new CGPoint(676, -238));
            path.LineTo(new CGPoint(676, -238));

            return(path);
        }
Example #30
0
        public static NSBezierPath CreateRoundedRectPath(this CGRect rect, CornerRadius cornerRadius)
        {
            var path = new NSBezierPath();

            path.MoveTo(new CGPoint(rect.Width - cornerRadius.TopRight, rect.Y));
            path.AddArc(new CGPoint((float)rect.X + rect.Width - cornerRadius.TopRight, (float)rect.Y + cornerRadius.TopRight), (nfloat)cornerRadius.TopRight, (float)(Math.PI * 1.5), (float)Math.PI * 2, true);
            path.AddLineTo(new CGPoint(rect.Width, rect.Height - cornerRadius.BottomRight));
            path.AddArc(new CGPoint((float)rect.X + rect.Width - cornerRadius.BottomRight, (float)rect.Y + rect.Height - cornerRadius.BottomRight), (nfloat)cornerRadius.BottomRight, 0, (float)(Math.PI * .5), true);
            path.AddLineTo(new CGPoint(cornerRadius.BottomLeft, rect.Height));
            path.AddArc(new CGPoint((float)rect.X + cornerRadius.BottomLeft, (float)rect.Y + rect.Height - cornerRadius.BottomLeft), (nfloat)cornerRadius.BottomLeft, (float)(Math.PI * .5), (float)Math.PI, true);
            path.AddLineTo(new CGPoint(rect.X, cornerRadius.TopLeft));
            path.AddArc(new CGPoint((float)rect.X + cornerRadius.TopLeft, (float)rect.Y + cornerRadius.TopLeft), (nfloat)cornerRadius.TopLeft, (float)Math.PI, (float)(Math.PI * 1.5), true);

            path.ClosePath();

            return(path);
        }
Example #31
0
        public override void DrawRect(RectangleF dirtyRect)
        {
            int radius = 5, arrowHeight = 10, arrowWidth = 20;
            var roundedRectangleRect = new RectangleF(0, 0, this.Bounds.Width, this.Bounds.Height - arrowHeight);
            var path = new NSBezierPath();

            path.AppendPathWithRoundedRect(roundedRectangleRect, radius, radius);

            // Draw the triangle
            path.MoveTo(new PointF((this.Bounds.Width / 2) - (arrowWidth / 2), this.Bounds.Height - arrowHeight));
            path.LineTo(new PointF((this.Bounds.Width / 2), this.Bounds.Height));
            path.LineTo(new PointF((this.Bounds.Width / 2) + (arrowWidth / 2), this.Bounds.Height - arrowHeight));
            path.ClosePath();

            NSColor.Control.SetFill();
            path.Fill();
        }
Example #32
0
        public override void DrawRect(CGRect dirtyRect)
        {
            base.DrawRect(dirtyRect);

            StrokeColor.SetStroke();
            var path = new NSBezierPath();

            path.MoveTo(Start);
            path.LineTo(End);

            path.LineWidth = LineThickness;
            if (LineDash.Length > 0)
            {
                path.SetLineDash(LineDash.Select(w => w * LineThickness).ToArray(), 0);
            }
            path.Stroke();
        }
Example #33
0
        public override void DrawRect(CoreGraphics.CGRect dirtyRect)
        {
            var rect = this.Bounds;
            var x1   = rect.Left;
            var y1   = rect.Top;
            var x2   = rect.Right;
            var y2   = rect.Bottom;

            NSBezierPath path = new NSBezierPath();

            path.MoveTo(new CoreGraphics.CGPoint(x1, y1));
            path.CurveTo(new CoreGraphics.CGPoint(x2, y1),
                         new CoreGraphics.CGPoint(x1, y2),
                         new CoreGraphics.CGPoint(x2, y2));
            path.LineWidth = 5;
            NSColor.Red.SetStroke();
            path.Stroke();
        }
		private NSBezierPath TextChamferProfile ()
		{
			var profile = new NSBezierPath ();
			profile.MoveTo (new CGPoint (0, 1));
			profile.LineTo (new CGPoint (1.5f, 1));
			profile.LineTo (new CGPoint (1.5f, 0));
			profile.LineTo (new CGPoint (1, 0));
			return profile;
		}
Example #35
0
		public static NSBezierPath SCArrowBezierPath (CGSize baseSize, CGSize tipSize, nfloat hollow, bool twoSides)
		{
			var arrow = new NSBezierPath ();

			var h = new nfloat[5];
			var w = new nfloat[4];

			w [0] = 0;
			w [1] = baseSize.Width - tipSize.Width - hollow;
			w [2] = baseSize.Width - tipSize.Width;
			w [3] = baseSize.Width;

			h [0] = 0;
			h [1] = (tipSize.Height - baseSize.Height) * 0.5f;
			h [2] = (tipSize.Height) * 0.5f;
			h [3] = (tipSize.Height + baseSize.Height) * 0.5f;
			h [4] = tipSize.Height;

			if (twoSides) {
				arrow.MoveTo (new CGPoint (tipSize.Width, h [1]));
				arrow.LineTo (new CGPoint (tipSize.Width + hollow, h [0]));
				arrow.LineTo (new CGPoint (0, h [2]));
				arrow.LineTo (new CGPoint (tipSize.Width + hollow, h [4]));
				arrow.LineTo (new CGPoint (tipSize.Width, h [3]));
			} else {
				arrow.MoveTo (new CGPoint (0, h [1]));
				arrow.LineTo (new CGPoint (0, h [3]));
			}

			arrow.LineTo (new CGPoint (w [2], h [3]));
			arrow.LineTo (new CGPoint (w [1], h [4]));
			arrow.LineTo (new CGPoint (w [3], h [2]));
			arrow.LineTo (new CGPoint (w [1], h [0]));
			arrow.LineTo (new CGPoint (w [2], h [1]));

			arrow.ClosePath ();

			return arrow;
		}
		private NSBezierPath MosconeRooms ()
		{
			var path = new NSBezierPath ();

			path.MoveTo (new CGPoint (553, -387));
			path.LineTo (new CGPoint (426, -387));
			path.LineTo (new CGPoint (426, -383));
			path.LineTo (new CGPoint (549, -383));
			path.LineTo (new CGPoint (549, -194));
			path.LineTo (new CGPoint (357, -194));
			path.LineTo (new CGPoint (357, -383));
			path.LineTo (new CGPoint (411, -383));
			path.LineTo (new CGPoint (411, -387));
			path.LineTo (new CGPoint (255, -387));
			path.LineTo (new CGPoint (255, -383));
			path.LineTo (new CGPoint (353, -383));
			path.LineTo (new CGPoint (353, -194));
			path.LineTo (new CGPoint (175, -194));
			path.LineTo (new CGPoint (175, -383));
			path.LineTo (new CGPoint (240, -383));
			path.LineTo (new CGPoint (240, -387));
			path.LineTo (new CGPoint (171, -387));
			path.LineTo (new CGPoint (171, -190));
			path.LineTo (new CGPoint (553, -190));
			path.LineTo (new CGPoint (553, -387));

			path.MoveTo (new CGPoint (474, -141));
			path.LineTo (new CGPoint (474, -14));
			path.LineTo (new CGPoint (294, -14));
			path.LineTo (new CGPoint (294, -141));
			path.LineTo (new CGPoint (407, -141));
			path.LineTo (new CGPoint (407, -145));
			path.LineTo (new CGPoint (172, -145));
			path.LineTo (new CGPoint (172, -141));
			path.LineTo (new CGPoint (290, -141));
			path.LineTo (new CGPoint (290, -14));
			path.LineTo (new CGPoint (124, -14));
			path.LineTo (new CGPoint (124, -141));
			path.LineTo (new CGPoint (157, -141));
			path.LineTo (new CGPoint (157, -145));
			path.LineTo (new CGPoint (120, -145));
			path.LineTo (new CGPoint (120, -10));
			path.LineTo (new CGPoint (478, -10));
			path.LineTo (new CGPoint (478, -145));
			path.LineTo (new CGPoint (422, -145));
			path.LineTo (new CGPoint (422, -141));
			path.LineTo (new CGPoint (474, -141));

			return path;
		}
		private NSBezierPath OutlineChamferProfilePath ()
		{
			var path = new NSBezierPath ();
			path.MoveTo (new CGPoint (1, 1));
			path.LineTo (new CGPoint (1, 0));
			return path;
		}
		private NSBezierPath MosconeFloor ()
		{
			var path = new NSBezierPath ();

			path.MoveTo (new CGPoint (69, 0));
			path.LineTo (new CGPoint (69, -107));
			path.LineTo (new CGPoint (0, -107));
			path.LineTo (new CGPoint (0, -480));
			path.LineTo (new CGPoint (104, -480));
			path.LineTo (new CGPoint (104, -500));
			path.LineTo (new CGPoint (184, -480));
			path.LineTo (new CGPoint (226, -480));
			path.LineTo (new CGPoint (226, -500));
			path.LineTo (new CGPoint (306, -480));
			path.LineTo (new CGPoint (348, -480));
			path.LineTo (new CGPoint (348, -500));
			path.LineTo (new CGPoint (428, -480));
			path.LineTo (new CGPoint (470, -480));
			path.LineTo (new CGPoint (470, -500));
			path.LineTo (new CGPoint (550, -480));
			path.LineTo (new CGPoint (592, -480));
			path.LineTo (new CGPoint (592, -505));
			path.LineTo (new CGPoint (752.548776f, -460.046343f));
			path.CurveTo (new CGPoint (767.32333f, -440.999893f), new CGPoint (760.529967f, -457.811609f), new CGPoint (767.218912f, -449.292876f));
			path.CurveTo (new CGPoint (700, 0), new CGPoint (767.32333f, -440.999893f), new CGPoint (776, -291));
			path.LineTo (new CGPoint (69, 0));

			path.MoveTo (new CGPoint (676, -238));
			path.LineTo (new CGPoint (676, -348));
			path.LineTo (new CGPoint (710, -348));
			path.LineTo (new CGPoint (710, -238));
			path.LineTo (new CGPoint (676, -238));
			path.LineTo (new CGPoint (676, -238));

			return path;
		}
		private NSBezierPath StarPath (float innerRadius, float outerRadius)
		{
			var raysCount = 5;
			var delta = 2.0f * NMath.PI / raysCount;

			var path = new NSBezierPath ();

			for (var i = 0; i < raysCount; ++i) {
				var alpha = i * delta + NMath.PI / 2;

				if (i == 0)
					path.MoveTo (new CGPoint (outerRadius * NMath.Cos (alpha), outerRadius * NMath.Sin (alpha)));
				else
					path.LineTo (new CGPoint (outerRadius * NMath.Cos (alpha), outerRadius * NMath.Sin (alpha)));

				alpha += 0.5f * delta;
				path.LineTo (new CGPoint (innerRadius * NMath.Cos (alpha), innerRadius * NMath.Sin (alpha)));
			}

			return path;
		}