예제 #1
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 ()));
		}
예제 #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 ();
				
			}
	
		}
예제 #3
0
        public override void AwakeFromNib()
        {
            base.AwakeFromNib();

            mPath = new NSBezierPath();
            mPath.LineWidth = 3.0f;
        }
예제 #4
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);
				}
			}
예제 #5
0
		public UIBezierPath (NSBezierPath path) : base()
		{
			// Initialize
			this.path = path;
		}
예제 #6
0
        public override void AwakeFromNib()
        {
            base.AwakeFromNib();
            this.SetValueForKey(new NSNumber(1.0f), new NSString("Opacity"));

            mPath = new NSBezierPath();
            mPath.LineWidth = 3.0f;
            //			CreateRandomPath();
            //			CreateRandomOvals();
            CreateRandomCurves();
            Image = new StretchImage("LittleBeach.jpg");
        }
		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;
		}
 public override void DrawRect(System.Drawing.RectangleF dirtyRect)
 {
     NSColor.WindowBackground.Set();
     NSBezierPath.FillRect(dirtyRect);
 }
예제 #9
0
        public static SCNNode SCBoxNode(string title, CGRect frame, NSColor color, float cornerRadius, bool centered)
        {
            NSMutableDictionary titleAttributes         = null;
            NSMutableDictionary centeredTitleAttributes = null;

            // create and extrude a bezier path to build the box
            var path = NSBezierPath.FromRoundedRect(frame, cornerRadius, cornerRadius);

            path.Flatness = 0.05f;

            var shape = SCNShape.Create(path, 20);

            shape.ChamferRadius = 0.0f;

            var node = SCNNode.Create();

            node.Geometry = shape;

            // create an image and fill with the color and text
            var textureSize = new CGSize();

            textureSize.Width  = NMath.Ceiling(frame.Size.Width * 1.5f);
            textureSize.Height = NMath.Ceiling(frame.Size.Height * 1.5f);

            var texture = new NSImage(textureSize);

            texture.LockFocus();

            var drawFrame = new CGRect(0, 0, textureSize.Width, textureSize.Height);

            nfloat hue, saturation, brightness, alpha;

            (color.UsingColorSpace(NSColorSpace.DeviceRGBColorSpace)).GetHsba(out hue, out saturation, out brightness, out alpha);
            var lightColor = NSColor.FromDeviceHsba(hue, saturation - 0.2f, brightness + 0.3f, alpha);

            lightColor.Set();

            NSGraphics.RectFill(drawFrame);

            NSBezierPath fillpath = null;

            if (cornerRadius == 0 && centered == false)
            {
                //special case for the "labs" slide
                drawFrame.Offset(0, -2);
                fillpath = NSBezierPath.FromRoundedRect(drawFrame, cornerRadius, cornerRadius);
            }
            else
            {
                drawFrame.Inflate(-3, -3);
                fillpath = NSBezierPath.FromRoundedRect(drawFrame, cornerRadius, cornerRadius);
            }

            color.Set();
            fillpath.Fill();

            // draw the title if any
            if (title != null)
            {
                if (titleAttributes == null)
                {
                    var paraphStyle = new NSMutableParagraphStyle();
                    paraphStyle.LineBreakMode     = NSLineBreakMode.ByWordWrapping;
                    paraphStyle.Alignment         = NSTextAlignment.Center;
                    paraphStyle.MinimumLineHeight = 38;
                    paraphStyle.MaximumLineHeight = 38;

                    var font = NSFont.FromFontName("Myriad Set Semibold", 34) != null?NSFont.FromFontName("Myriad Set Semibold", 34) : NSFont.FromFontName("Avenir Medium", 34);

                    var shadow = new NSShadow();
                    shadow.ShadowOffset     = new CGSize(0, -2);
                    shadow.ShadowBlurRadius = 4;
                    shadow.ShadowColor      = NSColor.FromDeviceWhite(0.0f, 0.5f);

                    titleAttributes = new NSMutableDictionary();
                    titleAttributes.SetValueForKey(font, NSAttributedString.FontAttributeName);
                    titleAttributes.SetValueForKey(NSColor.White, NSAttributedString.ForegroundColorAttributeName);
                    titleAttributes.SetValueForKey(shadow, NSAttributedString.ShadowAttributeName);
                    titleAttributes.SetValueForKey(paraphStyle, NSAttributedString.ParagraphStyleAttributeName);

                    var centeredParaphStyle = (NSMutableParagraphStyle)paraphStyle.MutableCopy();
                    centeredParaphStyle.Alignment = NSTextAlignment.Center;

                    centeredTitleAttributes = new NSMutableDictionary();
                    centeredTitleAttributes.SetValueForKey(font, NSAttributedString.FontAttributeName);
                    centeredTitleAttributes.SetValueForKey(NSColor.White, NSAttributedString.ForegroundColorAttributeName);
                    centeredTitleAttributes.SetValueForKey(shadow, NSAttributedString.ShadowAttributeName);
                    centeredTitleAttributes.SetValueForKey(paraphStyle, NSAttributedString.ParagraphStyleAttributeName);
                }

                var attrString = new NSAttributedString(title, centered ? centeredTitleAttributes : titleAttributes);
                var textSize   = attrString.Size;

                //check if we need two lines to draw the text
                var twoLines = title.Contains("\n");
                if (!twoLines)
                {
                    twoLines = textSize.Width > frame.Size.Width && title.Contains(" ");
                }

                //if so, we need to adjust the size to center vertically
                if (twoLines)
                {
                    textSize.Height += 38;
                }

                if (!centered)
                {
                    drawFrame.Inflate(-15, 0);
                }

                //center vertically
                var dy = (drawFrame.Size.Height - textSize.Height) * 0.5f;
                var drawFrameHeight = drawFrame.Size.Height;
                drawFrame.Size = new CGSize(drawFrame.Size.Width, drawFrame.Size.Height - dy);
                attrString.DrawString(drawFrame);
            }

            texture.UnlockFocus();

            //set the created image as the diffuse texture of our 3D box
            var front = SCNMaterial.Create();

            front.Diffuse.Contents        = texture;
            front.LocksAmbientWithDiffuse = true;

            //use a lighter color for the chamfer and sides
            var sides = SCNMaterial.Create();

            sides.Diffuse.Contents  = lightColor;
            node.Geometry.Materials = new SCNMaterial[] {
                front,
                sides,
                sides,
                sides,
                sides
            };

            return(node);
        }
예제 #10
0
            public override void DrawWithFrame(CGRect cellFrame, NSView inView)
            {
                if (IdeApp.Preferences.UserInterfaceTheme == Theme.Dark)
                {
#pragma warning disable EPS06 // Hidden struct copy operation
                    var inset = cellFrame.Inset(0.25f, 0.25f);
#pragma warning restore EPS06 // Hidden struct copy operation
                    if (!ShowsFirstResponder)
                    {
                        var path = NSBezierPath.FromRoundedRect(inset, 3, 3);
                        path.LineWidth = 0.5f;

                        // Hack to make the border be the correct colour in fullscreen mode
                        // See comment in AwesomeBar.cs for more details
                        if (MainToolbar.IsFullscreen)
                        {
                            Styles.DarkBorderBrokenColor.ToNSColor().SetStroke();
                        }
                        else
                        {
                            Styles.DarkBorderColor.ToNSColor().SetStroke();
                        }
                        path.Stroke();
                    }

                    // Can't just call base.DrawInteriorWithFrame because it draws the placeholder text
                    // with a strange emboss effect when it the view is not first responder.
                    // Again, probably because the NSSearchField handles the not first responder state itself
                    // rather than using NSSearchFieldCell
                    //base.DrawInteriorWithFrame (inset, inView);

                    // So instead, draw the various extra cells and text in the correct places
                    SearchButtonCell.DrawWithFrame(SearchButtonRectForBounds(inset), inView);

                    if (!ShowsFirstResponder)
                    {
                        PlaceholderAttributedString.DrawInRect(SearchTextRectForBounds(inset));
                    }

                    if (!string.IsNullOrEmpty(StringValue))
                    {
                        CancelButtonCell.DrawWithFrame(CancelButtonRectForBounds(inset), inView);
                    }
                }
                else
                {
                    if (inView.Window?.Screen?.BackingScaleFactor == 2)
                    {
                        nfloat yOffset = 0f;
                        nfloat hOffset = 0f;

                        if (MacSystemInformation.OsVersion >= MacSystemInformation.ElCapitan)
                        {
                            if (inView.Window.IsKeyWindow)
                            {
                                yOffset = 0.5f;
                                hOffset = -0.5f;
                            }
                            else
                            {
                                yOffset = 0f;
                                hOffset = 1.0f;
                            }
                        }
                        else
                        {
                            yOffset = 1f;
                            hOffset = -1f;
                        }
                        cellFrame = new CGRect(cellFrame.X, cellFrame.Y + yOffset, cellFrame.Width, cellFrame.Height + hOffset);
                    }
                    else
                    {
                        nfloat yOffset = 0f;
                        nfloat hOffset = 0f;

                        cellFrame = new CGRect(cellFrame.X, cellFrame.Y + yOffset, cellFrame.Width, cellFrame.Height + hOffset);
                    }
                    base.DrawWithFrame(cellFrame, inView);
                }
            }
예제 #11
0
 public override void DrawFocusRingMask() => NSBezierPath.FillRect(FocusRingMaskBounds);
예제 #12
0
 public override void DrawRect(CGRect dirtyRect)
 {
     NSColor.FromRgb(245, 245, 245).Set();
     NSBezierPath.FillRect(new CGRect(0, 0, dirtyRect.Width, 50));
 }
예제 #13
0
 public static CGPath ToCGPath(this NSBezierPath path)
 {
     return(ToCGPath(path, true));
 }
예제 #14
0
        public static void DrawUISwitch(CGRect dirtyRect, bool isEnabled, bool isSwitchOn,
                                        int BorderWidth,
                                        NSColor SwitchOnBackgroundColor,
                                        NSColor SwitchOffBackgroundColor,
                                        NSColor SwitchOffBorderColor,
                                        NSColor InternalSwitcherColor,
                                        NSColor InternalSwitcherShadowColor
                                        )
        {
            NSGraphicsContext context = NSGraphicsContext.CurrentContext;

            context.CGContext.SaveState();


            NSColor switchOnBackgroundColor     = SwitchOnBackgroundColor;
            NSColor switchOffBackgroundColor    = SwitchOffBackgroundColor;
            NSColor switchOffBorderColor        = SwitchOffBorderColor;
            NSColor internalSwitcherColor       = InternalSwitcherColor;
            NSColor internalSwitcherShadowColor = InternalSwitcherShadowColor;

            if (isEnabled == false)
            {
                // if disabled - set background color darker
                switchOnBackgroundColor     = SetColorDarker(switchOnBackgroundColor);
                switchOffBackgroundColor    = SetColorDarker(switchOffBackgroundColor);
                switchOffBorderColor        = SetColorDarker(switchOffBorderColor);
                internalSwitcherColor       = SetColorDarker(internalSwitcherColor);
                internalSwitcherShadowColor = SetColorDarker(internalSwitcherShadowColor);
            }

            nfloat offset = dirtyRect.Height * 0.1f;

            dirtyRect = new CGRect(dirtyRect.X + offset,
                                   dirtyRect.Y + offset,
                                   dirtyRect.Width - offset * 2,
                                   dirtyRect.Height - offset * 2);

            // set backgrund color
            NSColor bodyColor = (isSwitchOn)? switchOnBackgroundColor : switchOffBackgroundColor;

            bodyColor.SetFill();

            // draw background
            NSBezierPath bodyPath = NSBezierPath.FromRoundedRect(dirtyRect, dirtyRect.Height / 2, dirtyRect.Height / 2);

            bodyPath.Fill();

            // draw border
            if (!isSwitchOn)
            {
                bodyPath.AddClip();
                bodyPath.LineWidth = BorderWidth;

                if (switchOffBorderColor != null)
                {
                    switchOffBorderColor.SetStroke();
                }
                bodyPath.Stroke();
            }

            //restore \ save context status
            context.CGContext.RestoreState();
            context.CGContext.SaveState();

            // DRAW CIRCLE
            CGRect circleRect;

            if (!isSwitchOn)
            {
                circleRect = new CGRect(dirtyRect.X,
                                        dirtyRect.Y,
                                        dirtyRect.Height,
                                        dirtyRect.Height);
            }
            else
            {
                circleRect = new CGRect((dirtyRect.Width - dirtyRect.Height + dirtyRect.X),
                                        dirtyRect.Y,
                                        dirtyRect.Height,
                                        dirtyRect.Height);
            }

            // draw circle with shadow (no shadow for dark mode)
            if (!Colors.IsDarkMode)
            {
                CGRect circleShadowRect = new CGRect(circleRect.X + offset / 3, circleRect.Y + offset / 3, circleRect.Height - 2 * offset / 3, circleRect.Height - 2 * offset / 3);

                NSBezierPath circleShadowPath = NSBezierPath.FromRoundedRect(circleShadowRect, circleShadowRect.Height / 2, circleShadowRect.Height / 2);
                context.CGContext.SetShadow(new CGSize(offset / 3, -offset),
                                            offset * 1f,
                                            new CGColor(internalSwitcherShadowColor.RedComponent,
                                                        internalSwitcherShadowColor.GreenComponent,
                                                        internalSwitcherShadowColor.BlueComponent));
                circleShadowPath.Fill();
            }

            // restore context state
            context.CGContext.RestoreState();

            // set circle color
            NSColor circleColor = internalSwitcherColor;

            circleColor.SetFill();

            // draw circle without shadow to fill internal area filled by shadow
            NSBezierPath circlePath = NSBezierPath.FromRoundedRect(circleRect, circleRect.Height / 2, circleRect.Height / 2);

            circlePath.Fill();

            // circle border
            circlePath.AddClip();
            circlePath.LineWidth = 1;

            if (Colors.IsDarkMode)
            {
                // no border for Dark mode
                internalSwitcherColor.SetStroke();
            }
            else
            {
                if (switchOffBorderColor != null)
                {
                    switchOffBorderColor.SetStroke();
                }
            }
            circlePath.Stroke();
        }
 /// <summary>
 /// Add Line to path
 /// </summary>
 /// <param name="path">NS Bezier path</param>
 /// <param name="x">Target point X</param>
 /// <param name="y">Target point Y</param>
 public static void LineTo(this NSBezierPath path, double x, double y) => path.LineTo(new CGPoint(x, y));
예제 #16
0
 public override void DrawSelection(CoreGraphics.CGRect dirtyRect)
 {
     NSColor.FromRgb(225, 225, 225).Set();
     NSBezierPath.FillRect(dirtyRect);
 }
예제 #17
0
        public static NSImage ToCropped(NSImage source, double zoomFactor, double xOffset, double yOffset, double cropWidthRatio, double cropHeightRatio)
        {
            double sourceWidth  = source.CGImage.Width;
            double sourceHeight = source.CGImage.Height;

            double desiredWidth  = sourceWidth;
            double desiredHeight = sourceHeight;

            double desiredRatio = cropWidthRatio / cropHeightRatio;
            double currentRatio = sourceWidth / sourceHeight;

            if (currentRatio > desiredRatio)
            {
                desiredWidth = (cropWidthRatio * sourceHeight / cropHeightRatio);
            }
            else if (currentRatio < desiredRatio)
            {
                desiredHeight = (cropHeightRatio * sourceWidth / cropWidthRatio);
            }

            xOffset = xOffset * desiredWidth;
            yOffset = yOffset * desiredHeight;

            desiredWidth  = desiredWidth / zoomFactor;
            desiredHeight = desiredHeight / zoomFactor;

            float cropX = (float)(((sourceWidth - desiredWidth) / 2) + xOffset);
            float cropY = (float)(((sourceHeight - desiredHeight) / 2) + yOffset);

            if (cropX < 0)
            {
                cropX = 0;
            }

            if (cropY < 0)
            {
                cropY = 0;
            }

            if (cropX + desiredWidth > sourceWidth)
            {
                cropX = (float)(sourceWidth - desiredWidth);
            }

            if (cropY + desiredHeight > sourceHeight)
            {
                cropY = (float)(sourceHeight - desiredHeight);
            }


            var       colorSpace       = CGColorSpace.CreateDeviceRGB();
            const int bytesPerPixel    = 4;
            int       width            = (int)desiredWidth;
            int       height           = (int)desiredHeight;
            var       bytes            = new byte[width * height * bytesPerPixel];
            int       bytesPerRow      = bytesPerPixel * width;
            const int bitsPerComponent = 8;

            using (var context = new CGBitmapContext(bytes, width, height, bitsPerComponent, bytesPerRow, colorSpace, CGBitmapFlags.PremultipliedLast | CGBitmapFlags.ByteOrder32Big))
            {
                var clippedRect = new CGRect(0, 0, desiredWidth, desiredHeight);
                context.BeginPath();

                using (var path = NSBezierPath.FromRect(clippedRect))
                {
                    context.AddPath(path.ToCGPath());
                    context.Clip();
                }

                var drawRect = new CGRect(-cropX, -cropY, sourceWidth, sourceHeight);
                context.DrawImage(drawRect, source.CGImage);

                using (var output = context.ToImage())
                {
                    return(new NSImage(output, CGSize.Empty));
                }
            }
        }
예제 #18
0
        public override void DrawRect(System.Drawing.RectangleF dirtyRect)
        {
            var context = NSGraphicsContext.CurrentContext.GraphicsPort;

            // Engine.Instance.Stats.Charts.Hit (RandomGenerator.GetInt (1024, 1024 * 1024), RandomGenerator.GetInt (1024, 1024 * 1024)); // Debugging

            context.SetFillColor(m_colorBackground.CGColor);
            context.FillRect(dirtyRect);

            NSColor.Gray.Set();
            NSBezierPath.StrokeRect(Bounds);


            float DX = this.Bounds.Size.Width;
            float DY = this.Bounds.Size.Height;


            m_chartDX     = DX;
            m_chartDY     = DY - m_legendDY;
            m_chartStartX = 0;
            m_chartStartY = m_chartDY;


            float maxY = m_chart.GetMax();

            if (maxY <= 0)
            {
                maxY = 4096;
            }
            else if (maxY > 1000000000000)
            {
                maxY = 1000000000000;
            }

            Point lastPointDown = new Point(-1, -1);
            Point lastPointUp   = new Point(-1, -1);

            float stepX = (m_chartDX - 0) / m_chart.Resolution;

            // Grid lines
            for (int g = 0; g < m_chart.Grid; g++)
            {
                float x = ((m_chartDX - 0) / m_chart.Grid) * g;
                DrawLine(m_colorGrid, m_chartStartX + x, 0, m_chartStartX + x, m_chartStartY);
            }

            // Axis line
            DrawLine(m_colorAxis, 0, m_chartStartY, m_chartDX, m_chartStartY);

            // Legend

            /*
             * {
             *      string legend = "";
             *      legend += Messages.ChartRange + ": " + Utils.FormatSeconds(m_chart.Resolution * m_chart.TimeStep);
             *      legend += "   ";
             *      legend += Messages.ChartGrid + ": " + Utils.FormatSeconds(m_chart.Resolution / m_chart.Grid * m_chart.TimeStep);
             *      legend += "   ";
             *      legend += Messages.ChartStep + ": " + Utils.FormatSeconds(m_chart.TimeStep);
             *
             *      Point mp = Cursor.Position;
             *      mp = PointToClient(mp);
             *      if ((mp.X > 0) && (mp.Y < chartDX) && (mp.Y > chartDY) && (mp.Y < DY))
             *              legend += " - " + Messages.ChartClickToChangeResolution;
             *
             *      e.Graphics.DrawString(legend, FontLabel, BrushLegendText, ChartRectangle(0, chartStartY, chartDX, m_legendDY), formatTopCenter);
             * }
             */


            // Graph
            for (int i = 0; i < m_chart.Resolution; i++)
            {
                int p = i + m_chart.Pos + 1;
                if (p >= m_chart.Resolution)
                {
                    p -= m_chart.Resolution;
                }

                float downY = ((m_chart.Download[p]) * (m_chartDY - m_marginTopY)) / maxY;
                float upY   = ((m_chart.Upload[p]) * (m_chartDY - m_marginTopY)) / maxY;

                Point pointDown = ChartPoint(m_chartStartX + stepX * i, m_chartStartY - downY);
                Point pointUp   = ChartPoint(m_chartStartX + stepX * i, m_chartStartY - upY);

                //e.Graphics.DrawLine(Pens.Green, new Point(0,0), point);

                if (lastPointDown.X != -1)
                {
                    DrawLine(m_colorDownloadGraph, lastPointDown, pointDown);
                    DrawLine(m_colorUploadGraph, lastPointUp, pointUp);
                }

                lastPointDown = pointDown;
                lastPointUp   = pointUp;
            }

            // Download line
            float downCurY = 0;
            {
                long v = m_chart.GetLastDownload();
                downCurY = ((v) * (m_chartDY - m_marginTopY)) / maxY;
                DrawLine(m_colorDownloadLine, 0, m_chartStartY - downCurY, m_chartDX, m_chartStartY - downCurY);
                DrawStringOutline(Messages.ChartDownload + ": " + ValToDesc(v), m_colorDownloadText, ChartRectangle(0, 0, m_chartDX - 10, m_chartStartY - downCurY), 8);
            }

            // Upload line
            {
                long  v   = m_chart.GetLastUpload();
                float y   = ((v) * (m_chartDY - m_marginTopY)) / maxY;
                float dly = 0;
                if (Math.Abs(downCurY - y) < 10)
                {
                    dly = 15;                                              // Download and upload overwrap, distance it.
                }
                DrawLine(m_colorUploadLine, 0, m_chartStartY - y, m_chartDX, m_chartStartY - y);
                DrawStringOutline(Messages.ChartUpload + ": " + ValToDesc(v), m_colorUploadText, ChartRectangle(0, 0, m_chartDX - 10, m_chartStartY - y - dly), 8);
            }

            // Mouse lines
            {
                PointF mp = Window.MouseLocationOutsideOfEventStream;
                mp.X -= this.Frame.Left;
                mp.Y -= this.Frame.Top;
                //mp = ParentWindow.ConvertPointToView (mp, this);

                mp = Invert(mp);

                //mp = Window.ConvertScreenToBase (mp);

                if ((mp.X > 0) && (mp.Y < m_chartDX) && (mp.Y > 0) && (mp.Y < m_chartDY))
                {
                    DrawLine(m_colorMouse, 0, mp.Y, m_chartDX, mp.Y);
                    DrawLine(m_colorMouse, mp.X, 0, mp.X, m_chartDY);

                    float i = (m_chartDX - (mp.X - m_chartStartX)) / stepX;

                    int t = Conversions.ToInt32(i * m_chart.TimeStep);

                    //float y = mp.Y * maxY / (chartDY - m_marginTopY);
                    float y = (m_chartStartY - (mp.Y - m_marginTopY)) * maxY / m_chartDY;

                    String label = ValToDesc(Conversions.ToInt64(y)) + ", " + Utils.FormatSeconds(t) + " ago";

                    int        formatAlign = 6;
                    RectangleF rect        = new RectangleF();
                    if (DX - mp.X > DX / 2)
                    //if (mp.X < DX - 200)
                    {
                        if (DY - mp.Y > DY / 2)
                        //if (mp.Y < 20)
                        {
                            formatAlign = 0;
                            rect.X      = mp.X + 5;
                            rect.Y      = mp.Y + 5;
                            rect.Width  = DX;
                            rect.Height = DX;
                        }
                        else
                        {
                            formatAlign = 6;
                            rect.X      = mp.X + 5;
                            rect.Y      = 0;
                            rect.Width  = DX;
                            rect.Height = mp.Y - 5;
                        }
                    }
                    else
                    {
                        if (DY - mp.Y > DY / 2)
                        //if (mp.Y < 40)
                        {
                            formatAlign = 2;
                            rect.X      = 0;
                            rect.Y      = mp.Y;
                            rect.Width  = mp.X - 5;
                            rect.Height = DY;
                        }
                        else
                        {
                            formatAlign = 8;
                            rect.X      = 0;
                            rect.Y      = 0;
                            rect.Width  = mp.X - 5;
                            rect.Height = mp.Y - 5;
                        }
                    }

                    DrawStringOutline(label, m_colorMouse, rect, formatAlign);
                }
            }
        }
예제 #19
0
        public override void DrawRect(CGRect dirtyRect)
        {
            if (Gradient != null)
            {
                Gradient.DrawInRect(dirtyRect, GradientAngle);
            }

            // -----------------------------------------
            nfloat textOffset   = 0f;
            nfloat imageXOffset = 0f;
            nfloat imageWidth   = 0f;

            if (Image != null)
            {
                if (Image.Size.Height > dirtyRect.Height)
                {
                    Image.Size = new CGSize(Image.Size.Height, dirtyRect.Height);
                }
                if (Image.Size.Width > dirtyRect.Width)
                {
                    Image.Size = new CGSize(dirtyRect.Width, Image.Size.Width);
                }

                imageWidth = Image.Size.Width;

                nfloat minXOffset = (dirtyRect.Height - Image.Size.Height) / 2f;

                imageXOffset = CornerRadius;
                if (imageXOffset < minXOffset)
                {
                    imageXOffset = minXOffset;
                }

                if (AttributedTitle == null)
                {
                    imageXOffset = dirtyRect.Width / 2f - Image.Size.Width / 2f;
                }
                else if (IconLocation == IconLocationEnum.Right_BeforeCenteredText)
                {
                    imageXOffset = dirtyRect.Width / 2f - AttributedTitle.Size.Width / 2f - Image.Size.Width - minXOffset / 2f;
                }
                else if (IconLocation == IconLocationEnum.Left_AfterCenteredText)
                {
                    imageXOffset = dirtyRect.Width / 2f + AttributedTitle.Size.Width / 2f + minXOffset / 2f;
                }
                else if (IconLocation == IconLocationEnum.Right_AfterCenteredText)
                {
                    imageXOffset = dirtyRect.Width - minXOffset / 2f - Image.Size.Width;
                }
                else if (IconLocation == IconLocationEnum.Right)
                {
                    nfloat space = (dirtyRect.Width - AttributedTitle.Size.Width - Image.Size.Width) / 3;
                    textOffset   = space;
                    imageXOffset = space + AttributedTitle.Size.Width + space;
                }
                else if (IconLocation == IconLocationEnum.Left)
                {
                    nfloat space = (dirtyRect.Width - AttributedTitle.Size.Width - Image.Size.Width) / 3;
                    imageXOffset = space;
                    textOffset   = space + Image.Size.Width + space;
                }

                CGRect imgRect = new CGRect(dirtyRect.X + imageXOffset,
                                            dirtyRect.Y + dirtyRect.Height / 2f - Image.Size.Height / 2f,
                                            Image.Size.Width,
                                            Image.Size.Height);
                Image.Draw(imgRect);
            }

            if (AttributedTitle != null)
            {
                if (IconLocation == IconLocationEnum.Right_BeforeCenteredText || IconLocation == IconLocationEnum.Left_BeforeCenteredText)
                {
                    if ((imageXOffset + imageWidth) > (dirtyRect.Width - AttributedTitle.Size.Width) / 2f)
                    {
                        textOffset = imageXOffset + imageWidth;
                    }
                }

                CGRect titleRect = new CGRect(dirtyRect.X + textOffset,
                                              dirtyRect.Y + dirtyRect.Height / 2f - AttributedTitle.Size.Height / 2f - 1f,
                                              dirtyRect.Width - textOffset,
                                              AttributedTitle.Size.Height);

                this.AttributedTitle.DrawInRect(titleRect);
            }

            if (Highlighted)
            {
                NSColor fillColor = HighlitedColorOverlay;
                if (fillColor == null)
                {
                    fillColor = NSColor.FromRgba(0, 0, 0, 0.1f);
                }
                fillColor.Set();

                NSBezierPath highlitedFill = new NSBezierPath();
                highlitedFill.AppendPathWithRoundedRect(dirtyRect, CornerRadius, CornerRadius);
                highlitedFill.Fill();
            }

            if (!this.Enabled && DoNotChangeColorWhenDisabled != true)
            {
                NSColor fillColor = HighlitedColorOverlay;
                if (fillColor == null)
                {
                    fillColor = NSColor.FromRgba(0, 0, 0, 0.1f);
                }
                fillColor.Set();

                NSBezierPath highlitedFill = new NSBezierPath();
                highlitedFill.AppendPathWithRoundedRect(dirtyRect, CornerRadius, CornerRadius);
                highlitedFill.Fill();
            }
            // -----------------------------------------
            //base.DrawRect (dirtyRect);

            if (!Highlighted && BorderShadow != null)
            {
                BorderShadow.Set();
            }


            NSBezierPath bounds = new NSBezierPath();

            bounds.AppendPathWithRoundedRect(dirtyRect, CornerRadius, CornerRadius);
            bounds.AddClip();

            bounds.LineWidth = BorderLineWidth;

            if (BorderColor != null)
            {
                BorderColor.SetStroke();
            }

            bounds.Stroke();
        }
		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;
		}
예제 #21
0
        public override void DrawRect(CGRect dirtyRect)
        {
            var path = new NSBezierPath ();

            path.AppendPathWithRect (dirtyRect);
            NSColor.Clear.SetFill ();
            path.Fill ();

            path.AppendPathWithRect (highlightRect);
            NSColor.Red.SetStroke ();
            path.Stroke ();
        }
예제 #22
0
 public override void DrawSelection(CGRect dirtyRect)
 {
     selectedBkColor.SetFill();
     NSBezierPath.FillRect(dirtyRect);
     DrawFocusedMessage();
 }
		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;
		}
예제 #24
0
 private void DrawLine(CGContext context, CGColor color, CGPoint p1, CGPoint p2)
 {
     context.SetStrokeColor(color);
     //color.Set();
     NSBezierPath.StrokeLine(Invert(p1), Invert(p2));
 }
예제 #25
0
 public override void DrawRect(CoreGraphics.CGRect dirtyRect)
 {
     NSColor.WindowBackground.Set();
     NSBezierPath.FillRect(dirtyRect);
 }
예제 #26
0
		NSBezierPath CreatePathForOval (CGRect bounds)
		{
			CGRect rect = new CGRect (bounds.X + Offset, bounds.Y + Offset, bounds.Width - (2 * Offset), bounds.Height - (2 * Offset));
			rect.X += StrokeWidth / 2;
			rect.Y += StrokeWidth / 2;
			rect.Size = new CGSize (rect.Size.Width - StrokeWidth / 2, rect.Size.Height - StrokeWidth / 2);
			NSBezierPath path = new NSBezierPath ();
			path.AppendPathWithOvalInRect (rect);
			path.LineWidth = StrokeWidth;
			return path;
		}
예제 #27
0
 public UIBezierPath() : base()
 {
     // Initialize
     this.path = new NSBezierPath();
 }
		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;
		}
예제 #29
0
 public UIBezierPath(NSBezierPath path) : base()
 {
     // Initialize
     this.path = path;
 }
		private NSBezierPath OutlineChamferProfilePath ()
		{
			var path = new NSBezierPath ();
			path.MoveTo (new CGPoint (1, 1));
			path.LineTo (new CGPoint (1, 0));
			return path;
		}
예제 #31
0
 public static UIBezierPath FromRect(CGRect rect)
 {
     return(new UIBezierPath(NSBezierPath.FromRect(rect)));
 }
예제 #32
0
		public UIBezierPath () : base()
		{
			// Initialize
			this.path = new NSBezierPath();
		}
예제 #33
0
 public static UIBezierPath FromRoundedRect(CGRect rect, nfloat radius)
 {
     return(new UIBezierPath(NSBezierPath.FromRoundedRect(rect, radius, radius)));
 }
예제 #34
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;
		}
예제 #35
0
 private void DrawLine(NSColor color, PointF p1, PointF p2)
 {
     color.Set();
     NSBezierPath.StrokeLine(Invert(p1), Invert(p2));
 }